[tools] Input logging for state restoration (partial replay)

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4374
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

[tools] Input logging for state restoration (partial replay)

Post by boskid »

TL;DR
Ability to put game into state where every input is streamed and later to resume game using this stream
What ?
When player starts a new game or loads save file, game enters known state and is playable. When player does something and then game crashes (or is closed without saving) progress is lost. Logging all inputs could be used to restore game state to last recorded tick even in case of crash (well, restored state could also crash but this gives insight into reproduction). Input should be recorded before processing it.

Game is already capable of streaming inputs (multiplayer), game is deterministic enough and can restore game state using input records (multiplayer's "catching up"). This would be "partial replay" as it would require initial state in form of map-gen-settings (when no prior save is available) or link to existing save file, info about version (in case of using old save in newer version), and series of input records. In case of crash, this file would be created (medium RAM requirement to hold all inputs in case of this) or could be continously updated during play. If crash happens that causes game to be not possible to save(consistency check during saving), at least there would be record of all inputs and you could replay it and during replay choose earlier time when game state is not corrupted and can be saved to recover progress. Full record could be used to investigate crashes.

By pointing into initial state, this replay data could be created and used even after map migration - replay would cover input records from only one game version (and set of mods)
Why ?
1/ Because of recurring issues with integrity checks with trains (that are not precise as to what caused it, only that state is corrupted)
2/ as generic tool for crash reproduction
3/ to restore at least some progress after save
Alternative changes
Another option is to silently, always buffer inputs in case of crash. When crash happens - dump inputs (with hint as to where latest savefile is[+hash of it] or map-gen-settings [in case of no prior save] into file next to factorio-current.log and dump file).
Including input record in desync report would help with investigating desyncs without need to reproduction - desync report would already contain reproduction in form of this input stream (well, initial state in form of save-file would be required, but could be also included in desync report)
Post Reply

Return to “Ideas and Suggestions”