Colossal Cave Adventure (350-point) with a forgiving command parser
#20 in Riparion/riparion-retro — merged 2026-06-10
Adds Colossal Cave Adventure (the 1977/1995 350-point Crowther & Woods game) as a client-side WASM Dioxus app, plus a reusable, LLM-free forgiving command parser.
The game
- Faithful Rust port of
brandon-rhodes/python-adventure(advent.datembedded). CPython's Mersenne Twister is reproduced bit-for-bit, so seeded walkthroughs replay exactly — four golden-master walkthroughs assert engine output byte-for-byte. - Engine/UI split per the repo convention: pure host-testable engine, Dioxus CRT-styled UI (transcript, status bar, command line), localStorage saves + hall of fame.
Forgiving input inference
The classic parser resolved each word by exact match, so take the lamp, pick up lamp, x lamp, and typos like lmap all failed. Intent is now recovered offline (no LLM, no network).
New crate crates/parser-kit — game-agnostic, zero-dep tiered engine:
- Bounded Damerau–Levenshtein (hand-rolled, no
strsim, to keep WASM bundles lean). - Present-ranked fuzzy matching.
- Pipeline: leave-valid-untouched gate → filler strip → phrasal-verb collapse → alias expansion → collapse-to-pair → fuzzy correction → "did you mean?".
- API names no Adventure types; the consumer supplies word tables plus
resolves_ok/presentclosures.
Adventure wired in (engine/parse_infer.rs tables + game.rs maybe_infer/resolves_ok/token_present, Pending::DidYouMean). Now understood: take the lamp, pick up lamp, x lamp, i, take the small brass lamp, take lmap. Genuinely ambiguous typos (e.g. wace → WAVE/WAKE) prompt "Do you mean …?". The vocabulary chip strip above the input is removed now that the parser does the work.
Why the golden masters stay green
The entire inference layer is gated behind a resolves_ok Tier-0 check: any input the parser already understands returns unchanged, taking the identical code path and RNG sequence. Only formerly-failing input is rewritten.
Tests
parser-kit: 22 unit tests (edit distance, fuzzy ranking, every pipeline tier).adventure: 24 tests — four golden-master walkthroughs byte-for-byte unchanged, plus filler/phrasal/alias/collapse/fuzzy/gibberish/did-you-mean coverage.cargo check --workspaceand clippy clean.
🤖 Generated with Claude Code
Last updated 2026-06-11
Links to this note
Merged pull requests, newest first.