feat: Implement time travel (snapshot rollback) capability #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces a feature allowing you to revert the simulation to a previously saved state from a specific year.
Key changes include:
Database & State Management:
DatabaseManagercan now save and retrieve the complete raw simulation world state (RAW_WORLD BLOB) for each year, in addition to summaries. This required a manual schema change to add theRAW_WORLDcolumn toECOSYSTEM_MASTER.read_row_by_yearandget_available_yearswere added toDatabaseManagerfor targeted snapshot access.Godclass'sload_snapshotmethod now restores the full simulation state from the raw world buffer, ensuring accurate rollback.God::happy_new_yearnow saves this complete state whengods_eyeis enabled.Python API:
pyecosystemPython wrapper now exposes: -load_snapshot_from_year(year): To load a snapshot. -get_list_of_available_snapshots(): To list savailable years. -get_current_year(): To get the current simulation year.Example & Documentation:
Python/sample_timetravel.pydemonstrates how to use the snapshot feature.docs/README.mdhas been updated to briefly describe the new feature and the manual database change required.This feature allows for more flexible exploration of simulation dynamics by enabling you to revisit past states and explore alternative evolutionary paths.
Description and Context
Best Practices
Git requirements