Skip to content

Commit a611c84

Browse files
authored
IPVGO: correctly initialize board from save when there are no prior moves (#1995)
1 parent 6530b43 commit a611c84

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Go/SaveLoad.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ function loadCurrentGame(currentGame: unknown): BoardState | string {
111111
? Math.max(0, currentGame.cheatCountForWhite || 0)
112112
: 0;
113113
if (!isInteger(currentGame.passCount) || currentGame.passCount < 0) return "invalid number for currentGame.passCount";
114-
const previousBoards = typeof currentGame.previousBoard === "string" ? [currentGame.previousBoard] : [];
114+
const previousBoards =
115+
currentGame.previousBoard && typeof currentGame.previousBoard === "string" ? [currentGame.previousBoard] : [];
115116

116117
const boardState = boardStateFromSimpleBoard(board, ai);
117118
boardState.previousPlayer = previousPlayer;

src/Go/boardAnalysis/goAI.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ async function getIlluminatiPriorityMove(moves: MoveOptions, rng: number): Promi
403403
return moves.corner()?.point ?? null;
404404
}
405405

406-
const hasMoves = [moves.eyeMove(), moves.eyeBlock(), moves.growth(), moves.defend, surround].filter((m) => m).length;
406+
const hasMoves = [moves.eyeMove(), moves.eyeBlock(), moves.growth(), moves.defend(), surround].filter(
407+
(m) => m,
408+
).length;
407409
const usePattern = rng > 0.25 || !hasMoves;
408410

409411
if ((await moves.pattern()) && usePattern) {

0 commit comments

Comments
 (0)