diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/MCTS.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/python/MCTS.py b/python/MCTS.py index 91cd41c..fbddceb 100644 --- a/python/MCTS.py +++ b/python/MCTS.py @@ -7,6 +7,7 @@ from GameState import GameState # Based on https://github.com/DieterBuys/mcts-player/ + class GameController(object): def get_next_move(self, state): # when you get a new move, it is assumed that the game is not ended yet @@ -21,7 +22,6 @@ class MCTSNode(object): """ def __init__(self, state, parent=None, move=None): - self.parent = parent self.move = move self.state = state @@ -37,7 +37,7 @@ class MCTSNode(object): # to the sum of its children's plays def ucb(child): win_ratio = child.score / child.plays \ - + math.sqrt(2 * math.log(self.plays) / child.plays) + + math.sqrt(2 * math.log(self.plays) / child.plays) return win_ratio return max(self.children, key=ucb) @@ -109,7 +109,7 @@ class MCTSGameController(GameController): move = choice(tuple(node.pending_moves)) return node.expand_move(move) - def simulate(self, state, max_iterations=2000): + def simulate(self, state, max_iterations=1000): state = deepcopy(state) move = state.get_random_move() @@ -129,7 +129,7 @@ class MCTSGameController(GameController): node.score += node.get_score(result) node = node.parent - def get_next_move(self, state, time_allowed=2.0): + def get_next_move(self, state, time_allowed=1.0): super(MCTSGameController, self).get_next_move(state) self.root_node = MCTSNode(state) |