Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Fence Posts rules: a tested `fence-posts/field.js` where you and a farmer take turns fencing between posts and claim each pen you close, from plain data, in a two-file pull with a test file that runs in under a second #303
Reviewed pull #317 at its head: ticked fence-posts/field.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated grid of posts (pens are the cells between them), the player to move first, and a seeded count of sheep in each pen within a stated range. Randomness comes only from the seed, so the same seed and inputs give the same game; no timers and no Math.random.; fences(state) lists every unbuilt length of fence. build(state, edge) builds a listed length for the player and refuses an edge that is already built, off the grid or malformed, a move made out of turn, or a game already over, with a reason and the same state. Closing one or two pens with a single length claims each of them for the builder, who then moves again; otherwise the turn passes.; reply(state) plays the farmer's turn until it passes back, by a stated rule: close any pen it can; otherwise avoid giving a third side to a pen when a safe length exists; otherwise give away the fewest pens. Ties are broken by the seed. When every length is built, the side with more sheep wins, and a tie in sheep goes to more pens. The game ends with a win or loss line that reports both sides' sheep and pens.; fence-posts/field.test.mjs asserts each rule above: the same seed giving the same field and the same replies, each refusal and its reason, a single and a double close, the extra move after a close, the turn passing, each step of the farmer's rule including the seeded tie-break, a whole game ending with every length built, and the win, loss and tie-break lines.; bun test passes for the new file.; fence-posts/field.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 fence-posts/field.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..
A new Strategy game for the catalogue. A meadow is staked with a grid of posts. You and a rival farmer take turns running one length of fence between two neighbouring posts, and whoever closes the fourth side of a pen claims it and its sheep, and fences again. Rules only: no page and no catalogue entry yet.
Done looks like:
fence-posts/field.jsholds the rules as plain data in, plain data out, with no DOM.start(seed)gives a stated grid of posts (pens are the cells between them), the player to move first, and a seeded count of sheep in each pen within a stated range. Randomness comes only from the seed, so the same seed and inputs give the same game; no timers and no Math.random.fences(state)lists every unbuilt length of fence.build(state, edge)builds a listed length for the player and refuses an edge that is already built, off the grid or malformed, a move made out of turn, or a game already over, with a reason and the same state. Closing one or two pens with a single length claims each of them for the builder, who then moves again; otherwise the turn passes.reply(state)plays the farmer's turn until it passes back, by a stated rule: close any pen it can; otherwise avoid giving a third side to a pen when a safe length exists; otherwise give away the fewest pens. Ties are broken by the seed. When every length is built, the side with more sheep wins, and a tie in sheep goes to more pens. The game ends with a win or loss line that reports both sides' sheep and pens.fence-posts/field.test.mjsasserts each rule above: the same seed giving the same field and the same replies, each refusal and its reason, a single and a double close, the extra move after a close, the turn passing, each step of the farmer's rule including the seeded tie-break, a whole game ending with every length built, and the win, loss and tie-break lines.bun testpasses for the new file.fence-posts/field.test.mjsloads 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 fence-posts/field.test.mjs). The pull states the measured time.Files:
fence-posts/field.js,fence-posts/field.test.mjs: a two-file pull. Risk: none outside the folder. Do not touchshell.js,index.html,town.js,rounds.mjs,forge.json,scripts/,playtest.test.mjsorserve.test.mjshere. Fits: a builder.