Skip to content

Saving and loading games #50

@byorgey

Description

@byorgey

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.yaml file) 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?
  • Probably various other fields of the GameState and/or UIState.

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 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-ProjectA larger project, more suitable for experienced contributors.G-CESK machineThis issue has to do with the CESK machine (the Swarm language interpreter).G-EntitiesAn issue having to do with game entities.G-Game StateAn issue having to do with the game state record.G-RobotsAn issue having to do with robots.G-ScenariosAn issue having to do with scenario design, the way scenarios are described and loaded, etc.G-StructuresStructures (i.e. recognizable groupings of entities in the world)G-WorldAn issue having to do with world design, world generation, etc.S-CriticalThis is an issue that seriously affects playability or user experience.Z-FeatureA new feature to be added to the game.Z-User ExperienceThis issue seeks to make the game more enjoyable to play.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions