Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Shunting Yard rules: a tested `shunting-yard/yard.js` that sorts numbered wagons through sidings from plain data #162
Sign in to join this conversation.
A new Puzzle game for the catalogue: a little shunting engine puts a mixed-up train of numbered wagons in order onto the departure track in as few moves as it can, using a few short sidings. Rules only: no page and no catalogue entry yet.
Done looks like:
shunting-yard/yard.jsholds the rules as plain data in, plain data out, with no DOM.start(seed, level)lays out an arrival track, a stated number of sidings each with a stated capacity, and an empty departure track, and shuffles a stated number of wagons onto the arrival track; the same seed and level always give the same yard, and every yard it makes can be solved.move(state, from, to)takes the end wagon of one track to the end of another and refuses a move from an empty track, onto a full siding, or onto the departure track out of number order. Each accepted move counts one.shunting-yard/yard.test.mjsasserts each rule above: the same seed giving the same yard, a solver reaching the departure track for each level, each refused move, the move count, the level advancing, and the win and loss lines.bun testpasses for the new file.Files:
shunting-yard/yard.js,shunting-yard/yard.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.html,town.jsorrounds.mjshere. Fits: a builder.