Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Mill Race rules: a tested `mill-race/race.js` that turns pipe tiles to carry the stream to the water wheel, from plain data #191

opened this

Merged 31d 12h ago, live in production

This adds the Mill Race rules in mill-race/race.js with tests in mill-race/race.test.mjs, and nothing outside that folder. The 7 new tests pass. I couldn't run bun x tsc --noEmit here: it printed only its help text and no type errors.

Notes

opened this

This adds the Mill Race rules in mill-race/race.js with tests in mill-race/race.test.mjs, and nothing outside that folder. The 7 new tests pass. I couldn't run bun x tsc --noEmit here: it printed only its help text and no type errors. docs/VISION.md, scripts/gate.ts and scripts/fast.ts don't exist in this clone, so I skipped them.

What changed

  • Grid: start(seed, level) builds a level + 3 square grid of straight, bend, tee and blank tiles, with the sluice on the west edge and the wheel on the east edge. The same seed and level always give the same grid. Levels run 1 to 5.
  • Solvability: each level is laid from a connected west-to-east path, which is then turned out of true by seeded quarter turns. A level never starts already cleared. state.scramble lists each path tile's turns, and undoing them always clears the level.
  • Turning: turn(state, x, y) rotates a tile a quarter turn clockwise and counts one move. It refuses a blank tile, off-grid or non-integer coordinates, and any turn after the game is over, returning the same state and a reason.
  • Flow: flow(state) returns the cells the water reaches from the sluice. When it reaches the wheel, the next, larger level starts. Moves over par carry forward, and clearing level 5 ends the game.
  • Par and result: par for a level is the fewest turns that put its laid path right. The win line is 6 moves over par in total or fewer, with "The wheel turns: …". Anything more gives "The race ran dry: …".

What I chose not to do

  • There is no page, no catalogue entry, and no change to shell.js, index.html, town.js or rounds.mjs, as the issue asked.
  • Par comes from the laid path only. A shortcut through the non-path tiles could beat par, and that just counts as zero over.

Try it: bun test mill-race. In a console, MillRace is the browser global and require('./mill-race/race.js') works under Bun.

🤖 Generated with Claude Code

Closes #174

2 earlier comments
commented

This adds the Mill Race rules in mill-race/race.js with tests in mill-race/race.test.mjs, and nothing outside that folder. The 7 new tests pass. I couldn't run bun x tsc --noEmit here: it printed only its help text and no type errors. docs/VISION.md, scripts/gate.ts and scripts/fast.ts don't exist in this clone, so I skipped them.

What changed

  • Grid: start(seed, level) builds a level + 3 square grid of straight, bend, tee and blank tiles, with the sluice on the west edge and the wheel on the east edge. The same seed and level always give the same grid. Levels run 1 to 5.
  • Solvability: each level is laid from a connected west-to-east path, which is then turned out of true by seeded quarter turns. A level never starts already cleared. state.scramble lists each path tile's turns, and undoing them always clears the level.
  • Turning: turn(state, x, y) rotates a tile a quarter turn clockwise and counts one move. It refuses a blank tile, off-grid or non-integer coordinates, and any turn after the game is over, returning the same state and a reason.
  • Flow: flow(state) returns the cells the water reaches from the sluice. When it reaches the wheel, the next, larger level starts. Moves over par carry forward, and clearing level 5 ends the game.
  • Par and result: par for a level is the fewest turns that put its laid path right. The win line is 6 moves over par in total or fewer, with "The wheel turns: …". Anything more gives "The race ran dry: …".

What I chose not to do

  • There is no page, no catalogue entry, and no change to shell.js, index.html, town.js or rounds.mjs, as the issue asked.
  • Par comes from the laid path only. A shortcut through the non-path tiles could beat par, and that just counts as zero over.

Try it: bun test mill-race. In a console, MillRace is the browser global and require('./mill-race/race.js') works under Bun.

🤖 Generated with Claude Code

commented

All three fixes are pushed, and the 7 tests in mill-race/race.test.mjs pass. I didn't run bun x tsc --noEmit this round. Last round it printed only its help text.

  1. Credit: the header of race.js now credits Pipe Mania (The Assembly Line, 1989). It names Lucasfilm Games as the US publisher (as Pipe Dream) and Empire Software as the European publisher. It also says the rules and code are this repository's own.
  2. Dead ternary: lay() is now const to = Math.floor(rnd(n++) * size);.
  3. Wasted-move test: the test turns one tile four times, which changes nothing but costs four moves. It checks the tiles are unchanged and moves is 4, then solves the level. It asserts the level clears and over is exactly 4.

Credit wording: I didn't name "Oasis" as you suggested, because I couldn't confirm it. As I remember it, The Assembly Line made the game and Empire published it in Europe. Say if you can point to a source for Oasis and I'll add it. I also didn't name individual designers, since I couldn't confirm who they were.

🤖 Generated with Claude Code

commented

I found nothing in this pull to fix, so I pushed an empty commit to rerun the preview check.

The pull adds only mill-race/race.js and mill-race/race.test.mjs. The failed deploy hit its 600-second limit while running empire/page.test.mjs, which I didn't touch.

Locally, empire/page.test.mjs passes all 14 tests in 9.8s, and the mill-race suite passes all 7 in 0.4s. I did not run the whole suite or the other pre-push checks here, because nothing in the diff reaches anything outside mill-race/. If the rerun times out again in the empire tests, the slowness is in that suite or on the deploy machine, not in the mill-race rules.

Pull description: Mill Race rules. mill-race/race.js turns channel tiles to carry the stream to the water wheel. mill-race/race.test.mjs covers it, including over-par accounting with real wasted turns. I didn't build the playable page; that is a separate step. To try it, run bun test mill-race.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs