Expand description
Top-level simulation runner. Top-level simulation runner and tick loop.
§Essential API
Simulation exposes a large surface, but most users only need the
~15 methods below, grouped by the order they appear in a typical
game loop.
§Construction
SimulationBuilder::demo()orSimulationBuilder::from_config()— fluent entry point; call.build()to get aSimulation.Simulation::new()— direct construction from&SimConfig+ a dispatch strategy.
§Per-tick driving
Simulation::step()— run all 8 phases.Simulation::current_tick()— the current tick counter.
§Spawning and rerouting riders
Simulation::spawn_rider_by_stop_id()— simple origin/destination/weight spawn.Simulation::build_rider_by_stop_id()— fluentRiderBuilderfor patience, preferences, access control, explicit groups, multi-leg routes.Simulation::reroute()— change a waiting rider’s destination mid-trip.Simulation::settle_rider()/Simulation::despawn_rider()— terminal-state cleanup forArrived/Abandonedriders.
§Observability
Simulation::drain_events()— consume the event stream emitted by the last tick.Simulation::metrics()— aggregate wait/ride/throughput stats.Simulation::waiting_at()/Simulation::residents_at()— O(1) population queries by stop.
§Imperative control
Simulation::push_destination()/Simulation::push_destination_front()/Simulation::clear_destinations()— override dispatch by pushing/clearing stops on an elevator’sDestinationQueue.
§Persistence
Simulation::snapshot()— capture full state as a serializableWorldSnapshot.WorldSnapshot::restore()— rebuild aSimulationfrom a snapshot.
Everything else (phase-runners, world-level accessors, energy, tag metrics, topology queries) is available for advanced use but is not required for the common case.
Structs§
- Elevator
Params - Parameters for creating a new elevator at runtime.
- Line
Params - Parameters for creating a new line at runtime.
- Rider
Builder - Fluent builder for spawning riders with optional configuration.
- Simulation
- The core simulation state, advanced by calling
step().