add simulate

This commit is contained in:
Nemo 2018-03-04 03:58:12 +05:30
parent a75decca44
commit 69618c2a1f
1 changed files with 10 additions and 0 deletions

View File

@ -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 = []