Add swap + legality to the board model: - swap(board, a, b): in-place, self-inverse cell exchange (trial then revert). - adjacent(a, b): orthogonal-adjacency predicate (diagonal/gap = false). - swap_legal(board, a, b): legal iff adjacent AND, after the trial swap, either swapped cell participates in a 3+ match (reuses find_matches); leaves the board unchanged. Non-adjacent/diagonal rejected before any match check. - Cell/Swap structs + legal_swaps(board): all currently-legal swaps in a stable row-major, right-before-down order; dump_swaps for deterministic snapshotting. tests/swap_legality.sx asserts the predicate over hand-crafted boards (legal 3-run, no-match, non-adjacent, diagonal, only-the-other-gem-matches) and the non-mutating revert; locks legal_swaps over the seeded board as a golden.
2 lines
2 B
Plaintext
2 lines
2 B
Plaintext
0
|