diff options
Diffstat (limited to 'imago/engine/core.py')
-rw-r--r-- | imago/engine/core.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/imago/engine/core.py b/imago/engine/core.py index 44da3b8..09ee51d 100644 --- a/imago/engine/core.py +++ b/imago/engine/core.py @@ -1,18 +1,21 @@ """Imago GTP engine""" -from imago.engine.monteCarlo import MCTS +from imago.engine.decisionAlgorithmFactory import DecisionAlgorithms, DecisionAlgorithmFactory from imago.gameLogic.gameState import GameState DEF_SIZE = 7 DEF_KOMI = 5.5 +DEF_ALGORITHM = DecisionAlgorithms.MONTECARLO class GameEngine: """Plays the game of Go.""" - def __init__(self): + def __init__(self, decisionAlgorithmId = DEF_ALGORITHM): self.komi = DEF_KOMI self.gameState = GameState(DEF_SIZE) - self.mcts = MCTS(self.gameState.lastMove) + self.daId = decisionAlgorithmId + self.daFactory = DecisionAlgorithmFactory() + self.da = self.daFactory.create(self.daId, self.gameState.lastMove) def setBoardsize(self, newSize): """Changes the size of the board. @@ -20,14 +23,14 @@ class GameEngine: It is wise to call clear_board after this command. """ self.gameState = GameState(newSize) - self.mcts = MCTS(self.gameState.lastMove) + self.da = self.da.__init__(self.gameState.lastMove) def clearBoard(self): """The board is cleared, the number of captured stones reset to zero and the move history reset to empty. """ self.gameState.clearBoard() - self.mcts.clearBoard() + self.da.clearBoard() def setKomi(self, komi): """Sets a new value of komi.""" @@ -48,11 +51,11 @@ class GameEngine: row = vertex[0] col = vertex[1] self.gameState.playMoveForPlayer(row, col, color) - self.mcts.forceNextMove(vertex) + self.da.forceNextMove(vertex) def genmove(self, color): """Returns a list representing coordinates of the board in the form (row, col).""" - coords = self.mcts.pickMove().coords + coords = self.da.pickMove().coords #TODO: The move should NOT be played in its generation. This method is just for #suggesting a move. #self.gameState.playMoveForPlayer(coords[0], coords[1], color) |