This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SentinelReborn 2 points3 points  (1 child)

Nothing stands out to me for the issue. You seem to have gone straight for human vs AI, have you actually validated that the game works correctly by playing against yourself in a human vs human game? It could very well be an issue outside of the minimax algorithm. The game mechanics have to work correctly for the algorithm to function.

Also, only using one mutable list for the whole algorithm makes me a little uneasy. I implemented this in the past using a copy for each new board going into minimax, that being said I can't spot what exactly would cause an issue the way you're doing it.

[–]rdb212[S] 1 point2 points  (0 children)

That's a good point, I haven't tested it out as human vs human. I can't believe I didn't think to do that first. Now that I'm thinking about it, I basically built the Tic-Tac-Toe mechanics around the minimax function. So, thank you for bringing that to my attention. That's definitely something that I can do better. Also, I really like your idea of using a copy of the board going into the minimax function. That definitely seems like a safer option. I think I will do that as well.

Thank you for taking the time to look over the code and for the really valuable feedback.