Hello, i have made a chess game in Python using pygame.
To do so, i have made an object of a "chess game" class i also made. Now i would like to save games so we can play chess later.
I know that can use pickle (or other modules like json, and hdf5) to save my games. I am aware that pickle can only let me save objects if i give their dictionnaries of variables in parameter for the pickle.dump method.
The problem is the following: How to save a python object whose attributes also are objects and that on multiple levels?
To explain myself: I have made an object of my "Chess" class whose attributs contain other objects.
For exemple, "board" is an attribut of chess and is an object of my "Board" class, and board also contains objects, one of which is the grid of all the pieces (it's a matrix made with a list in a list) and each of element of the grid is an object "piece" of my "Piece" class.
So is there a simple way to save all my game attributs without having to decompose each objects to get their dictionnaries? and if yes, is it possible to save objects containing other objects as many times as i want?
Thank you very much in advance! :D