Merge pull request #1 from sproblvem/add_rules

Add rules
This commit is contained in:
Wenbo Hu 2017-12-13 14:35:39 +08:00 committed by GitHub
commit d280260a46
2 changed files with 19 additions and 1 deletions

View File

@ -202,6 +202,24 @@ class Executor:
elif color_estimate < 0: elif color_estimate < 0:
return utils.WHITE return utils.WHITE
def _add_nearby_stones(self, neighbor_vertex_set, start_vertex_x, start_vertex_y, x_diff, y_diff, num_step):
'''
add the nearby stones around the input vertex
:param neighbor_vertex_set: input list
:param start_vertex_x: x axis of the input vertex
:param start_vertex_y: y axis of the input vertex
:param x_diff: add x axis
:param y_diff: add y axis
:param num_step: number of steps to be added
:return:
'''
for step in xrange(num_step):
new_neighbor_vertex = (start_vertex_x, start_vertex_y)
if self._in_board(new_neighbor_vertex):
neighbor_vertex_set.append((start_vertex_x, start_vertex_y))
start_vertex_x += x_diff
start_vertex_y += y_diff

View File

@ -246,7 +246,7 @@ class strategy(object):
self.simulator.history = copy.copy(history) self.simulator.history = copy.copy(history)
self.simulator.board = copy.copy(history[-1]) self.simulator.board = copy.copy(history[-1])
state = self.data_process(self.simulator.history, color) state = self.data_process(self.simulator.history, color)
mcts = MCTS(self.simulator, self.evaluator, state, self.simulator.size ** 2 + 1, inverse=True, max_step=100) mcts = MCTS(self.simulator, self.evaluator, state, self.simulator.size ** 2 + 1, inverse=True, max_step=10)
temp = 1 temp = 1
prob = mcts.root.N ** temp / np.sum(mcts.root.N ** temp) prob = mcts.root.N ** temp / np.sum(mcts.root.N ** temp)
choice = np.random.choice(self.simulator.size ** 2 + 1, 1, p=prob).tolist()[0] choice = np.random.choice(self.simulator.size ** 2 + 1, 1, p=prob).tolist()[0]