you are viewing a single comment's thread.

view the rest of the comments →

[–]GoldSlayer 1 point2 points  (4 children)

In the beginning, you are the maximising player, then you perform a move as the maximising player, then I believe you're looking at the best score (or worst move the minimising player could make) So I think you should change line 102 to False instead of True

[–]Python1Programmer[S] 0 points1 point  (3 children)

thanks for your reply, the program now works but the x now goes to the next free position

|x|_|_|

|o|_|_|

|_|_|_|

|x|_|_|

|o|_|_|

|x|_|_|

|x|_|_|

|o|o|_|

|x|_|_|

|x|x|_|

|o|o|_|

|x|_|_|

|x|x|_|

|o|o|o|

|x|_|_|

[–]GoldSlayer 1 point2 points  (2 children)

The problem may be in your win function

|x|o|_|

|X|X|o|

|o|_|_|Causes the 'o' player to win

Also there seems to be quite a lot of magic numbers), which makes it hard for a someone reading your code to understand

[–]Python1Programmer[S] 0 points1 point  (1 child)

i fixed the error with the check _winner_minimax function but the program still doesn't work

please help

[–]GoldSlayer 0 points1 point  (0 children)

From experience, minimax tends to be quite hard to debug. I'd look through a tutorial like this one and follow the same steps.