-
Notifications
You must be signed in to change notification settings - Fork 67
Description
It should be possible to save the current state of your game, and then later to load from a saved game. There is nothing theoretically difficult about this, but it will take a good deal of engineering. Off the top of my head, a save would need to include.
- A version number, so that we can do something reasonable with saves created by a previous version of the game.
- The current state of the world:
- The seed used to generate the world
- Which tiles have been loaded
- The contents of those tiles (either the complete contents, or perhaps just a catalog of the cells whose entity contents have changed from their initial value)
- All (active and inactive) robots, including their CEK machine state.
- Note, when saving entities (either in the world map, or in an inventory, or a robot entity), if the hash matches the hash of a standard entity, we only have to save the hash. Otherwise we must serialize the entire entity.
- Note that for this to work well on old save files, we need to keep old/outdated entities around (perhaps in a separate
old_entities.yamlfile) so that we can load them. - Alternatively (this might be simpler), every save file could just contain a complete description of every entity which needs to be referenced?
- Note that for this to work well on old save files, we need to keep old/outdated entities around (perhaps in a separate
- Probably various other fields of the
GameStateand/orUIState.
For loading entities and recipes, we use .yaml files, so that they can be easily human-editable. However, for saving the entire game state we definitely don't want to do that. Instead we should use some kind of binary serialization framework so save files will be as compact as possible. Since we can already load scenarios from .yaml files, it makes sense at this point to just double down on that and make save files use the same format.
Once we enable this feature, we'll have to be very careful about versioning things such as entities and recipes, world generation, etc., and keep around old versions of things (as much as is reasonable) so that we can correctly load save files produced by older versions of the game.
Note, a related issue is #7 .