On the Tic Tac Toe challenge I took a very long route and hard coded everything. It’s a big mess and I think I have made it impossible for myself to make AI now. Could somebody please check it out and help me to figure out how I can make AI out of this? Thank you!
You made it complicated but not yet un-exploitable !
What it does for now, is to handle the user inputs
, print it
on the grid, check his win
.
You need to add a new sequence for the AI
part, after the check
, that handle to choose a square, apply the X
or O
accordingly and check
again for the win.
The first time you check for a win, it’s always after the user clicked somewhere so it only validates his victory ; the second time you’ll call the win, you’ll be checking for the AI
victory