open_spiel
open_spiel copied to clipboard
Fix #1254: Convert pyspiel game state to dict
This pull request introduces the following changes based off issue #1254:
Added ToDict() and FromDict() methods to the State class in spiel.:
- These methods allow converting the game state to a dictionary of array-like structures and restoring the state from such a dictionary.
- ToDict() converts the current state to a dictionary, and FromDict() restores the state from the dictionary representation.
Added a new test case in spiel_test.cc:
- The test verifies that the ToDict() and FromDict() methods work correctly by:
- Converting the state of a Tic-Tac-Toe game to a dictionary.
- Creating a new game state and restoring it using the FromDict() method.
- Making sure that the original and restored states are the same.