elevator-core
From a 5-story office to a space elevator — same engine, same API.
An engine-agnostic, tick-based elevator simulation library for Rust.
Plug it into Bevy, Unity, your own renderer, or run headless.
Guide · API Reference · Examples · Changelog
What it does
You define stops at arbitrary positions on a 1-D axis, spawn riders, and call step(). The engine handles dispatch, trapezoidal motion, doors, boarding, and metrics — your code just reacts to events.
use *;
use ElevatorConfig;
Use cases
| Scenario | How |
|---|---|
| Office building with 5 floors | Stops at 0, 4, 8, 12, 16 |
| Skyscraper with sky lobbies | Multi-group dispatch, express zones |
| Space elevator | Stops at 0 and 1,000,000 — same engine |
| Player-controlled car | ServiceMode::Manual + velocity commands |
| Custom AI dispatch | Implement DispatchStrategy::rank() |
| VIP passengers, cargo, robots | Extension storage — attach any data |
Features
- Arbitrary stop positions: not limited to uniform floors; model buildings, towers, orbital tethers
- Pluggable dispatch: built-in SCAN, LOOK, Nearest Car, ETD, Destination; or bring your own via the
DispatchStrategytrait - Rider lifecycle: Waiting → Boarding → Riding → Exiting → Arrived/Abandoned, with hooks at each transition
- Extension storage: attach arbitrary typed data to riders, elevators, and stops
- O(1) population queries: who's waiting, riding, or resident at any stop, instantly
- Deterministic replay: same inputs produce the same simulation every time
- Snapshot save/load: serialize full simulation state for replays or networking
- Metrics: wait times, ride times, throughput, delivered counts, all built-in
Non-goals
This is a simulation library, not a game. It deliberately does not include:
- Rendering or UI — wrap it with Bevy, Unity (FFI), or anything else
- AI passengers or traffic generation — use the optional
trafficfeature flag, or drive arrivals yourself - Building layout or 2-D floor plans — the sim is 1-D by design
Visual demo
The workspace includes a Bevy frontend that renders the simulation in 2-D:
Feature flags
| Flag | Default | Adds |
|---|---|---|
traffic |
yes | Poisson arrivals, daily traffic patterns. Pulls in rand. |
energy |
no | Per-elevator energy/regen modeling. |
License
MIT or Apache 2.0, at your option.