Skip to content

Checkers: a new game, with classic and Spanish rules (#357) - #368

Merged
margani merged 1 commit into
mainfrom
issue/357-checkers
Oct 19, 2026
Merged

margani merged 1 commit into
mainfrom
issue/357-checkers

Conversation

@margani

@margani margani commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Closes #357

The owner said yes in chat (2026-10-19). Thanks to @unmashedpotatoes for the suggestion and for the link to the Spanish draughts rules.

What it is. Draughts on the 32 dark squares of an 8×8 board, against the AI at three levels or two players on one phone. The daily challenge is a classic game from a seeded four-ply opening against the hard AI, like Reversi's.

Two rule sets, chosen with a picker:

  • Classic checkers (English draughts):
    • men step diagonally forward;
    • jumps are compulsory and must run to the end;
    • a jump that crowns a man ends the move;
    • kings step one square, backwards too.
  • Spanish draughts, from the rules the issue linked (ludoteka.com, read for this PR):
    • kings fly along the whole diagonal and capture from a distance, landing on any empty square beyond;
    • a capture must take the most pieces (quantity rule), then the most kings (quality rule).
  • Draws: after 80 plies (classic) or 40 king moves (Spanish) without a capture or a man moving.
  • Not implemented from the Spanish rules: draw by agreement, threefold repetition, and the "three kings against one in 13 moves" rule.

The AI. Negamax with alpha-beta, extending forced captures. Easy looks 1 ply ahead with a lot of noise, medium 3, hard 7. I measured it before writing the test bands, 8–10 games per pairing:

classic Spanish
hard vs easy 8–0 8–0
hard vs medium 8–0 7–0, 1 draw
medium vs easy 7–0, 1 draw 8–0

The slowest hard move took 367 ms on this laptop.

Page

  • Canvas board in the core's .ch-fit / .ch-split layout (Games use only part of larger screens (7-inch phones, tablets, laptops) #359) from the start, and the canvas checks both sides before reusing its backing.
  • Tap a piece, then its landing square. On a multiple jump, tap each landing in turn. Pieces that can move are ringed, and "You must jump" shows when a capture is compulsory.
  • Keyboard: arrows, Space/Enter, Esc to drop a pick (before Esc would leave the game), U/Ctrl+Z to undo.
  • Three awards: ck-win, ck-hard, ck-clean (win without losing a piece).
  • Accent #B82066: ΔE 22 from the nearest game, white text 6.1:1.
  • games.json, README (en and fa), and the five store descriptions (35 games). I trimmed the German and Spanish texts elsewhere, so they stay under Play's 4000 characters: 3987 and 3975.

Proof

  • 37 checks in testCheckers(). Rules: start position, men forward only, compulsory and complete jumps, crowning ends a jump, win by blocking or capture, both draw counts, undo back to the start. Spanish: flying moves and distant captures, the quantity and quality rules, a whole Spanish AI game. Plus AI bands, the daily seed and the page wiring.
  • Mutations, each caught by its own check:
    • captures made optional;
    • jumps that stop after one;
    • a crowning that doesn't end the jump;
    • no quantity rule;
    • no quality rule;
    • kings that never fly.
      The first mutation went uncaught at first, because the test position put the jumping piece first in board order. I moved the free man before it, and that version is in the test.
  • node tools/test.js: همه‌ی 4186 بررسی سبز; MIN_CHECKS is now 4185. tools/browser-check.sh: 36 of 36 pages.
  • Clicks in Playwright:
    • a move against the AI: the AI replied, at 390×844 and 1280×800;
    • a double jump tapped landing by landing: rival men 3 → 3 → 1, the turn passes;
    • a Spanish king flying from d5 to b2.
      No page errors.
  • Visual check: 390×844, 844×390, 600×960 and 1280×800, light Persian and dark English. Nothing clips or scrolls.

Not tested: a real phone. The bot's speed on a slow phone is estimated from this laptop.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VoRrYWfb9CHLaEtJPXc4HH

Phone, Persian

Laptop, the rows beside the board

After a double jump tapped landing by landing

Draughts on the 32 dark squares of an 8x8 board, against the AI at three
levels or two players on one phone, and a daily classic game from a seeded
four-ply opening against the hard AI.

Two rule sets. Classic checkers (English draughts): men step forward, jumps
are compulsory and run to the end, a jump that crowns ends the move, and kings
step one square both ways. Spanish draughts, which the issue linked: kings fly
along the whole diagonal and capture from a distance, and a capture must take
the most pieces, then the most kings. A game is drawn after 80 plies (classic)
or 40 king moves (Spanish) without a capture or a man moving.

The AI is a negamax with alpha-beta that extends forced captures; easy looks 1
ply ahead with a lot of noise, medium 3, hard 7. Measured over 8-10 games per
pairing in both rule sets, hard beat medium and easy every time but one draw,
and medium never lost to easy. The slowest hard move took 367 ms.

Built on the core's screen-filling layout from the start (#359). Accent
#B82066 (nearest game ΔE 22, white text 6.1:1). Store descriptions name it;
German and Spanish were trimmed to stay under Play's 4000 characters.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VoRrYWfb9CHLaEtJPXc4HH
@margani

margani commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Diff review

  • Engine: pure, between the ENGINE markers. moves() lifts the moving piece off its square while searching for jumps, so a king can pass back over its own starting square. Captured pieces stay on the board until the move ends, so none is jumped twice and they block a flying king, as in both rule sets.
  • Spanish quantity rule: it applies across all pieces, not per piece. moves() collects every capture first, then filters.
  • The page's pick flow: candidates are the legal moves whose path starts with the landings tapped so far. A move is played when one of them is fully matched. A path pins down its captures, so the match is unique.
  • Daily: always classic, so every player plays the same rules. The rules picker isn't shown in the daily game.
  • Core: only the three awards are added. whoosh/thud and the layout classes are untouched.
  • Risk: a flying-king position deep in the middlegame makes the hard search wider. The worst move I measured was 367 ms, from simulated games, not every position.

@margani
margani merged commit 7825b0b into main Oct 19, 2026
3 checks passed
@margani
margani deleted the issue/357-checkers branch October 19, 2026 23:05
@margani margani mentioned this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: add classic checkers

1 participant