open_spiel icon indicating copy to clipboard operation
open_spiel copied to clipboard

Fix #1254: Convert pyspiel game state to dict

Open Ayah-Saleh opened this issue 4 months ago • 3 comments

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.

Ayah-Saleh avatar Sep 26 '24 18:09 Ayah-Saleh