Checkers
English draughts with compulsory captures, multi-jump chains and crowning.
- Also known as
- English draughts
- Players
- 2 players
- Origin
- Traditional
- Rules file
- 117 lines · BGDL 0.4 draft, runs on 1.0 · no hooks
- Perfect information
- Grid board
- Forced captures
The game
Men move one square diagonally forward; kings move diagonally either way. Capturing is compulsory and a capturing piece keeps jumping while it can. A man that reaches the far row is crowned, and a player with no legal move loses. Black moves first.
Not modelled yet: Draws by agreement or repetition.
How it's built in BGDL
- Every capture path is a list of landing squares, worked out by a recursive function: a piece can't jump the same piece twice, and jumped pieces stay until the move ends.
- A piece's legal moves are its capture paths if its side has any captures, otherwise single steps, which is how the compulsory-capture rule is expressed.
- Crowning ends the move, as the rules require.
Tested: Move generation matches the published move counts from the starting position (perft).
The rules file
Its top-level sections:dsl, game, boards, components, data, zones, consts, functions, setup, flow, actions, end.
checkers.rules.yaml
# Checkers (English draughts), a conformance game (issue #32): forced captures and multi-jump chains. Its move counts
# from the start position are published (perft), so move generation can be checked against them.
# Rules: men move one square diagonally forward and kings in any diagonal direction; a capture jumps an adjacent
# opposing piece to the empty square beyond; capturing is compulsory, and a capturing piece must keep jumping while it
# can, but any capture sequence may be chosen; a man reaching the far row is crowned and its move ends; a player with no
# legal move loses. Black moves first. Draws by agreement or repetition aren't modelled yet.
dsl: "0.4"
game:
id: checkers
name: Checkers
players: { min: 2, max: 2 }
seats:
topology: ring
names: [black, white] # seat 0 = black, who moves first, from ranks 1-3
boards:
board:
kind: grid
size: [8, 8]
labels: { x: "abcdefgh", y: "12345678" }
components:
piece:
props:
owner: seat
king: "bool = false"
data:
startPosition:
of: piece
rows:
- { owner: black, at: [a1, c1, e1, g1, b2, d2, f2, h2, a3, c3, e3, g3] }
- { owner: white, at: [b6, d6, f6, h6, a7, c7, e7, g7, b8, d8, f8, h8] }
zones:
square: { kind: cell, board: board, of: piece, capacity: 1, visibility: public }
captured: { kind: set, of: piece, perSeat: true, visibility: public }
consts:
diagonals: "[(x: 1, y: 1), (x: -1, y: 1), (x: 1, y: -1), (x: -1, y: -1)]"
functions:
forward:
params: { s: seat }
returns: int
expr: "s == seat(black) ? 1 : -1"
kingRow:
params: { s: seat }
returns: int
expr: "s == seat(black) ? 8 : 1"
# The directions a piece may move or jump in: forward only for a man.
directions:
params: { p: piece }
returns: "list<(x: int, y: int)>"
expr: "p.king ? diagonals : diagonals.where(d => d.y == forward(p.owner))"
# Every capture path from a square: each a list of landing squares. A piece can't jump the same piece twice, and
# jumped pieces stay on the board until the move ends; a man that reaches the king row stops there.
jumps:
params: { p: piece, at: square, taken: "list<square>" }
returns: "list<list<square>>"
expr: >
directions(p).selectMany(d =>
let over = offset(at, d.x, d.y);
let land = over == null ? null : offset(over, d.x, d.y);
land == null || pieceAt(over)?.owner != opponent(p.owner) || taken.contains(over) || (pieceAt(land) != null && land != p.at) ? [] :
!p.king && land.rank == kingRow(p.owner) ? [[land]] :
(let more = jumps(p, land, taken.concat([over])); more.isEmpty() ? [[land]] : more.select(r => [land].concat(r))))
steps:
params: { p: piece }
returns: "list<list<square>>"
expr: "directions(p).select(d => offset(p.at, d.x, d.y)).where(sq => sq != null && pieceAt(sq) == null).select(sq => [sq])"
mustCapture:
params: { s: seat }
returns: bool
expr: "pieces(s).any(p => jumps(p, p.at, []).any())"
# A piece's legal moves as paths: captures if the side has any, otherwise single steps.
movesOf:
params: { p: piece }
returns: "list<list<square>>"
expr: "mustCapture(p.owner) ? jumps(p, p.at, []) : steps(p)"
# The squares a path jumps over, in order.
jumped:
params: { from: square, path: "list<square>" }
returns: "list<square>"
expr: >
range(0, path.count()).select(i => (prev: i == 0 ? from : path[i - 1], next: path[i]))
.where(s => abs(s.next.file - s.prev.file) == 2)
.select(s => square((s.prev.file + s.next.file) / 2, (s.prev.rank + s.next.rank) / 2))
setup:
- createFrom: { table: startPosition, into: square, positionColumn: at }
flow:
- phase: play
turns:
order: { from: "seat(black)", direction: clockwise }
budget: 1
actions: [move]
onNoLegalAction:
- endGame: { winner: "opponent(activeSeat)", reason: no legal move }
actions:
move:
choose:
- piece: { from: "pieces(self)", where: "movesOf(piece).any()" }
- path: { from: "movesOf(piece)" }
effect:
- forEach: { in: "jumped(piece.at, path)", as: sq, do: [ { move: { what: "pieceAt(sq)", to: "captured[self]" } } ] }
- move: { what: piece, to: "path.last()" }
- if:
cond: "!piece.king && piece.at.rank == kingRow(self)"
then: [ { set: { target: piece.king, value: true } } ]
end:
scoring: { win: 1, draw: 0.5, loss: 0 }
rating: eloWrite your own game in BGDL
Start free and describe your game's rules, or book a demo and we'll walk through your rulebook with you.