Skip to main content

LockstepWorld

Struct LockstepWorld 

Source
pub struct LockstepWorld { /* private fields */ }
Expand description

Single-threaded simulation world for lockstep (synchronous) execution.

Created from a WorldConfig via new(). Each step_sync() call runs one complete tick: submit commands → drain ingress → run propagator pipeline → publish snapshot → return results.

§Example

let world = LockstepWorld::new(config)?;
for _ in 0..1000 {
    let result = world.step_sync(commands)?;
    let obs = result.snapshot.read(field_id);
}

Implementations§

Source§

impl LockstepWorld

Source

pub fn new(config: WorldConfig) -> Result<Self, ConfigError>

Create a new lockstep world from a WorldConfig.

Validates the configuration, builds the read resolution plan, constructs the arena, and returns a ready-to-step world. Consumes the WorldConfig.

Source

pub fn step_sync( &mut self, commands: Vec<Command>, ) -> Result<StepResult<'_>, TickError>

Execute one tick synchronously.

Submits commands to the ingress queue, runs the full propagator pipeline, publishes the new snapshot, and returns a StepResult containing the snapshot reference, receipts, and metrics.

The returned Snapshot borrows from self, preventing the caller from calling step_sync() again until the snapshot is dropped.

§Errors

Returns TickError if a propagator fails (tick is rolled back atomically) or if ticking is disabled after consecutive rollbacks. On rollback, the error’s receipts field contains per-command rollback receipts plus any submission rejections.

Source

pub fn reset(&mut self, seed: u64) -> Result<Snapshot<'_>, ConfigError>

Reset the world to tick 0 with a new seed.

Reclaims all arena memory, clears the ingress queue, and resets all counters. Returns a snapshot of the initial (zeroed) state.

The seed is stored for future use when propagators support seeded RNG. Currently all runs are fully deterministic regardless of seed.

Source

pub fn snapshot(&self) -> Snapshot<'_>

Get a read-only snapshot of the current published generation.

Source

pub fn current_tick(&self) -> TickId

Current tick ID (0 after construction or reset).

Source

pub fn is_tick_disabled(&self) -> bool

Whether ticking is disabled due to consecutive rollbacks.

Source

pub fn last_metrics(&self) -> &StepMetrics

Metrics from the most recent successful tick.

Source

pub fn seed(&self) -> u64

The current simulation seed.

Source

pub fn consecutive_rollback_count(&self) -> u32

Number of consecutive rollbacks since the last successful tick.

Source

pub fn space(&self) -> &dyn Space

The spatial topology for this world.

Trait Implementations§

Source§

impl Debug for LockstepWorld

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.