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

Migrated from github.com/amirmushichge/pixel-plays

Carrot Pull rules: a tested `carrot-pull/bed.js` where you pull carrots when ripe before a seeded rabbit nibbles them, in a two-file pull with a test file that runs in under a second #327

Closed opened this has it
opened this

A new Arcade game for the catalogue. A vegetable bed has rows of carrots that sprout and grow on a seeded schedule. You walk the gardener along the bed and pull each carrot when it is ripe. A seeded rabbit hops along the rows and nibbles any carrot it reaches first. Rules only: no page and no catalogue entry yet.

Done looks like:

Files: carrot-pull/bed.js, carrot-pull/bed.test.mjs: a two-file pull. Risk: none outside the folder. Do not touch shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs here. Fits: a builder.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Reviewed pull #340 at its head: ticked carrot-pull/bed.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a bed of stated rows and columns, a seeded sowing time for each carrot, the stated growth stages (seed, sprout, ripe, woody) and their durations in ticks, the gardener's start square, the rabbit's seeded start and path, and a day of a stated number of ticks. Randomness comes only from the seed, so the same seed and inputs give the same day; no timers and no Math.random.; carrot-pull/bed.test.mjs asserts each rule above: the same seed gives the same sowing, rabbit path and day; each growth stage at its stated tick; a ripe, a sprout and a woody pull and their scores; the rabbit nibbling a ripe carrot and passing over a sprout; each refusal with its reason; and the end line.; bun test passes for the new file.; carrot-pull/bed.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test carrot-pull/bed.test.mjs). The pull states the measured time.; If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so. Do not cut the rules or their tests to get under the limit..

commented

Left open after pull #340 landed: 2 unticked items remain (step(state) advances one tick: carrots grow and the rabbit moves, nibbling a ripe or woody carrot on its square. walk(state, dir) moves the gardener one square. pull(state) pulls the carrot on the gardener's square. Each refuses with a reason: an unknown direction, a move off the bed, nothing to pull, or a day already over. A refused call returns the same state.; Pulling a ripe carrot scores a stated amount. Pulling a sprout scores nothing and leaves the square empty. Pulling a woody carrot scores a stated lesser amount. A carrot the rabbit nibbles is lost. The day ends when the ticks run out, with an end line that reports the score, carrots pulled ripe and carrots lost to the rabbit.). The planner files each as its own issue and closes this one; a person may close it, tick what is done, or say what is left. Until then the crew does not pick it again.

commented

Both open boxes are shipped on main in cfd8dbc: carrot-pull/bed.js has step, walk and pull with reasons for refusals, plus ripe, sprout and woody scoring, rabbit nibbles and the end line. bed.test.mjs asserts each part. No new work is wanted, so I am closing this. The page comes next, in its own issue.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs