Hey community. I'm trying to fill up gaps on my attempt to code an unbeatable AI for my TicTacToe challenge.
Here's the codepen, don't mind the rough css: tictactoe challenge.
What I want to point out can be appreciated here: on this doodle. This shows grosso modo how the AI predicts next play and try to win the game or sabotage player's victory for a draw if winning is not possible. Some observations:
1) Recursion stops right after finding an end stage condition(draw/win/lost), not after filling up the board and then evaluate it.
2) It doesn't discriminate boards with same minmax value. It just returns the first board with the lowest minmax found.
Thus I think the issue should be lingering within these two.
<div> <img> </div>
multiple boards. There is no need to save any in between, this only takes up memory and makes things very hard to track
deepwhich i just increased in each recursive call so i always know on what level i am.
return valueof the recursion call. So there is no need to store it, because you just pass it