IPVGO: Ensure getValidMoves correctly handles playing as white (#2292)

This commit is contained in:
Michael Ficocelli
2025-08-22 16:12:09 -04:00
committed by GitHub
parent b025a4d0c1
commit 02f2f1be74
3 changed files with 13 additions and 2 deletions
+5
View File
@@ -71,11 +71,16 @@ export function getNewBoardStateFromSimpleBoard(
simpleBoard: SimpleBoard,
priorSimpleBoard?: SimpleBoard,
ai: GoOpponent = GoOpponent.Netburners,
priorColor: GoColor | undefined = undefined,
): BoardState {
const newState = getNewBoardState(simpleBoard.length, ai, false, updatedBoardFromSimpleBoard(simpleBoard));
if (priorSimpleBoard) {
newState.previousBoards.push(priorSimpleBoard.join(""));
}
if (priorColor) {
newState.previousPlayer = priorColor;
} else if (priorSimpleBoard) {
// Identify the previous player based on the difference in pieces
const priorWhitePieces = priorSimpleBoard.join("").match(/O/g)?.length ?? 0;
const priorBlackPieces = priorSimpleBoard.join("").match(/X/g)?.length ?? 0;