How can you most effectively find on the playing field the coordinates of all the cells, the filling of which will lead to winning?
Accordingly, the following options are possible: XXX_ , XX_X , X_XX , _XXX horizontally, similar vertically and along both diagonals. ( X is a busy cell, _ is empty)
At first, I looked for a simple pass through the entire array: I put X on an empty cell, then O, and every time I checked some checkWin (), is there a winner.
However, since the field is conditionally "unlimited", this option works too slowly, something more effective is needed.
How can I do that? Is the only option to fence a bunch of ifs and check each of the sixteen possible situations?
(Java language)