Serialization - makingthematrix/gailibrary GitHub Wiki

The main loop of GAI can also be used to serialise the whole GAI state (cells + cell types + graphs + function ids) to eg. JSON and save it. Then, on request, the state can be retrieved. This might be useful for save game operations, but also it makes the whole library more independent: the library could be used almost out of the box for cellular automata simulations other than computer games.

The functions themselves are not serialized. Every time we define a function we tag it with a unique id. The ids are saved. After retrieval, the ids are checked against the functions registry. If some functions are missing โ€“ the retrieval fails. (Some manual fixing methods could be useful, eg. replacing ids with other ids).

Also, continuity between iterations in the main loop makes a case for a separate file storage for cells data. On the other hand, this is a minor issue. Maybe it would be better to create an additional small โ€žcrateโ€ for it, not to integrate it with the core GAI library.