nx_checkers.nx
buildroot/runtime/nx_checkers.nx
about
nx_checkers.nx -- C1 of the bootstrap-to-generative trajectory.
Standard 8x8 American checkers (English draughts). Pieces on dark
squares only; 12 pieces per side; men move forward diagonally, kings
move both directions. Captures are jumps over an adjacent opponent
to an empty square; multi-captures chain. Win when opponent has no
legal moves (no pieces left or all blocked).
This file (C1a) ships:
- Piece + outcome sealed-enum constants
- State block layout (8x8 board + turn + outcome + force-continue)
- Allocation + standard starting position
- Accessors (cell, turn, outcome, force_continue)
- Coordinate helpers (is_dark_square, in_bounds)
Deferred to C1b+:
- Legal-move generation (simple moves + jumps + mandatory captures)
- Multi-capture chaining
- Kinging on reaching far row
- Win-condition evaluation
- AI tiers (easy random / medium 1-ply / minimax-depth-N)
- HTML UI + WASM delivery + playwright audit
genealogy_id: nx_checkers_v1_2026_05_19
lineage_id: abstract_classic_8x8_game_state_machine
license: operator-as-sole-author (per ยง23.1 open question)
complexity: O(1) accessors; O(8) legal-move gen per piece; AI depth-bounded
dependencies 3 imports · 4 importers
imports: nx_syscalls.nxnx_tier.nxnx_prng.nx
imported by: nx_checkers_render.nxnx_checkers_test.nxnx_chk_bits_up_e2e.nxnx_user_sim_games.nx
structs
| none |
consts
| 40 | const NX_CHK_AI_EASY: i64 = 0 // random legal action |
| 41 | const NX_CHK_AI_MEDIUM: i64 = 1 // (deferred) 1-ply heuristic |
| 42 | const NX_CHK_AI_HARD: i64 = 2 // (deferred) minimax depth-N alpha-beta |
| 46 | const NX_CHK_EMPTY: i64 = 0 |
| 47 | const NX_CHK_RED_MAN: i64 = 1 |
| 48 | const NX_CHK_RED_KING: i64 = 2 |
| 49 | const NX_CHK_BLACK_MAN: i64 = 3 |
| 50 | const NX_CHK_BLACK_KING: i64 = 4 |
| 56 | const NX_CHK_RED: i64 = 1 |
| 57 | const NX_CHK_BLACK: i64 = 2 |
| 61 | const NX_CHK_ONGOING: i64 = 0 |
| 62 | const NX_CHK_WIN_RED: i64 = 1 |
| 63 | const NX_CHK_WIN_BLACK: i64 = 2 |
| 64 | const NX_CHK_DRAW: i64 = 3 |
| 77 | const NX_CHK_OFF_BOARD: i64 = 0 |
| 78 | const NX_CHK_OFF_TURN: i64 = 64 |
| 79 | const NX_CHK_OFF_OUTCOME: i64 = 65 |
| 80 | const NX_CHK_OFF_FORCE_CONTINUE: i64 = 66 |
| 81 | const NX_CHK_OFF_PLIES: i64 = 67 |
| 82 | const NX_CHK_STATE_CELLS: i64 = 68 |
functions
| 89 | func nx_chk_in_bounds(row: i64, col: i64) -> i64 |
| 97 | func nx_chk_is_dark(row: i64, col: i64) -> i64 |
| 105 | func nx_chk_sq(row: i64, col: i64) -> i64 |
| 111 | func nx_chk_new() -> *i64 |
| 153 | func nx_chk_cell(s: *i64, row: i64, col: i64) -> i64 |
| 158 | func nx_chk_cell_by_sq(s: *i64, sq: i64) -> i64 |
| 164 | func nx_chk_turn(s: *i64) -> i64 |
| 168 | func nx_chk_outcome(s: *i64) -> i64 |
| 172 | func nx_chk_force_continue(s: *i64) -> i64 |
| 176 | func nx_chk_plies(s: *i64) -> i64 called by 1: main |
| 182 | func nx_chk_is_red(piece: i64) -> i64 called by 1: nx_chk_side_of |
| 188 | func nx_chk_is_black(piece: i64) -> i64 called by 1: nx_chk_side_of |
| 194 | func nx_chk_is_king(piece: i64) -> i64 |
| 201 | func nx_chk_side_of(piece: i64) -> i64 |
| 208 | func nx_chk_other(side: i64) -> i64 |
| 214 | func nx_chk_count_side(s: *i64, side: i64) -> i64 |
| 249 | func nx_chk_legal_jumps(s: *i64, side: i64, out_buf: *i64) -> i64 |
| 361 | func nx_chk_legal_moves(s: *i64, side: i64, out_buf: *i64) -> i64 |
| 458 | func nx_chk_piece_can_jump_from(s: *i64, sq: i64) -> i64 |
| 524 | func nx_chk_jumps_exist(s: *i64, side: i64) -> i64 |
| 538 | func nx_chk_has_any_legal_move(s: *i64, side: i64) -> i64 |
| 563 | func nx_chk_check_outcome(s: *i64) called by 3: nx_chk_apply_simple_movenx_chk_apply_jumpmain calls 2: nx_chk_has_any_legal_movenx_chk_other |
| 597 | func nx_chk_apply_simple_move(s: *i64, from_row: i64, from_col: i64, |
| 687 | func nx_chk_apply_jump(s: *i64, from_row: i64, from_col: i64, |
| 784 | func nx_chk_apply_move(s: *i64, from_row: i64, from_col: i64, |
| 801 | func nx_chk_pick_easy(s: *i64, side: i64, prng_state: *i64, out_move: *i64) -> i64 |
| 829 | func nx_chk_pick(s: *i64, side: i64, difficulty: i64, |