No video
Coding an Unbeatable Tic Tac Toe AI Using Python and the Minimax Algorithm
In this tutorial I will show how to code an unbeatable AI to play against in Tic Tac Toe using object oriented programming, the minimax algorithm (game theory), Python and its Pygame module.
LINKS:
😺 GitHub Repo: github.com/AlejoG10/python-ti...
- Classic Tic tac toe Tutorial: • Tic Tac Toe Using Pyth...
- Windows Setup: • How to Install Python ...
- Mac Setup: • How to Install Python ...
FOLLOW FOR MORE:
💥 GITHUB: github.com/AlejoG10
💥 INSTAGRAM: / coding_sp0t
⏱ TIMESTAMPS ⏱
00:00 Introduction
03:49 Screen & Background
17:43 Console Board
31:06 Drawing Figures
43:46 Board Functions
59:38 Minimax Explanation
1:13:21 Random AI
1:22:49 Minimax Function
1:40:17 Keyboard Events
1:49:40 Fix Bug
1:54:10 Show Wins
2:04:07 End
Пікірлер: 76
One of the BEST project tutorials EVER. Thank you. This was awesome.
Thank you so much for this tutorial ! Very useful tbh ! Got to learn a lot. Please keep making these!
Your voice is the only voice that didn't make me go insane after hours of listening. Subscribed!
@codingspot
Жыл бұрын
Happy to hear that my friend!
Wow brother, this is the most clear tutorial that I could find. Thank you so much! Keeing up!
You're so good at explaining things man! Mark my words: this man will blow up one day
Thank you very much! Great tutorial video, helped me a lot! Many thanks again!
Best tutorial out there. Thanks
Thanks you very much for making this!! I have been waiting long for a good tic tac toe ai tutorial and this is perfekt!!
@codingspot
2 жыл бұрын
Hope you like it!
@masternobody1896
2 жыл бұрын
@@codingspot thanks
@GrowWithArup23
3 ай бұрын
@@codingspot How to make "ai vs ai" mode? kindly help!!
Well thanks brother , this is amazing .
seriously best tutorial ever. Thank u for your amazing work
Welcome back man! Hope you good!
@codingspot
2 жыл бұрын
Hey bro!! Doing great thanks!
Thank you!
thanks a lot for this video
I understand everything except the AI minmax method coding and unfortunately that was the reason that i watch your video. Never the less i think you 've done a pretty good job...
This is so good!!! Thank you!!
@codingspot
2 жыл бұрын
Happy to hear that my bro!
@mohithrajds8852
9 ай бұрын
brother where i can get code@@codingspot
I'm at: Time: @1:38:30 I copied the code as you did it and I am getting the same result as you EXCEPT on the print out, for some reason it is showing 0 when the eval should be -1 because it knows it's going to win, any idea what I did wrong?
Hey thanks for preparing this video... I have coded it in Java but found in some corner cases it doesn't work.. can you help me to identify the issue
Does anyone know the Color Theme that he uses? I liked the colors of the variables in the code @Coding Spot
I have a question , I used ur code to my AI course and I need to make sure of something, how can I communicate with you please help me
Hello ..I am getting an error offset is not defined.. Would you please tell me how do I fix it
I follow the tutorial i get a good result but it can be beatable somehow if I start playing in some pos the ai doesn't mark the smart position I think its kinda see the fast move not the best move hope u understand me thanks
What's the alternative way to write the code at 49:22?
Hlo can u please tell me how to solve some error. Width is not defined
can u make the same project with android syudio?
How to make "ai vs ai" mode? kindly help!!
i have an error in the move variable
For some reason when the AI starts and my first move is in the centre, I will always win. Why's that?
Hey would it be possible to implement this Ai into the tic tac toe game made with your previous tutorial?
@codingspot
2 жыл бұрын
Sure, I did it this way because I think is much easier, but you can do it without classes and objects too
@ThePackLeaderWolfe
2 жыл бұрын
@@codingspot Would it be possible for you to write out small sample code without objects and classes so i can get an idea of how i'd implement it into the old noughts and crosses python tutorial
where can i get the codes
can u add a score board with it
can 4x4?
Tic Tac Toe Game in JavaScript | JS Project Day 1 | JavaScript Full Course : kzread.info/dash/bejne/foVtm8qHgZDSqrA.html
Can I ask basic question, why non maximising is ai player ? Can maximising be ai player?
are this video and that tic tac toe video which have 5 parts same? which video should i watch first? and can i use sublime text ?
@codingspot
2 жыл бұрын
Hey! They are not the same, the one with 5 parts is the clasic player vs player tic tac toe game (easier). In this one you will add a computer to play against (harder).
@codingspot
2 жыл бұрын
And sure you can use SublimeText or any other text editor, just make sure to have pygame installed.
@ajsingh3100
2 жыл бұрын
@@codingspot thank you so much
I tried to code based on your idea and found that if I let the AI goes first, specifically at grid (1, 1), there might be a chance that the AI doesn't win immediately. I wonder if you could try that on yourself and see if this is only my problem or because of how the mechanism of minimax work :D anyways, thanks for your help, I was able to finish my school's lab.
@brand_blitz
7 ай бұрын
same issue
May i please ask that can i learn this if im like between intermediate and beginner ?
@codingspot
2 жыл бұрын
Sure you can, I tried to make it beginner friendly. But you can also start with the normal tic tac toe tutorial which is easier.
@xxtbge0457
2 жыл бұрын
@@codingspot oh ok thanks:>>
Hey, can you help me out ? A bit urgent, I'm trying to implement a similar (4*4 tic tac toe) but getting an error here!
@codingspot
2 жыл бұрын
Can you paste the error to see it
@rajnigupta8581
2 жыл бұрын
@@codingspot It goes into infinite loop and throws an error on board not responding...Would you mind telling me a mode where I can share pic?
@codingspot
2 жыл бұрын
You can send me it through Instagram
@sanghoaxuan2028
10 ай бұрын
Have you fixed this error yet ?
half part was same in you older pvp series parts
please i need your help!!
hello any one can send code of tic tac game
hi why no massage for who when
it doesn't work and it says error because of "numpy" what should I do?
@codingspot
2 жыл бұрын
Make sure you have numpy installed
@renielmanalo7282
2 жыл бұрын
@@codingspot nice! but one last question, how do you change the O and X to S and O? because we have a project and we need to change it to a SOS game but works like a TICTACTOE game. hope you can help
@codingspot
2 жыл бұрын
You will need to change the method that draws the figures. Instead of drawing an 'X', you should draw an 'S' (try drawing it like the number 5 with 5 lines), the 'O' will be the same in your case.
I don't know why in the 26 minute the compilation shows up but once i click on the screen it disappears
@codingspot
2 жыл бұрын
Is there any error showing up?
@oumaimadguigou9882
2 жыл бұрын
It's oky I juste make an error Thank you so much for your efforts
Please add the translation
Shouldn't O be maximizing? Because it moves first????, Is it because we return -1 for the first player, Alright, Got it , great tutorial!
well i beat it
Please Active Subtitle I'm From Iran
can you copy the code in here?have a great day!!!
@codingspot
2 жыл бұрын
Code is too long to paste it here, but you can find it on my github (link on description)
@mohithrajds8852
9 ай бұрын
brother it is not opening @@codingspot
there is a problem with when the ai is starting... i mean the best possible move is to place it in the center cause its not necessarily a draw then cause the human player can still mess up but i mean the same counts for what its doing right now of course but the chances of winning are much better when starting in the center at least in a human sense.
It's not AI tho