Skip to content

GetAllStates relies on the the unreliable state string instead of the history #399

@gabrfarina

Description

@gabrfarina

Hit as part of #376 .

+@lanctot +@michalsustr +@finbarrtimbers

The implementation of GetAllStates expects that state->ToString() be unique for states, which is not true. For example, in the Battleship game, ToString() returns an ascii art representation of the player boards. In Go, my understanding is that ToString() renders the Go board (edit see also this discussion). Neither of these mappings are injective: different orders of moves can result in the same boards, and therefore the same ToString().

https://github.com/deepmind/open_spiel/blob/de2c9ef57038829c2709becb0104e3b2d76725cc/open_spiel/algorithms/get_all_states.cc#L47-L53

This results in the method failing to explore the full game tree. Since the method is performing a DFS on a tree, it is impossible to hit the same state twice, so I am not sure what the comment add only if not already present was supposed to catch. I suggest the following:

  • If we want to keep the map, we should have histories as key.
  • There is no need to keep an expensive map: a vector of (unique) pointers to states would be more efficient and simplify the code even further. I'm not sure how breaking a change that would be though?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions