The Simulation Runtime IS the Spine.
A small engine and scripting language for story-driven games, written in Zig. The world is a list of plain facts, characters follow scripts that can pause and resume, and any moment can be rewound and replayed.
Lantern Watch: The Harbour
The dawn packet is waiting outside the shoals. Follow the watch handover through ten harbour stops and clear the ship from the outer beacon house. Play with typed commands; the map is optional.
Classic Adventure & Systemic Proofs
Thirteen proofs of concept drive the engine end to end. Each runs without a window and checks its own outcome;
twelve also rewind and check the world matches (the Saltmarket does not yet).
They live in proofs/, depend on the engine through its public module, and build as a separate
bespoke-proofs binary. Each card below opens that proof on its own page, where the
deck runs the proof's own script in your browser.
The Tavern Heist
A patrolling Guard carries the Cheese. The Bard's lute charms him, and the Cat takes the cheese while he is distracted. No cutscene: rules react to facts as they change.
The Pip-Spitting Green
Tamsin wants the cherry-pit spitting prize at the Brackwater Harvest Fair. She blows a conch to send the judge looking for the herring fleet, moves the distance pegs, drinks a thick treacle cider, and waits for a sea breeze.
The Borrowed Beard
Tamsin must pass as Captain Rook to claim the last berth on the packet boat. Charcoal, sail tape, honey, his sailing papers, and some dog fur combine across three scenes into a convincing disguise.
The Living Village
Six villagers with hunger, energy, and money run their own days. A starving drifter steals, a witness talks, rumours spread, and the Sheriff makes an arrest, with nothing scripted in between.
The Donkey of Lamp Point
Cudgel the donkey shoves Tamsin down whenever she heads for the cellar hatch. While he ambles back to his post, haul the old anchor into his rope line, and the way down to the wreckers' cellar is clear. Each step is an arrival rule in the script.
The Well of Three Tides
Ossie in 1712, Nell in 1912, and Juno in 2112 pass items through Doctor Brine's Tide Wells. A change in the past is a fact the future reads, so each era's puzzles depend on the others.
Caustic Grog
Three cups of grog eat through themselves on the way from the barrel to the lock. Pour from cup to cup before each fails, and arrive with enough to dissolve the lock.
Brackwater Barbs
A fencing duel fought with barbs, taking turns: whoever wins a round attacks next. You learn a comeback by hearing an opponent use it against your barb. Mistress Vell throws her own versions of the barbs, which the same comebacks answer, and the barkeep tires of repeated questions. Rounds and moods are world facts, so a rewind replays them exactly.
The Saltmarket: Three Ways In
Pilot Ashe's lost logbook is behind Broker Quince's bills of lading. Cunning, Muscle, or Crew: choosing an approach locks the other routes, limits the dialogue to that approach, and runs only that approach's solution.
The Copper Weathercock
A weathercock falls through Wren's attic roof 28 days early, and the world splits into a borrowed month with a countdown. Flood the Customs House, get a note to Hester Quill, and carry the weathercock into the fog whirl before time runs out, and the month merges back; miss it and the month tears away, so you rewind and try again.
The Bell Tower
Play four-note tunes (drafts) on a musical staff to change the world. Played backwards, each tune does its opposite.
The Castle Fire Escape
Burn a tapestry to find the hidden door, then soak the door before the fire reaches it. Water floods back through the corridor and puts the fire out.
The Larkspur Observatory
Investigate a missing comet plate while the staff go about their night. Each of them has an agenda and intercepts you when your evidence threatens it. Type your commands.
Simulation as First Principle
Drawing spiritual inspiration from the deterministic clockwork of Chris Sawyer's RollerCoaster Tycoon, the actor/cue architecture of Sierra's SCI and LucasArts' SCUMM, and the emergent relationship graphs of Dwarf Fortress. BeSpoke counts time in whole steps (ticks) and stores the world as facts, so the same inputs always produce the same story.
Engine-as-Spine
The engine runs the game; the screen only shows it. The engine owns the clock, the characters, the map, and the facts. The window (SDL2 on the desktop, a canvas in the browser) draws what the engine reports and passes player input back; it never changes the world itself.
_ = try host.start_script(&world, &spatial, &vm, &compiled);
_ = try host.tick(&vm, &compiled);
Flat Relational State
Everything the game knows is a row of four values: (subject, relation, object, expires_at_tick),
such as "the Guard carries the Cheese". A fact can carry an expiry tick, so a charm, a distraction,
or an alarm ends on its own without cleanup code.
remember CharmedBy(Guard, Bard) for 180 ticks
Fibers & Time Travel
Write behaviour like a play script: a routine walks, waits, and speaks, and pauses with wait or
wait until without blocking anything else. The facts sit in four flat columns, so a snapshot copies
those columns and the name tables as raw bytes; rewinding copies them back.
wait 5 ticks
walk Guard to Hearth
Dialogue That Reads the World
Adventure-game dialogue usually tracks what the player has said with a pile of yes/no flags. In BeSpoke, each dialogue option carries a condition written against the world's facts, and the option appears only while that condition holds. Both examples below are excerpts from the Brackwater Barbs proof's script.
A Duel Declared as Data
The script lists barb and comeback pairs; the engine's duel module turns them into facts
(HeardBarb, MasteredComeback, Counters). Each round, the comebacks the player
may choose are the ones they have learned, filtered through the same dialogue engine as every other choice.
The dialogue text is shortened here.
duel BrackwaterBarbs:
pair Barb1:
challenge "..."
reply "..."
variant 1 "..."
# fifteen pairs in all
fallback "..."
fallback "..."
win 3
relations HeardBarb MasteredComeback Counters VellVariant FencingTier Advantage DuelsWon
fatigue Inquiries "welcoming":
stage AnnoyedWith 2 100 "annoyed"
stage FuriousWith 3 250 "furious"
Characters Who Lose Patience
Ask the barkeep the same question twice and the answer changes. Each option checks a fact, and the annoyance is a fact that expires after 100 ticks, so the barkeep calms down on their own.
on cue TalksTo(Tamsin, Barkeep):
choice "Tell me about Harbourmaster Odell." if not Inquired(Tamsin, Odell, _):
say Barkeep: "Odell? Counts every barrel twice and trusts nobody once."
remember Inquired(Tamsin, Odell, 1)
choice "Tell me more about Harbourmaster Odell." if Inquired(Tamsin, Odell, 1):
say Barkeep: "I've told you already. His office is above the customs shed."
remember Inquired(Tamsin, Odell, 2)
remember AnnoyedWith(Barkeep, Tamsin) for 100 ticks
choice "About Harbourmaster Odell..." if AnnoyedWith(Barkeep, Tamsin):
say Barkeep: "Ask me once more and you'll be drinking from the canal!"
remember FuriousWith(Barkeep, Tamsin) for 250 ticks
How the Engine Is Built
Three views of the same design: what owns the clock, how a player's action becomes a story beat, and how one script reaches every platform.
Engine-as-Spine
The engine is main(). A host only asks for the next tick; one discrete tick runs the VM, the rules, and the declared subsystems, all reading and writing one World of facts.
From Action to Story Beat
Nothing calls a cutscene. A cue changes facts, rules notice the combination on the next tick, and routines pause or resume around them. Speech and music are read from the result.
One Script, Every Platform
A game is a .bespoke script. The engine's compiler turns it into a checked .bspk package, which the same runtime plays in a desktop window, headless in tests, or in the browser. The window and the browser draw the same frame with the same code; only how it reaches the screen differs.
Comparing Engine Philosophies
General-purpose engines are built around drawing frames, with game logic attached to the render loop. BeSpoke starts from the simulation and treats drawing as one consumer of it. The left column describes the common default, not every engine.
| Dimension | Visual-First Scene Graph Engine | Simulation-First Relational Spine (BeSpoke) |
|---|---|---|
Who owns main()? |
Graphics pipeline & frame-rate render loop | The simulation, one whole tick at a time (1 per second by default; the display redraws at 60 Hz) |
| World State Representation | Transform hierarchies, heap pointers & GC objects | Rows of facts in one fixed block of memory |
| Time-Travel & Save States | Custom serializers & object-graph reconstruction | Copy the fact columns and name tables as raw bytes, with a checksum |
| Temporal Logic (Waiting, Routines) | Delta-time accumulation, per-frame callbacks, state booleans | Routines that pause with wait and resume on a later tick |
| Ephemeral State (Buffs, Alerts) | Explicit timer handles & manual polling loops | An expiry tick on the fact itself; the engine drops it when the clock passes |
| Toolchain & Footprint | A large editor and runtime to install | The Zig 0.13 toolchain; the core needs nothing else, and SDL2 only for the desktop window |