From a611c842e22b57f510b20b59df9031857edac347 Mon Sep 17 00:00:00 2001 From: Michael Ficocelli Date: Thu, 6 Mar 2025 14:30:12 -0500 Subject: [PATCH] IPVGO: correctly initialize board from save when there are no prior moves (#1995) --- src/Go/SaveLoad.ts | 3 ++- src/Go/boardAnalysis/goAI.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Go/SaveLoad.ts b/src/Go/SaveLoad.ts index be27e6612..1d09e4761 100644 --- a/src/Go/SaveLoad.ts +++ b/src/Go/SaveLoad.ts @@ -111,7 +111,8 @@ function loadCurrentGame(currentGame: unknown): BoardState | string { ? Math.max(0, currentGame.cheatCountForWhite || 0) : 0; if (!isInteger(currentGame.passCount) || currentGame.passCount < 0) return "invalid number for currentGame.passCount"; - const previousBoards = typeof currentGame.previousBoard === "string" ? [currentGame.previousBoard] : []; + const previousBoards = + currentGame.previousBoard && typeof currentGame.previousBoard === "string" ? [currentGame.previousBoard] : []; const boardState = boardStateFromSimpleBoard(board, ai); boardState.previousPlayer = previousPlayer; diff --git a/src/Go/boardAnalysis/goAI.ts b/src/Go/boardAnalysis/goAI.ts index 26a40902f..5fc1174fe 100644 --- a/src/Go/boardAnalysis/goAI.ts +++ b/src/Go/boardAnalysis/goAI.ts @@ -403,7 +403,9 @@ async function getIlluminatiPriorityMove(moves: MoveOptions, rng: number): Promi return moves.corner()?.point ?? null; } - const hasMoves = [moves.eyeMove(), moves.eyeBlock(), moves.growth(), moves.defend, surround].filter((m) => m).length; + const hasMoves = [moves.eyeMove(), moves.eyeBlock(), moves.growth(), moves.defend(), surround].filter( + (m) => m, + ).length; const usePattern = rng > 0.25 || !hasMoves; if ((await moves.pattern()) && usePattern) {