Add MutablePlacement and rewire SearchBoard onto it #120
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project#120
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
#117
What to build
Add
MutablePlacement— the mutablePieceReaderimplementation for the search hot path — and rewireSearchBoardonto it. TodaySearchBoardholds two views of one record (#sets: PieceSetsplus#board: Boardaliasing it) and applies edits via a private#applyEdits. This slice replaces both fields with a singleMutablePlacementthat owns the soleapplyEditsmutation primitive and maintains occupancy incrementally.The two structurally-identical edit shapes —
ApplyEdit(search-board.ts) andZobristEdit(zobrist.ts) — collapse into onePieceEdittype owned by the placement module.snapshotBoardbecomesBoard.fromReader(mutablePlacement), copying out across the immutable boundary.This is the heaviest slice; perft node counts being byte-identical is the correctness guard.
Acceptance criteria
MutablePlacement implements PieceReader, withapplyEdits(edits: readonly PieceEdit[])as the only mutation methodMutablePlacementmaintains occupancy incrementally (no O(12) reduce per call);SquareSetinstances stay immutable — only slot references and occupancy fields mutateSearchBoardholds oneMutablePlacement, replacing the#sets+#boardpair;makeMove/unmakeMovego throughapplyEditsSearchBoard.snapshotBoard()returnsBoard.fromReader(...)ApplyEditandZobristEditunified into a singlePieceEdit;zobrist.updateZobristKeyconsumes itapplyEditsround-trip (apply then inverse) restores exact prior state; occupancy equals the recomputed union after any edit sequence — covered by testspnpm lint,pnpm typecheck,pnpm test,pnpm buildall green; perft node counts byte-identical to beforeBlocked by
Implemented by Sandcastle on branch
sandcastle/sequential-reviewer/1779454410208— awaiting review.SearchBoardnow owns a singleMutablePlacement(replacing the#sets+#boardpair), withapplyEditsas the sole mutation primitive and incrementally-maintained occupancy.ApplyEdit/ZobristEditcollapsed into a singlePieceEditowned by the placement module;snapshotBoard()copies out viaBoard.fromReader. All four gates green; perft node counts unchanged.Promoted to branch
refactor/introduce-the-piecereader-read-port-118(PR #122), not yet merged to main. A dependent slice shouldgit fetch origin refactor/introduce-the-piecereader-read-port-118and branch off it.mentioned in issue #121
mentioned in commit
f0389d7360mentioned in commit
81a871ba17mentioned in commit
6bd42d7f09mentioned in commit
a10f52db80