I'm creating a tic tac toe game, there will be two players: X
and O
. X
will be a human, and O
is an AI which will always choose the best move to play. My board is an 11x11 board and the winning condition is 5 in a row.
How do I know if a board is at end state (where one player has won)? For the 3x3 board, you can do it easily with just a few steps. But for the larger board (11x11) and the winning condition is smaller than the dimension, it's way more complex. The best solution I have found is to check for each n x n (n is the winning condition) square for a winner. But that seems slow.
So here is my question: if you know the last move of a player, can you use that position to check if that player wins without checking every n x n square in the board?