Python/Pygame Checkers Tutorial (Part 3) - Jumping and King Movement

preview_player
Показать описание
In part three of this python checkers pygame tutorial we will be working on the mechanics on jumping a piece and the movement of our king pieces.

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

💰 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 Pygame
- Pygame Checkers
- Checkers Pygame
- Python Checkers
- Python Checkers Pygame
- Pygame Checkers Tutorial

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

As some people have pointed out there is a few minor bugs here that occur in very rare edge-case like scenarios. Unfortunately I will be able to make another video to fix these but I encourage you to read through the comments and let me know if you come up with any solutions. The one's I'm aware of now are:
- King counter increases when king revisits side that made it king (very easy fix)
- If a piece can double jump over multiple pieces and land on the same destination square you can't pick which exact move to make (involves changing the whole movement selection process)

TechWithTim
Автор

Wow the quality of this series is so much better than the old pygame ones (I've seen all of them) the code is easier to understand, the camera zooms are extremely helpful, the explanations are better there is a clear focus on OOP, and there's face cam. Even if no one else appreciates the upgrade I certainly do.
God bless.

Mushbeary
Автор

Dude I think your videos are underrated. Really underrated. You give us a lot of useful content, a lot more than even paid courses can give. Just want to thank you for your video lessons, they really help me to grow up as a python developer.

vrdzcrk
Автор

Found a solution for red not being able to jump twice - change in board, for both traverse_left and traverse right:
if last:
if step == -1:
row = max(r - 3, -1)
so make the 0 a -1 :)

Amitbidermoon
Автор

Hey Tim, absolutely loved this series, so fun and challenging on the algorithm part, thanks for putting this together! I think the last pygame project I did with you was Snake which I found really cool, but it had all code crammed in one file, so love the progress you made since then with putting stuff in modules as well as putting this more 'advanced' stuff like private methods, it's been honestly so helpful!
Have you considered adding to your tutorials few bits where you'd be like 'ok now we'll need to write this function (or even a line of code) that does this or that, you guys should pause the video and try to code it yourselves'? I've not seen all your videos (yet) but I think few challenges here and there could help your viewers.
All the best!

albertzagajewski
Автор

Man you put a lot of mind and energy in this algorithm. Good job

boylinzosall
Автор

Best channel I came across YouTube till date.A big Thank you.

globalchess
Автор

Hi Tim. AWESOME tutorial!!! I did find a bug which I also fixed. BUG: when double jumping where the final position is the last row (where the piece would become a king), the last row is not included as a valid move. FIX: row = max(r-3, 0) needs to be revised to row = max(r-3, -1) This change needs to be made is 2 places - in the traverse_left function and the traverse_right function.

danadasachan
Автор

Hey Tim, can you make a series teaching how to agar.io or paper.io or diep.io or any fps game in python day - 14. Like so he can see.

programmingwithpranav
Автор

Hi Tim, love the video! just want to you to know that i made the game with you, and even crated an online version of it myself! with the knowledge i got from your online games series

elad
Автор

This is awesome man, thank you so much. Like you said in the video, I think the best way to explain the more complicated algorithm parts would be use a visual diagram while you're explaining it, something that shows the possibilities that each part of the algorithm covers? I appreciate that might get exponential very quickly for something much bigger than this but might be worth a shot. Please keep up the amazing work!

DM-nzwq
Автор

The programs don't work properly if you triple jump.

chinmaykumar
Автор

To fix the issue of tripe hoop, you have how account for whether or not we skipped when updating the moves.
For example, in _traverse_right you should have:
if skipped:
moves.update(self._traverse_left(r+step, row, step, color, right-1, skipped=last+skipped))
moves.update(self._traverse_right(r+step, row, step, color, right+1, skipped=last+skipped))
else:
moves.update(self._traverse_left(r+step, row, step, color, right-1, skipped=last))
moves.update(self._traverse_right(r+step, row, step, color, right+1, skipped=last))
And do the same _traverse_left

junli
Автор

Wow, this checkers series is really lit🔥

Shivam-jvme
Автор

Looking forward to building the AI already ! awesome series

Amitbidermoon
Автор

Just writing a comment for the algorithm. Great project idea, hope you get more views

MD-jidh
Автор

Hi Tim, like the series, I'm always learning new things from your videos. Not a great fan of code/logic with lots of if statements though, have you considered using an array to hold possible move positions, something like "move_matrix = [(1, 1, 2, 2), (-1, 1, -2, 2), (1, -1, 2, -2), (-1, -1, -2, -2)]", where the tuples contain the allowable x and y offsets from the current position. If you add these offsets to your current position, you'll get a list of the cells to check. If you loop through the list (first 2 elements if you're moving down, last 2 for up and all for the king) then check what's in the first and second positions, there are only 2 valid move combinations; an opponent's piece in the first position and nothing in the second or nothing in the first.
In addition, if you surround your original array with a couple of rows of dummy cells that contain something that isn't red, black or a space, you don't need to check for edges and avoid index out of range errors. Hope this makes sense, easier to code this than trying to put into English:-)

alun
Автор

Hey Tim! Great video series! Loved the way you've explained everything! There does seem to be a small bug with respect to linking forward and backward jumps for kings. The recursive calls look like they do handle a change in direction (up or down) for kings, but a king still can't jump over a piece forwards and then backwards. Is there any fix for this?

srishti
Автор

that was really helpful thank you a lot!

abdelazizkhalid
Автор

Hey Tim, its me again! According to the international rules of checkers there exsists the concept of a "flying king", i.e. you are allowed to jump over an opponent piece more than once. This is not allowed in the English rules but still possible in your current implementation and might even cause a non-ending loop.
Just consider this worst case scenario: a square of four opponent pieces. Starting at a corner of a square twisted by 45° to the original one a king piece might jump over the the opponent pieces infinitely.
This issue can be fixed by checking whether an opponent piece is in the list of captured pieces already.

manfredreinsch