IPVGO: Do not update captures on passed analysis boards (#2415)

This commit is contained in:
Michael Ficocelli
2025-12-21 16:44:24 -05:00
committed by GitHub
parent 49e231fd41
commit 4218b01dfb
8 changed files with 127 additions and 20 deletions
+1 -2
View File
@@ -90,8 +90,7 @@ export function getNewBoardStateFromSimpleBoard(
newState.previousPlayer = GoColor.black;
}
}
updateCaptures(newState.board, newState.previousPlayer ?? GoColor.white);
updateChains(newState.board);
return newState;
}
+10 -7
View File
@@ -242,9 +242,11 @@ export function getChains(_board?: Board) {
export function getLiberties(_board?: Board) {
const board = _board || Go.currentGame.board;
return board.map((column) =>
column.reduce((libertyArray: number[], point) => {
libertyArray.push(point?.liberties?.length || -1);
return libertyArray;
column.map((point) => {
if (!point?.liberties || point.color === GoColor.empty) {
return -1;
}
return point.liberties.length;
}, []),
);
}
@@ -278,12 +280,13 @@ export function getControlledEmptyNodes(_board?: Board) {
* Resets the active game to be a new board with "No AI" as the opponent. Applies the specified board state and komi to the new game.
* Used for testing scenarios.
*/
export function setTestingBoardState(ctx: NetscriptContext, board: Board, komi?: number) {
resetBoardState(ctx, GoOpponent.none, board.length);
Go.currentGame.board = board;
export function setTestingBoardState(ctx: NetscriptContext, state: BoardState, komi?: number) {
resetBoardState(ctx, GoOpponent.none, state.board.length);
Go.currentGame = state;
if (komi != undefined) {
Go.currentGame.komiOverride = komi;
}
updateCaptures(Go.currentGame.board, Go.currentGame.previousPlayer ?? GoColor.white, true);
GoEvents.emit();
}
@@ -444,7 +447,7 @@ export function validateBoardState(
return getNewBoardStateFromSimpleBoard(
simpleBoard,
priorSimpleBoard,
undefined,
GoOpponent.none,
playAsWhite ? GoColor.black : GoColor.white,
);
} catch (e) {