add simulate
This commit is contained in:
parent
a75decca44
commit
69618c2a1f
|
@ -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 = []
|
||||
|
|
Loading…
Reference in New Issue