Skip to content

Conversation

@sayansil
Copy link
Owner

@sayansil sayansil commented Jun 4, 2025

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:

    • DatabaseManager can 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 the RAW_WORLD column to ECOSYSTEM_MASTER.
    • Methods read_row_by_year and get_available_years were added to DatabaseManager for targeted snapshot access.
    • The God class's load_snapshot method now restores the full simulation state from the raw world buffer, ensuring accurate rollback.
    • God::happy_new_year now saves this complete state when gods_eye is enabled.
  • Python API:

    • The pyecosystem Python 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:

    • A new Python script Python/sample_timetravel.py demonstrates how to use the snapshot feature.
    • docs/README.md has 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

  • My code follows the code style of this project.
  • The code base is in a better state after this PR.
  • The level of testing this PR includes is appropriate.
  • I have considered the impact that this change will cause on application performance.

Git requirements

  • I don't have multiple unrelated changes in the same PR.
  • My branch is in sync with latest production branch.

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:**
    - `DatabaseManager` can 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 the
      `RAW_WORLD` column to `ECOSYSTEM_MASTER`.
    - Methods `read_row_by_year` and `get_available_years` were added to
      `DatabaseManager` for targeted snapshot access.
    - The `God` class's `load_snapshot` method now restores the full
      simulation state from the raw world buffer, ensuring accurate rollback.
    - `God::happy_new_year` now saves this complete state when `gods_eye`
      is enabled.

- **Python API:**
    - The `pyecosystem` Python 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:**
    - A new Python script `Python/sample_timetravel.py` demonstrates
      how to use the snapshot feature.
    - `docs/README.md` has 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.
@sayansil sayansil requested a review from DarkStar1997 June 4, 2025 05:07
@sayansil
Copy link
Owner Author

sayansil commented Jun 4, 2025

@hit-11 someone has picked up your feature-request 😌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants