P3.3: turn accounting + special-match flagging (pure sx)
Extend the pure-sx board model with the model-level pieces P5 (input) and P7 (turn/goal loop) will call: - Turn accounting on Board: `moves_made` + configurable `move_limit` (DEFAULT_MOVE_LIMIT), with `moves_remaining()` derived from the two so the counters can't drift. `init` resets them. - Special-match flagging: `count_specials` tallies a detection round's maximal runs of length exactly 4 and length 5+, surfaced over a whole settle as Cascade.len4 / len5_plus (+ had_len4 / had_len5_plus). A hook for future special gems — detection only, no gem behavior. - `commit_swap`: the single player-move entry point. Legal swap → apply, resolve (scoring accrues), spend one move; illegal → revert, no move spent. Returns a PlayerMove with the settle's payout + special flags. Adds tests/turn.sx (+ golden) asserting: legal swap decrements the move counter by exactly 1 and accrues score; illegal swap leaves counter, score and board untouched; len4/len5+/len3 rounds set the documented flags. Existing goldens unchanged; ios-sim build compiles.
This commit is contained in:
1
tests/expected/turn.exit
Normal file
1
tests/expected/turn.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
98
tests/expected/turn.stdout
Normal file
98
tests/expected/turn.stdout
Normal file
@@ -0,0 +1,98 @@
|
||||
== turn (accounting + special-match flagging) ==
|
||||
== flag-len3-none ==
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GORRROGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
len4 0 len5_plus 0
|
||||
had_len4 false had_len5_plus false
|
||||
== flag-len4 ==
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GORRRRGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
len4 1 len5_plus 0
|
||||
had_len4 true had_len5_plus false
|
||||
== flag-len5 ==
|
||||
OGOGOGOG
|
||||
GRRRRRGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
len4 0 len5_plus 1
|
||||
had_len4 false had_len5_plus true
|
||||
== flag-len4-and-len5 ==
|
||||
RRRGOGOG
|
||||
GOGOGOGO
|
||||
GOBBBBOG
|
||||
OGOGOGOG
|
||||
GPPPPPGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
len4 1 len5_plus 1
|
||||
had_len4 true had_len5_plus true
|
||||
== commit-legal-len3 ==
|
||||
RROGOGOG
|
||||
GGROGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
before: score 0 moves_made 0 moves_remaining 5
|
||||
after: legal true depth 1 awarded 30 len4 0 len5_plus 0
|
||||
after: score 30 moves_made 1 moves_remaining 4
|
||||
RBRGOGOG
|
||||
GGOOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
== commit-illegal ==
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
before: score 0 moves_made 0 moves_remaining 5
|
||||
after: legal false depth 0 awarded 0 len4 0 len5_plus 0
|
||||
after: score 0 moves_made 0 moves_remaining 5
|
||||
== commit-legal-len4 ==
|
||||
RROROGOG
|
||||
GGROGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
after: legal true depth 1 awarded 60 len4 1 len5_plus 0
|
||||
after: had_len4 true had_len5_plus false
|
||||
after: score 60 moves_made 1 moves_remaining 4
|
||||
RBRROGOG
|
||||
GGOOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
OGOGOGOG
|
||||
GOGOGOGO
|
||||
ok: turn accounting + special-match flagging
|
||||
Reference in New Issue
Block a user