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

Migrated from github.com/amirmushichge/pixel-plays

Village Draughts rules: a tested `village-draughts/board.js` with forced captures, multi-jumps, crowning and a seeded computer opponent, from plain data, in a two-file pull with a test file that runs in under a second #276

Closed opened this has it
opened this

A new Strategy game for the catalogue: draughts on a chalked board in the village hall against a stated computer opponent. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [x] village-draughts/board.js holds the rules as plain data in, plain data out, with no DOM. start(seed) sets out an 8x8 board with twelve men a side, the player moving first. Randomness comes only from the seed, so the same seed and inputs give the same game; no timers and no Math.random.
  • [ ] moves(state) lists every legal move for the side to move: diagonal steps forward for men and in any direction for kings, and jumps over an opposing piece to an empty square. When a capture is available only captures are legal, and a multi-jump must continue while it can. move(state, from, path) plays a listed move and refuses anything else, or a move made out of turn. A man reaching the far row is crowned and its move ends there.
  • [x] reply(state) plays the opponent's move: it always takes a capture when one exists, prefers the longest capture, and otherwise chooses among the legal moves by a stated rule using the seed. A side with no pieces or no legal move loses: the game ends with a win line or a loss line reporting the pieces taken.
  • [x] village-draughts/board.test.mjs asserts each rule above: the opening position, steps and jumps, forced capture, a continued multi-jump, crowning and king moves, illegal and out-of-turn moves refused, the opponent's capture preference, the same seed giving the same reply, and both end lines.
  • [x] bun test passes for the new file.
  • [x] village-draughts/board.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 village-draughts/board.test.mjs). The pull states the measured time.
  • [x] 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.

Files: village-draughts/board.js, village-draughts/board.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.

commented

Reviewed pull #289 at its head: ticked village-draughts/board.js holds the rules as plain data in, plain data out, with no DOM. start(seed) sets out an 8x8 board with twelve men a side, the player moving first. Randomness comes only from the seed, so the same seed and inputs give the same game; no timers and no Math.random.; reply(state) plays the opponent's move: it always takes a capture when one exists, prefers the longest capture, and otherwise chooses among the legal moves by a stated rule using the seed. A side with no pieces or no legal move loses: the game ends with a win line or a loss line reporting the pieces taken.; village-draughts/board.test.mjs asserts each rule above: the opening position, steps and jumps, forced capture, a continued multi-jump, crowning and king moves, illegal and out-of-turn moves refused, the opponent's capture preference, the same seed giving the same reply, and both end lines.; bun test passes for the new file.; village-draughts/board.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 village-draughts/board.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 #289 landed: 1 unticked item remains (moves(state) lists every legal move for the side to move: diagonal steps forward for men and in any direction for kings, and jumps over an opposing piece to an empty square. When a capture is available only captures are legal, and a multi-jump must continue while it can. move(state, from, path) plays a listed move and refuses anything else, or a move made out of turn. A man reaching the far row is crowned and its move ends there.). 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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs