resequence

Crates.ioresequence
lib.rsresequence
version0.1.0
created_at2026-01-17 00:33:13.06917+00
updated_at2026-01-17 00:33:13.06917+00
descriptionTime-travel simulation engine based on Achron's Resequence engine patterns
homepagehttps://github.com/emberian/resequence-rs
repositoryhttps://github.com/emberian/resequence-rs
max_upload_size
id2049586
size82,186
libs (github:rust-lang:libs)

documentation

https://docs.rs/resequence

README

resequence

A time-travel simulation engine based on patterns reverse-engineered from Achron's Resequence engine (2011). This crate preserves the intellectual heritage of Achron's innovative time manipulation mechanics for future game development and research.

Features

  • Event-Linked Entities: Entities store history as timestamped events, not full snapshots. O(log n) historical queries via binary search.
  • Timewaves: Execution contexts that move through time at variable speeds. Multiple waves can view the same timeline at different positions.
  • Identity Linking: When entities time-travel (chronoport), they create linked duplicates sharing a "name ID" for paradox detection.
  • Sorted Wave Processing: Timewaves are sorted by position each tick. Earlier waves propagate state changes to later waves for causal consistency.

Quick Start

use resequence::{Engine, EntityState};

#[derive(Clone, Default, Debug)]
struct Unit {
    hp: i32,
    x: f32,
    y: f32,
}

impl EntityState for Unit {}

fn main() {
    let mut engine = Engine::<Unit>::new();

    // Spawn a unit
    let unit = engine.spawn(Unit { hp: 100, x: 0.0, y: 0.0 });

    // Advance time
    for _ in 0..10 {
        engine.tick();
    }

    // Time travel! Create a duplicate at t=5
    engine.chronoport(unit, 5).unwrap();

    // Now there are two linked copies of the unit
    let duplicates = engine.get_same_name_entities(unit);
    assert_eq!(duplicates.len(), 2);
}

Lifecycle States

Entities transition through lifecycle states matching the original engine:

  • Unborn: Empty slot or not yet scheduled
  • Prebirth: Scheduled to appear (e.g., destination of chronoport)
  • Born: Normal active state
  • Chronoporting: Mid-time-travel
  • Dead: Destroyed

Time Window Constraints

Chronoport operations can be constrained to a time window:

// Allow chronoport up to 100 ticks in the past, 50 ticks in the future
engine.set_time_window(Some(100), Some(50));

Applications

Beyond games, these patterns are useful for:

  • Simulation debugging: Add past observation waves to inspect state
  • What-if analysis: Fork timelines, apply different decisions, compare
  • Undo/redo systems: Position-based state views without explicit snapshots
  • Distributed consensus: Multiple nodes as waves at different timestamps

Examples

Run the examples with:

cargo run --example basic
cargo run --example paradox
cargo run --example timewave_sync
cargo run --example time_window

License

MIT

Commit count: 3

cargo fmt