Tic tac toe

Hello I am kind of stuck with my minimax algorithm in this tictactoe AI.

The program just crashes "Not responding" whenever I debug calling the function on CPU turn move


I would like some assistance but unfortunately I can't post the code here because its around 1300 lines so I'll leave a dropbox link for the .cpp file and I hope someone can tell me what's causing the crash.

PS: Many things are still not implemented in the general code, I only need help with the AI algorithm [minimax]


https://www.dropbox.com/s/b13kwvvdc39s7ox/main.cpp?dl=0
Last edited on
In your function minimax I got a stack overflow at line so this might be a problem with a endless recursion
 
bestMove = min(bestMove,  minimax(depth + 1, !isMaximized));

Does this function has to be recurcive ?
Yes supposedly I tried to implement the function using this algorithm explanation mainly:


http://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-3-tic-tac-toe-ai-finding-optimal-move/
Thanks for whoever tried to think of it, it was this part that made the conflict:


if (movesleft() == true)

Just changed it to

if (board[i] != 'X' && board[i] != 'O')

and it worked heh!
Topic archived. No new replies allowed.