Python Checkers AI Tutorial Part 2 - Implementation & Visualization (Minimax)

  Рет қаралды 51,056

Tech With Tim

Tech With Tim

Күн бұрын

Пікірлер: 102
@thomasbezencon2121
@thomasbezencon2121 4 жыл бұрын
Hey Tim, great video. I think the reason why the AI king kept boing back and forth on the last two rows, is because of a bug in your program. If a king lands on the "king row", the king counter is increased despite no new king having been created (a piece can't be a double king). Given that this king counter is part of the algorithms scoring function, it used this bug to increase its own perceived score.
@aaronwtr1150
@aaronwtr1150 3 жыл бұрын
I noticed this as well, and I made sure that a single piece could not become a king more than once and even then this issue persists... @techwithtim any suggestions?
@aaronwtr1150
@aaronwtr1150 3 жыл бұрын
I have been playing around with it for a bit now and I think I have narrowed down the problem. The minimax seems to consider a single piece at a time. If the piece has valid moves available, it takes them. If there are none, it skips to a next piece. So when a king is made and this piece it selected, the king will just move around, since its moves are valid. I am to find a way to fix this ..
@MD-ji7dh
@MD-ji7dh 2 жыл бұрын
@@aaronwtr1150 were you able to solve the issue? Can't find any solutions and it's pretty anoying for the game to end after on ai got one king
@aaronwtr1150
@aaronwtr1150 2 жыл бұрын
@@MD-ji7dh I have fixed that particular issue, but there still are some bugs even if that bug is fixed. For example, the AI seems to select a single piece at random and ONLY moves that piece until it is captured or makes a king.
@MD-ji7dh
@MD-ji7dh 2 жыл бұрын
@@aaronwtr1150 could you please tell me what's the solution of the repeating king? I have tried for so long to find the issue
@spark1539
@spark1539 3 жыл бұрын
just want to say your a god send, got a project for AI class and the teacher showed us no code on how an ai might look or function so this was and is endlessly helpful.
@bradmclean4988
@bradmclean4988 3 жыл бұрын
Sounds like we have the same class
@justins7796
@justins7796 3 жыл бұрын
same here. Is your teacher's last name Li?
@bruhmomentum0734
@bruhmomentum0734 2 жыл бұрын
same here
@softknk1422
@softknk1422 4 жыл бұрын
The idea of you with storing possible moves in a map data structure helped me a lot .. Thanks for that!
@Fersko
@Fersko 4 жыл бұрын
It's great to have someone who speaks normal English and can explain the programming properly. Thanks a bunch, Tim
@dpskane
@dpskane 4 жыл бұрын
I deviated with my coding during the first 3 parts and I am glad that my board state has a list of the pieces instead of the actual number. Makes the whole process of finding pieces easier.
@DarkusNights
@DarkusNights 2 ай бұрын
Old tutorial but this actually helped me for my classes and adapt your methods to my own code.
@chinonsodimgba7689
@chinonsodimgba7689 3 жыл бұрын
Nice one, I followed this tutorial and have been able to implement the checkers game using dart and flutter, but the pain comes in the AI keeps making unimaginable wrong moves, mostly because they do not know that it is possible to kill more than one enemy in one turn and the position of the pieces do not matter, so for that reason I have been working on making the algorithm take note that a player can kill more than one enemy in one turn and improve on the scoring formula
@amankaushik5833
@amankaushik5833 4 жыл бұрын
Hi tim thanks for making the second part! as always I just love watching your videos related to any topic!
@shaharyarahmed5777
@shaharyarahmed5777 4 жыл бұрын
Recursion is always confusing but after a lot of thinking you can finally get your head around it.
@manfredreinsch8448
@manfredreinsch8448 4 жыл бұрын
Hi Tim, very nice tutorial, well done! I have one question. one remark and two ideas how to extend and even improve your checkers tutorial. In your evaluate method there is a factor of 0.5 for the king piece. Because a king piece is more valuable than a normal piece, shoudn´t that be a factor of 1.5 ? Of course your algorithm will find the best way to win or just to avoid a lose according to your evaluation method , but it can not handle a draw. Consider an obviously drawish situation, e.g. just one red and one white king remaining; the AI will keep on trying to win, while the human player gets bored and sacrifices his king to end the game. In chess there are rules to avoid such a situation. You might add a chesslike rule for offering, accepting or even force a draw, when there was no capture amoung the last x moves. Yes, I am aware that you considerd alpha-beta pruning and rejected it for your current implementation, probably because it seems to be too "technical" for you. Still alpha-beta pruning will accelarate your algorithim by a factor of one ore even two according to depth. Therefore you can easily show, how a slight change in your code will improve an algorithm by a great amount. Because you have implemented a representation to show the effects of the speed of your algorithm depending of the depth in a very nice way, you can present the accelation by alpha-beta pruning visualy. If there are only a few pieces left on the board, you might consider to add an end-game database in your program, which is i.e. offered by the Canadian world best checkers program Chinook for free use. This might be even an idea of merging your checkers- and Mango-DB-Tuts...
@fisheatsyourhead
@fisheatsyourhead 2 жыл бұрын
There is meant to be a 25 move rule where 25 king moves each with no captures forces a draw
@victor20214
@victor20214 4 жыл бұрын
Tim has been an inspiration to code and teach code. I'm from a country where coding isn't as popular and learning it through time has been great. and maybe its time for the bird to fly on its own. hope you will help my endeavour in this quest
@Kobbiemainoocomps
@Kobbiemainoocomps 4 жыл бұрын
i know what you mean. ill support you.
@williamikennanwosu
@williamikennanwosu 2 жыл бұрын
Thanks for the video Tim!
@ashwanirai8324
@ashwanirai8324 4 жыл бұрын
Sir, if I am doing it for AI vs AI it is showing error at the end states that Attributeerror Object has no attribute winner
@anzarrabbani3766
@anzarrabbani3766 5 ай бұрын
36:43 can some1 pls help me, it keeps saying: File ---------------------------------------------------------------------, line 43, in get_all_moves for piece in board.get_all_pieces(color): TypeError: 'int' object is not iterable
@ohgreatone1381
@ohgreatone1381 Жыл бұрын
Tim great video but there are several "bugs' First as you and anther person mentioned the white king goes to the bottom and stays there. Bouncing back and forth between two squares. I believe someone found a solution but it did not get posted. Additionally, randomly the White King will move from the lower square where it is bouncing around and suddenly goes 6 squares diagonally to jump over a red piece. This is not supposed to happen in any version of checkers I have ever played. Could you please post the correction for the White King bouncing around. Thank you
@showmickkar7793
@showmickkar7793 4 жыл бұрын
Hey Tim, just out of curiosity, in a video you said you do all you programming on linux. Why do use windows for making tutorials?
@ahmedthegreat3973
@ahmedthegreat3973 4 жыл бұрын
He Said That Most Good Video Editing Softwares Are On Windows
@КириллПопов-о3с
@КириллПопов-о3с 4 жыл бұрын
Hey Tim! My english is bad, but i try to ask you a question. In your minimax function you do something like that for move in get_all_moves(position, WHITE, game): . So you store all game tree. Can you answer how much memory your program uses with depth different depth. Ty!
@gilbertocisneros85
@gilbertocisneros85 3 жыл бұрын
Can this be implemented with the real checkers rules? The jump in not optional and with different levels? In a website
@ohgreatone1381
@ohgreatone1381 Жыл бұрын
Also, you mentioned that you were going to show us how to make the computer play itself. I tried adding a if game.turn == RED statement like the WHITE statement but it only allows the white pieces to move and the game ends with the white pieces moving down and blocking the red pieces.
@manfredreinsch8448
@manfredreinsch8448 4 жыл бұрын
Hi Tim, I have just found another minor problem: It is possible to blockade your opponent, i.e. he is unable to draw while you can make one or more moves. So "no move" shoud be an option for possible moves!
@fisheatsyourhead
@fisheatsyourhead 2 жыл бұрын
no possible moves means you lose, even if you have pieces on the board. Unlike in chess where no possible moves with pieces is a draw.
@sachinsinghal13
@sachinsinghal13 3 жыл бұрын
Hey Tim, Thanks for everything, the other checkers series and this checkers series were awesome. Though, I have been trying for long time to make the game so we can undomoves as well, but I'm unable to. How can we make the unndomove function?
@sevendoesstuff
@sevendoesstuff Жыл бұрын
if you save all the moves played in a list then when the back arrow (or whatever key you want) is clicked delete the last move done and then quickly play all the moves in the list from the start position then do display.update() that should do it. you could also save all the board positions in a list / matrix and delete the last position in the list and set it to the now last one (the one before it). the ladder takes up much more space as you have to save every single board position from the start while the first just saves 2 points (where it was and where it moved too) but it is a bit more complex.
@AliHaider-bc7cl
@AliHaider-bc7cl 8 ай бұрын
i keep on gettin the game object not iterable error.. any help?!
@matthewzamat3331
@matthewzamat3331 3 жыл бұрын
Hey Tim! Thanks for the video. Is there any way we could create a function to make this checkers AI play against itself? how would we have to modify this code?
@ohgreatone1381
@ohgreatone1381 Жыл бұрын
Also found that the list of valid moves for RED fail when approaching row 0. I can double jump everywhere on the screen except when the last move results in a KING. White can do a double jump but not the RED player
@crjcpj9100
@crjcpj9100 4 жыл бұрын
Hi Tim ,i really like your color theme on vscode how did you do it. what's it called.
@tomiolah5137
@tomiolah5137 Жыл бұрын
I haven't watched this video yet but I plan on doing it soon. Is it possible to build a chess AI based on this?
@wiwikkarlina4447
@wiwikkarlina4447 3 жыл бұрын
thanks for the video! but i still dont get how the static evaluation of position in minmax at depth = 0 get passed up to the parents?
@MD-ji7dh
@MD-ji7dh 2 жыл бұрын
if you debug you can see the return statement isn't exiting the whole function but the current recursion
@AfrasiabAhmadSU__O_OO_OO
@AfrasiabAhmadSU__O_OO_OO 4 жыл бұрын
which color theme and font are you using currently
@SnoozeTheRecluse
@SnoozeTheRecluse Жыл бұрын
I keep getting AttributeError: 'NoneType' object has no attribute 'winner'
@divyanshsingh2614
@divyanshsingh2614 4 жыл бұрын
Hey bro, can u please bring a tutorial on React.Js It would be of great help.
4 жыл бұрын
Hey Tim! Is your website down or you are using a new domain?
@programmatore
@programmatore 3 жыл бұрын
where can i begin this game project....new programmer ho can understand this..............................000000000000 value
@ruchi727
@ruchi727 4 жыл бұрын
you got a new sub!!!
@EmmnauelPeace
@EmmnauelPeace 4 жыл бұрын
Thanks so much for this hard work this can further be use in robots to make them take better decision as humans ...Well we need to explore more on this min-max algorithm with neural networks and others .When these algorithms are used in combination it really makes it very difficult for humans to beat computers in context. Great work..Best regards
@tiagozpt7743
@tiagozpt7743 Жыл бұрын
Friend u know gamezer ? Rules u cant create this rules checkers ?
@ahmedthegreat3973
@ahmedthegreat3973 4 жыл бұрын
Tim I Cant Access Your Website Its Shows Account Suspended. If Its A Bug Please Fix It Please
@richardtarbell946
@richardtarbell946 4 жыл бұрын
I also ran into this issue earlier. I think it is fixed now.
@ahmedthegreat3973
@ahmedthegreat3973 4 жыл бұрын
@@richardtarbell946 Okay Ill Check Thanks For Letting Me Know
@ahmedthegreat3973
@ahmedthegreat3973 4 жыл бұрын
@@richardtarbell946 No I Checked It. Its Not Fixed
@richardtarbell946
@richardtarbell946 4 жыл бұрын
@@ahmedthegreat3973 You're right my b. I was looking at this link tech-with-tim.teachable.com/ rn other one is still down.
@namo2943
@namo2943 4 жыл бұрын
nice i just open youtube and saw this
@alcalina636
@alcalina636 4 жыл бұрын
Hello, how are you? did your site just get down? tks
@kae4881
@kae4881 4 жыл бұрын
nice video!!
@kotvkvante22
@kotvkvante22 4 жыл бұрын
where can I donate to you? paypal doesnt work for me
@avigupta6064
@avigupta6064 4 жыл бұрын
Donate me instead😔
@kotvkvante22
@kotvkvante22 4 жыл бұрын
@@avigupta6064 did not deserve
@techwithomar1875
@techwithomar1875 4 жыл бұрын
I was literally watching the checkers video
@RohanKumar-zd3pc
@RohanKumar-zd3pc 4 жыл бұрын
Hey Tim, When I tried to reach techwithtim. Net then it showed "account suspended"
@shaharyarahmed5777
@shaharyarahmed5777 4 жыл бұрын
Same here
@danielros7798
@danielros7798 4 жыл бұрын
I got this error and don't understand how to fix it File "main.py", line 47, in main() File "main.py", line 27, in main value, new_board = minimax(game.get_board(), 4, WHITE, game) File "C:\Users osda\Documents\Python\Checkers met AI (MiniMax)\minimax\algorithm.py", line 15, in minimax evaluation = minimax(move, depth-1, False, game)[0] File "C:\Users osda\Documents\Python\Checkers met AI (MiniMax)\minimax\algorithm.py", line 8, in minimax if depth == 0 or position.winner() != None: AttributeError: 'list' object has no attribute 'winner'
@johnathanindigo3340
@johnathanindigo3340 4 жыл бұрын
same here, did you manage to fix it?
@danielros7798
@danielros7798 4 жыл бұрын
@@johnathanindigo3340 that's a lot of code, I am going to my PC now and then I'll send it :)
@danielros7798
@danielros7798 4 жыл бұрын
@@johnathanindigo3340 hey, I don't know exactly what I changed so I have the whole code here in a hastebin: hastebin.com/adoqinidom.properties
@johnathanindigo3340
@johnathanindigo3340 4 жыл бұрын
@@danielros7798 hey, so this one works?
@danielros7798
@danielros7798 4 жыл бұрын
@@johnathanindigo3340 Yes
@markgatere5007
@markgatere5007 4 жыл бұрын
Hello Sir, Am a High School student. Kindly advise me and other high school guys who have interest in tech on Computer Science majors in University or college to later have an internship or job in the top high-tech companies like Google.
@TheFonurb
@TheFonurb 3 жыл бұрын
After following this tutorial, i realized i'm probably the worst checkers player in the world... even the 1 depth AI could beat me one time T.T
@artmancs4108
@artmancs4108 2 жыл бұрын
I'm doing a project where we want a robot playing as the AI, for this I need to have the coördinates (row, col) of the final move it took in a list variable. That way I can link these variables to points for the robot. I've been struggling to get this variable out of the program. Should be simple but I can't figure it out haha. Someone help this poor fellah out
@tahalyousfi
@tahalyousfi 4 жыл бұрын
Great work Tim
@renuaggarwal7660
@renuaggarwal7660 4 жыл бұрын
hey bro pls. provide link to the Asset file too . it would be a great help
@shiehuapiaopiao
@shiehuapiaopiao 3 жыл бұрын
It's in the description.
@georgianabhishek3561
@georgianabhishek3561 4 жыл бұрын
perfect just opened pycharm
@duncansutherland5917
@duncansutherland5917 3 жыл бұрын
goat
@gilbertocisneros85
@gilbertocisneros85 2 жыл бұрын
This is not American checkers rules because jumps must be mandatory
@ganapathypt6410
@ganapathypt6410 4 жыл бұрын
🖤
@ahmedthegreat3973
@ahmedthegreat3973 4 жыл бұрын
Please Create A Video About Creating A Slack Bot In Python
@MD-ji7dh
@MD-ji7dh 2 жыл бұрын
pretty sure he has one
@נועםאיפרגן-ל7ע
@נועםאיפרגן-ל7ע 3 жыл бұрын
44:40
@PAuLXPlain
@PAuLXPlain 4 жыл бұрын
Assistant Didn't work Please help
@alenvarghesec.k8001
@alenvarghesec.k8001 4 жыл бұрын
Why not make python hacking series? (Or you can't do dat)
@WForWonder
@WForWonder 2 жыл бұрын
kather.......................................
@MD-ji7dh
@MD-ji7dh 2 жыл бұрын
Not bad, but a lot of bugs
@techwithomar1875
@techwithomar1875 4 жыл бұрын
Hi
@baburajp8342
@baburajp8342 4 жыл бұрын
Tenth comment 😉
@karansingh9700
@karansingh9700 4 жыл бұрын
second
@dogesh828
@dogesh828 4 жыл бұрын
third
@prajwalmishra8562
@prajwalmishra8562 4 жыл бұрын
First
@tahalyousfi
@tahalyousfi 4 жыл бұрын
Hi I love your content Tim
Python Checkers AI Tutorial Part 1 - The Minimax Algorithm Explained
14:24
Please Master This MAGIC Python Feature... 🪄
25:10
Tech With Tim
Рет қаралды 97 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Minimax: How Computers Play Games
14:37
Spanning Tree
Рет қаралды 215 М.
Can THIS win Sebastian Lague's Chess challenge?
10:11
Game Tech Explained
Рет қаралды 203 М.
Python/Pygame Checkers Tutorial (Part 1) - Drawing the Board
33:26
Tech With Tim
Рет қаралды 144 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 664 М.
I made an unbeatable Tic Tac Toe AI (Minimax algorithm)
9:19
nextProgram
Рет қаралды 134 М.
Algorithms Explained - minimax and alpha-beta pruning
11:01
Sebastian Lague
Рет қаралды 1,1 МЛН
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
Python/Pygame Checkers Tutorial (Part 3) - Jumping and King Movement
58:46
Python Pong AI Tutorial - Using NEAT
1:18:13
Tech With Tim
Рет қаралды 107 М.