From 69618c2a1f3b654d4cc0983d884a86283982049c Mon Sep 17 00:00:00 2001 From: Nemo Date: Sun, 4 Mar 2018 03:58:12 +0530 Subject: [PATCH] add simulate --- gothok/game.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gothok/game.py b/gothok/game.py index c42ae1a..3e5dbc4 100644 --- a/gothok/game.py +++ b/gothok/game.py @@ -112,6 +112,16 @@ class GameNode(object): def runSimulation(self): self.backPropagate(self.simulate()) + def simulate(self): + state = self.state + + while not state.gameOver: + moves = state.getPossibleMoves + randomMove = random.choice(possibleMoves) + state.playMove(randomMove) + + return self.state.result(state) + def getChildren(self): possibleMoves = self.state.getPossibleMoves() children = []