diff --git a/src/shared/gameplay/boardgame.ts b/src/shared/gameplay/boardgame.ts index 9655ca0..fcf2cc7 100644 --- a/src/shared/gameplay/boardgame.ts +++ b/src/shared/gameplay/boardgame.ts @@ -21,8 +21,14 @@ export const getTargetGameState = (state: BoardgameState, rules: GameRules) => { return state; } - const solutions = getAllSolutions(state.rows, state.columns, rules); - const nextMove = createOpponent(solutions).getNextMove(state.board, state.currentPlayer); - const newState = state.withMove(nextMove.row, nextMove.column); - return newState; + try { + const solutions = getAllSolutions(state.rows, state.columns, rules); + const nextMove = createOpponent(solutions).getNextMove(state.board, state.currentPlayer); + const newState = state.withMove(nextMove.row, nextMove.column); + return newState; + } catch (err) { + // Fall back to non-auto play + console.error(err); + return state; + } };