|
|
@ -21,8 +21,14 @@ export const getTargetGameState = (state: BoardgameState, rules: GameRules) => { |
|
|
|
return state; |
|
|
|
return state; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
const solutions = getAllSolutions(state.rows, state.columns, rules); |
|
|
|
const solutions = getAllSolutions(state.rows, state.columns, rules); |
|
|
|
const nextMove = createOpponent(solutions).getNextMove(state.board, state.currentPlayer); |
|
|
|
const nextMove = createOpponent(solutions).getNextMove(state.board, state.currentPlayer); |
|
|
|
const newState = state.withMove(nextMove.row, nextMove.column); |
|
|
|
const newState = state.withMove(nextMove.row, nextMove.column); |
|
|
|
return newState; |
|
|
|
return newState; |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
|
|
// Fall back to non-auto play
|
|
|
|
|
|
|
|
console.error(err); |
|
|
|
|
|
|
|
return state; |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|