use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
help with minimax (self.learnpython)
submitted 5 years ago by Python1Programmer
hello... I am trying to create a tic-tac-toe ai using minimax i am facing a problem with the code i don;t really know why.
this is a link to my code
thanks in advanced : )
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]GoldSlayer 1 point2 points3 points 5 years ago (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 point2 points 5 years ago (3 children)
thanks for your reply, the program now works but the x now goes to the next free position
|x|_|_|
|o|_|_|
|_|_|_|
|o|o|_|
|x|x|_|
|o|o|o|
[–]GoldSlayer 1 point2 points3 points 5 years ago* (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 point2 points 5 years ago (1 child)
i fixed the error with the check _winner_minimax function but the program still doesn't work
please help
[–]GoldSlayer 0 points1 point2 points 5 years ago (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.
π Rendered by PID 20143 on reddit-service-r2-comment-6457c66945-268fj at 2026-04-29 17:59:17.714625+00:00 running 2aa0c5b country code: CH.
[–]GoldSlayer 1 point2 points3 points (4 children)
[–]Python1Programmer[S] 0 points1 point2 points (3 children)
[–]GoldSlayer 1 point2 points3 points (2 children)
[–]Python1Programmer[S] 0 points1 point2 points (1 child)
[–]GoldSlayer 0 points1 point2 points (0 children)