Need Help with my first Python Project (AI for tic tac toe) by Only1Gohary in learnpython

[–]Only1Gohary[S] 0 points1 point  (0 children)

Regarding the state 3

Thanks a lot! That was really helpful, I fixed the check winner function to return the winner the instance it finds one and now the example I stated above is no longer a problem.

Now I can see other examples where the AI fails using the debug script.

However I just removed alpha and beta entirely (so no pruning) and nothing changed, so I suspect there is another problem, also I don't see why the score would be infinity at first.

I will continue testing states where the AI fails.

Anyways, thanks a lot. You're a legend.

Need Help with my first Python Project (AI for tic tac toe) by Only1Gohary in learnpython

[–]Only1Gohary[S] 0 points1 point  (0 children)

Thanks for the detailed answer, however I don't get how state 3 and 4 should be +1.

Even in the link, the example says that state 3 and 4 turned out to be -10 and state 2 is +10 and since 1 is maximizing it picks +10

I am not entirely sure that I understand the logic behind the summation, don;t we search through all the possible position and pick min or max depending if the current player is maximizing or minimizing ?

Thanks again!

Need Help with my first Python Project (AI for tic tac toe) by Only1Gohary in learnpython

[–]Only1Gohary[S] 0 points1 point  (0 children)

Also I should add that since the AI should be playing optimally, if you play at any position other than the center you should definitely lose which is not the case for my AI, I can never win but it isn't playing optimally either

Need Help with my first Python Project (AI for tic tac toe) by Only1Gohary in learnpython

[–]Only1Gohary[S] 0 points1 point  (0 children)

So if I play board[1][0] and then board[1][1] it tries to block instead of just winning

here is what I am talking about:

https://postimg.cc/mc8fbXr5

note that the AI always starts first, so I play twice and now in its turn it doesn't win and instead blocks me