You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified the GetChildren method of GameNode, so that the GameNodes are self-contained, and we don't need to go back and forth between state and nodes. Hence, our successor function is part of the GameNode definition. The new method is:
defgetChildren(self):
children= []
# Translations relative to the middle of the boardfortranslationinrange(-5, 6, 1):
forrotationinrange(0, 4, 1): # Number of rotations# Simulate the game by dong a few rotations and translations: get the new state (for each performed move)new_state=GameState.TetrisGame(self.state.grid, self.state.curr_piece, self.state.next_piece, rotation, translation)
action= (rotation, translation)
child=GameNode(new_state, self, action)
children.append(child)
# Calculate the hash value# hash_val = abs(hash(new_state_string))# Check for hash collision# if (self.hashtable[hash_val % 1000000] == 0):# self.hashtable[hash_val % 1000000] = 1# child = GameNode(new_state.getGrid(), piece, next_piece, new_state.getActions())# self.children.append(child)returnchildren
However, I'm getting about 44 children out of each state. I think we should only take into account some of them. But which ones?
Furthermore, this function takes quite some CPU time. I think it could be because we run deepcopy while creating new GameState objects. Could this be the case?
The text was updated successfully, but these errors were encountered:
Hashing now works properly, no more duplicate nodes.
Considering the CPU time, we could start with managing the ranges in;
for translation in range(-5, 6, 1):
for rotation in range(0, 4, 1):
such that not unnecessary game simulations are done. For example, if a square block is falling there is no point in rotating it. If this does not make it, we should indeed look into how we manage the GameState objects.
I modified the GetChildren method of GameNode, so that the GameNodes are self-contained, and we don't need to go back and forth between state and nodes. Hence, our successor function is part of the GameNode definition. The new method is:
However, I'm getting about 44 children out of each state. I think we should only take into account some of them. But which ones?
Furthermore, this function takes quite some CPU time. I think it could be because we run deepcopy while creating new GameState objects. Could this be the case?
The text was updated successfully, but these errors were encountered: