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

preview_player
Показать описание
This python checkers AI tutorial covers the implementation of the minimax algorithm in python. We will visualize the minimax algorithm and implement it to create an AI that can play the game of checkers.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾

💰 Courses & Merch 💰

🔗 Social Medias 🔗

🎬 My YouTube Gear 🎬

🎤 XLR Microphone (Rode NT1): Not available

◾ 💸 Donations 💸 ◾
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾

⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡

⭐ Tags ⭐
- Tech With Tim
- Python Minimax
- Minimax Python
- Minimax AI
- Minimax Checkers
- Checkers Minimax AI

⭐ Hashtags ⭐
#python #minimax
Рекомендации по теме
Комментарии
Автор

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.

spark
Автор

The idea of you with storing possible moves in a map data structure helped me a lot .. Thanks for that!

softknk
Автор

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.

thomasbezencon
Автор

Old tutorial but this actually helped me for my classes and adapt your methods to my own code.

DarkusNights
Автор

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.

dpskane
Автор

It's great to have someone who speaks normal English and can explain the programming properly. Thanks a bunch, Tim

Fersko
Автор

Recursion is always confusing but after a lot of thinking you can finally get your head around it.

shaharyarahmed
Автор

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

chinonsodimgba
Автор

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

victor
Автор

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...

manfredreinsch
Автор

Hi tim thanks for making the second part! as always I just love watching your videos related to any topic!

amankaushik
Автор

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

ohgreatone
Автор

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?

showmickkar
Автор

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.

ohgreatone
Автор

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

ohgreatone
Автор

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?

tomiolah
Автор

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!

КириллПопов-ос
Автор

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

ashwanirai
Автор

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!

manfredreinsch
Автор

which color theme and font are you using currently

AfrasiabAhmadSU__O_OO_OO