add simulate
This commit is contained in:
parent
a75decca44
commit
69618c2a1f
|
@ -112,6 +112,16 @@ class GameNode(object):
|
||||||
def runSimulation(self):
|
def runSimulation(self):
|
||||||
self.backPropagate(self.simulate())
|
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):
|
def getChildren(self):
|
||||||
possibleMoves = self.state.getPossibleMoves()
|
possibleMoves = self.state.getPossibleMoves()
|
||||||
children = []
|
children = []
|
||||||
|
|
Loading…
Reference in New Issue