code wiki / (root) / nx_folkgame_sow_lib.nx

nx_folkgame_sow_lib.nx

buildroot/runtime/nx_folkgame_sow_lib.nx

11717 B286 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind librarytopic folkgame
docsdependenciesstructsconstsfunctions

about

nx_folkgame_sow_lib.nx -- THE SOW (MANCALA) FAMILY: pits, seeds, laps and capture. Seven registry rows run on this one engine: Oware, Kalah, Congkak, Omweso, Tsoro, Pallanguzhi and Bao. It reuses nx_folkgame_lib's image, save/restore and terminal plumbing entirely -- cells are pits and state[c] is a SEED COUNT rather than an occupancy code. There is no second parser and no second position representation. THE INVARIANT THIS FAMILY IS PROVEN BY: sowing MOVES seeds, it never creates or destroys them. Total seeds is conserved across every legal move from every reachable position, and that is arithmetic rather than an opinion -- a sowing loop that is off by one anywhere breaks it, and no implementation can satisfy it by accident. It is the sow family's answer to what the published game-tree constant is for the align family. HONEST DIFFERENCE, STATED NOT HIDDEN: unlike Tic-Tac-Toe's 255168 there is no cheap PUBLISHED constant for these boards -- Oware was solved by Romein and Bal over 889 billion positions and Kalah by Irving, Donkers and Uiterwijk, neither reproducible inside a gate. The external anchor available to us is OpenSpiel's Oware, which its own table grades THOROUGHLY-TESTED, and wiring that cross-check is the named rung. Until it lands, this family is proven by an exhaustive invariant and NOT by an external count, and the gate says so in those words. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 1 importers

nx_folkgame_lib.nx nx_folkgame_sow_lib.nx nx_folkgame_sow_gate.nx

imports: nx_folkgame_lib.nx

imported by: nx_folkgame_sow_gate.nx

structs

none

consts

27const FGS_S_SCORE1: i64 = 8
28const FGS_S_SCORE2: i64 = 9

functions

30func fgs_perside(base: i64) -> i64 { let hd: *i64 = fg_hdr(base); return hd[FG_H_PERSIDE] }
31func fgs_has_store(base: i64) -> i64 { let hd: *i64 = fg_hdr(base); return hd[FG_H_STORE] }
32func fgs_store_cell(base: i64, side: i64) -> i64
38func fgs_first(base: i64, side: i64) -> i64
42func fgs_last(base: i64, side: i64) -> i64
47func fgs_owns(base: i64, side: i64, c: i64) -> i64
called by 1: fgs_apply_raw calls 2: fgs_firstfgs_last
53func fgs_score(base: i64, side: i64) -> i64
59func fgs_add_score(base: i64, side: i64, n: i64) -> i64
70func fgs_total(base: i64) -> i64
81func fgs_expected(base: i64) -> i64
called by 3: fgg_walkmainfgs_sow calls 1: fg_hdr
86func fgs_reset(base: i64) -> i64
called by 1: main calls 3: fg_hdrfg_statefg_scal
102func fgs_next(base: i64, side: i64, c: i64) -> i64
121func fgs_sow(base: i64, pit: i64) -> i64
155func fgs_apply_raw(base: i64, pit: i64) -> i64
202func fgs_feeds(base: i64, pit: i64, snap: *i64) -> i64
221func fgs_moves(base: i64, out: *i64, snap: *i64) -> i64
247func fgs_apply(base: i64, pit: i64, snap: *i64) -> i64
264func fgs_terminal(base: i64, snap: *i64, scratch: *i64) -> i64