do not crash on large boards, fall back to manual play

main
Inga 🏳‍🌈 2 days ago
parent d6f2d6e407
commit 3745313fb9
  1. 6
      src/shared/gameplay/boardgame.ts

@ -21,8 +21,14 @@ export const getTargetGameState = (state: BoardgameState, rules: GameRules) => {
return state;
}
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;
}
};

Loading…
Cancel
Save