Trait agents::simulation::Simulation[][src]

pub trait Simulation {
    type SyncState: 'static + Clone + Send + Sized + Default;

    const TICK_THROTTLE: Duration;

    fn setup(&mut self, sync: &mut Input<Self::SyncState>);
fn tick(&mut self, sync: &mut Input<Self::SyncState>, duration: Duration); }
Expand description

A simulation is a type with State. State is advanced in fixed time steps and is presented via the triple-buffer’s Input interface.

The big idea is that a simulation can be run in a separate thread at whatever tick interval the specific implementation requires. Neither the simulation nor the main thread need to block, instead the most recent state is always made available via the triple-buffer.

Simulations are typically managed by a Worker instance.

Associated Types

The portion of the simulation’s state which will be sent between threads via the triple buffer.

The state must be cloneable and defaultable so that it can be safely passed via the triple buffer.

Associated Constants

The minimum tick duration for this simulation. If an individual tick() invocation takes less than this amount of time, then the Worker will delay the next tick for the difference.

Required methods

Initialize the simulation. Called once right before starting the main loop.

Advance the simulation by one time step (fixed steps).

Implementors

impl Simulation for VehicleWorld