Skip to content

Regression tests for Polypiled's rule changes on the real core - #103

Open
kafuji wants to merge 2 commits into
claude/headless-mcpfrom
claude/rule-regression-tests
Open

kafuji wants to merge 2 commits into
claude/headless-mcpfrom
claude/rule-regression-tests

Conversation

@kafuji

@kafuji kafuji commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Stacked on #101 (headless runner). Retarget this PR to main before deleting claude/headless-mcp after #101 merges, or GitHub closes it.

What

scripts/headless/rules.test.mjs checks the rule changes in docs/rule-changes.md against the real core, using the headless runner from #101. Each test sets up a scene in debug mode where it needs one, then checks what tells the Polypiled rule apart from vanilla.

Rule Checked
Hunger Hungry appears at 400 nutrition (vanilla 150), read with reveal
Worn armor weight Ring mail counts 125 of its 250 once it is on
Overeating Food coma ("You pass out from overeating." / "You come out of your food coma."), and the hero lives
Food spoilage A fresh newt corpse tastes okay. After 200 turns: "The corpse smells putrid. Eat it anyway?" before the first bite. Apples kept 200 turns are never rotten
Power regeneration A Wizard at XL1 regains Pw every 12 turns (vanilla 18)
Identification by obvious effect Engraving names the wand of striking
Bag of holding safety Putting a known bag of holding into one asks first, and declining keeps both
Polypiling 10 daggers "shimmer and fuse" into 4 objects; 20 rocks stay rocks
Pet orders #chat with the pet opens "What do you tell the little dog?" with the four orders
Sokoban No mimics, molds, jellies or hiders on any of the four levels, in four seeds
The thieves' den One level above Medusa; stocks a wand of wishing, a magic lamp, a magic whistle and a unicorn horn; peaceful shopkeeper and at least four watch guards
Midway set pieces At depth 13–16 and holding one of the three set pieces, in three seeds

The 13 tests run in parallel in about 2 s. The results were the same in three consecutive runs.

Where they run

  • npm run test:rules runs them alone; npm run test:headless now includes them.
  • ci.yml gains a "Headless game tests" step (npm run test:headless).
  • build-core-wasm.yml runs the rule tests on each fresh build. It points the client at the build with the new POLYPILED_CORE_DIR, so a core change that breaks a rule fails before it is shipped to public/. These steps come after the "source tree is unchanged" check, because npm i rewrites package-lock.json.
  • .agents/rules/AGENTS.md asks for a scenario with every new rule change, and docs/rule-changes.md lists what is covered.

Not covered yet

These depend on chance over many trials, on long waits, or on scenes that are harder to set up:

  • missile breakage rates, item destruction rates, fountain and sink odds
  • characteristic recovery, spell memory
  • weapon skill families
  • shops (restocking, appraisal, the shopkeeper defending customers, pets returning goods)
  • priests reading blessings
  • Gehennom mapping on arrival, no mysterious force
  • two-weapon artifacts
  • container bursts

Testing

  • npm run test:headless: 26 of 26 pass, locally on the core in public/.
  • POLYPILED_CORE_DIR=<copy of public> npm run test:rules: 13 of 13 pass.

🤖 Generated with Claude Code

kafuji and others added 2 commits November 26, 2026 22:11
scripts/headless/rules.test.mjs plays the rule changes of
docs/rule-changes.md with the headless runner, setting scenes in debug
mode and checking what tells each change from vanilla:

- Hungry at 400 nutrition; worn armor counting half its weight
- a food coma instead of choking; a fresh corpse is fine, an old one
  smells putrid before the first bite, other food keeps
- a Wizard's Pw every 12 turns at XL1
- engraving names a wand of striking
- the bag of holding question
- polypiling: 10 daggers fuse into 4 objects, rocks stay rocks
- the pet orders menu
- nothing that stays put and no mimics in Sokoban (four seeds)
- the thieves' den just above Medusa with a wand of wishing and the
  held-back tools
- a midway set piece at depth 13 to 16 (three seeds)

The 13 tests run in parallel in about two seconds. npm run test:rules
runs them alone; test:headless includes them. CI runs test:headless, and
Build game core (WASM) runs the rule tests on each fresh build, pointing
the client at it with POLYPILED_CORE_DIR. AGENTS.md asks for a scenario
with every new rule change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant