mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-08 08:37:48 +02:00
IPVGO: Ensure getValidMoves correctly handles playing as white (#2292)
This commit is contained in:
committed by
GitHub
parent
b025a4d0c1
commit
02f2f1be74
@@ -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;
|
||||
|
||||
@@ -426,6 +426,7 @@ export function validateBoardState(
|
||||
error: (s: string) => never,
|
||||
_boardState?: unknown,
|
||||
_priorBoardState?: unknown,
|
||||
playAsWhite = false,
|
||||
): BoardState | undefined {
|
||||
const simpleBoard = getSimpleBoardFromUnknown(error, _boardState);
|
||||
const priorSimpleBoard = getSimpleBoardFromUnknown(error, _priorBoardState);
|
||||
@@ -435,7 +436,12 @@ export function validateBoardState(
|
||||
}
|
||||
|
||||
try {
|
||||
return getNewBoardStateFromSimpleBoard(simpleBoard, priorSimpleBoard);
|
||||
return getNewBoardStateFromSimpleBoard(
|
||||
simpleBoard,
|
||||
priorSimpleBoard,
|
||||
undefined,
|
||||
playAsWhite ? GoColor.black : GoColor.white,
|
||||
);
|
||||
} catch (e) {
|
||||
error(boardValidity.failedToCreateBoard);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user