Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def grow(self, depth=1e900000):
- '''Grow the tree of GameStates, starting from this one.
- Assumptions:
- The tree of GameStates generated from this one is finite, and is
- specified (recursively) by self.value.make_move()
- '''
- if depth == 0:
- return self
- h = hash(self.value)
- if h not in gamestates:
- for m in self.value.next_move():
- child = GameStateNode(self.value.make_move(m), m)
- child = child.grow(depth -1)
- self.children.append(child)
- gamestates[h] = self
- else:
- for child in gamestates[h].children:
- self.children.append(child)
- return gamestates[h]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement