How to Make Chess in Python!

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 210

  • @lemastertech
    @lemastertech  ปีที่แล้ว +7

    Hello All, I made a follow-up video where we add en passant, castling and pawn promotion! Be sure to check that out here to continue the journey! th-cam.com/video/s2Dd_obh3fM/w-d-xo.html

    • @BesongAbigail
      @BesongAbigail 5 หลายเดือนก่อน

      please when i run the code , it tells me that the black queen has a problem

  • @Krishn_G
    @Krishn_G 8 หลายเดือนก่อน +7

    A great tutorial, brother. Thanks a lot.
    I would love to watch more of such projects of yours.

    • @lemastertech
      @lemastertech  8 หลายเดือนก่อน +2

      Thanks so much for watching!! Glad you liked it and I hope you like my other videos too! :)

  • @freeelectron8261
    @freeelectron8261 11 หลายเดือนก่อน +11

    Great tutorial. BTW, Don't know why you worried about the audio it was way better than most TH-cam tutorials. Nice work!

    • @lemastertech
      @lemastertech  11 หลายเดือนก่อน

      hey thanks for the super nice comment and thanks for watching!!

  • @codinghighlightswithsadra7343
    @codinghighlightswithsadra7343 ปีที่แล้ว +16

    wow I love chess and I always wanted to make it in a programing language, but I just couldn't find the right tutorial... then u uploaded this video and finely I'm satisfied! thanks for the content!👍

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Thanks so much for the nice comment my friend!! Glad I was able to help 😎 cheers!!

    • @wcsdiaries
      @wcsdiaries ปีที่แล้ว

      when I run mine it pulls up a green screen showing the fps (which flickres from 59 to60). Any ideas why? I copied the code exactly @@lemastertech

  • @josephjohnson4761
    @josephjohnson4761 ปีที่แล้ว +8

    Very well done! very clear and the fact that you provided the github when some other videos for whatever reason did not, is a great plus! one note sometimes your camera square blocks what you are typing, maybe put it in the top left corner but other than that very well done! keep this up and I am sure you will have millions of subscribers and views!

    • @lemastertech
      @lemastertech  ปีที่แล้ว +4

      Thanks so much for the nice comment! I will try to make extra care to not put the video feed over the code in the future, thanks again for watching!!

  • @superman1234567826
    @superman1234567826 หลายเดือนก่อน +1

    Thank you for taking the time to do this

    • @lemastertech
      @lemastertech  หลายเดือนก่อน

      Youre very welcome thank you for taking the time to leave a nice comment!

    • @superman1234567826
      @superman1234567826 หลายเดือนก่อน

      @@lemastertech also wanted to ask you, is mu an acceptable editor for designing this in? i tried running vsc on my computer a while back and had issues with it.

  • @dedtvzqweqwe6799
    @dedtvzqweqwe6799 11 หลายเดือนก่อน +2

    Im so happy that i found your channel so happy

    • @lemastertech
      @lemastertech  11 หลายเดือนก่อน +1

      Hey I’m so glad you did too!! Thanks for watching and commenting! Welcome to the channel :)

  • @savikrey7256
    @savikrey7256 7 หลายเดือนก่อน +3

    thanks for the video, it really helped me with my school project

    • @lemastertech
      @lemastertech  7 หลายเดือนก่อน

      You’re super welcome thank you for watching!!

  • @aidanomeara7850
    @aidanomeara7850 ปีที่แล้ว +1

    This was fantastic, I just finished my game and everything works smoothly. Thanks for the great video!

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Awesome! You’re very welcome and thank you for watching!!

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      @@NAVIN.... Hello, if you have not installed it run pip install pygame - there are a lot of good explanations on how pip works if you need them on youtube!

  • @STARBLAZE-bj5kh
    @STARBLAZE-bj5kh 10 หลายเดือนก่อน +3

    This was a fcukin world-class tutorial man. Don't know why you aint got a million subs

    • @lemastertech
      @lemastertech  10 หลายเดือนก่อน +1

      Hey that’s super nice of you to say mate!! Maybe we’ll make a million one day but for now I’m stoked to almost be to 10k 😎😎

    • @STARBLAZE-bj5kh
      @STARBLAZE-bj5kh 10 หลายเดือนก่อน

      @@lemastertech Your gf is lucky she gets her cheeks clapped by a majestic guy like you

  • @wacksas
    @wacksas 6 หลายเดือนก่อน +1

    Its really nice how you reused the code for the different movements. 👍

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      Thank you! It was alot of fun making this project!!

  • @kingdom1853
    @kingdom1853 11 หลายเดือนก่อน +1

    19:00
    i think working with function will be easier
    def( name, image)...etc

    • @lemastertech
      @lemastertech  11 หลายเดือนก่อน

      Hey you may be right! Thanks for the suggestion!

  • @ameyhukkeri9874
    @ameyhukkeri9874 ปีที่แล้ว +1

    You need recognition, and I'm gon do it for you!

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hey that’s super nice of you haha but no big deal I like making TH-cam content!!

  • @nathank59
    @nathank59 5 หลายเดือนก่อน

    I love this video! Though I would have liked to see a full checkmate situation, this was awesome. I do want to note though that I found something interesting. With the way the code is laid out, there is nothing to prevent the king from putting themself into check. That is something that has been stumping me so I really wish you had covered that.

    • @lemastertech
      @lemastertech  5 หลายเดือนก่อน

      Thanks for watching Nathan! I did do a part two video where I fix a few bugs and add en passant and pawn promotion and castling and I can’t remember if I fully fixed checkmate and check or not (it’s been a while since that video came out) but for sure some of the stuff around endgame conditions I got a little burnt out trying to finish and was already hours deep into the tutorial! Thank you for watching!!

  • @dkkavanagh17
    @dkkavanagh17 6 หลายเดือนก่อน +1

    Wonderful tutorial! However, If you notice it is running slowly, or that it uses a lot of memory, an optimisation you could make would be to represent the board squares as a single 64 length array, instead of a nested array.
    You could also then place the pieces inside the array, combining both location and piece type into a single array.

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      Cool optimization! Thank you for sharing!

    • @Clank12
      @Clank12 6 หลายเดือนก่อน

      How would you go about doing that? Thanks.

  • @flioink
    @flioink ปีที่แล้ว +4

    That's a serious one!
    Not a chess guy myself, but definitely gonna follow that one too :)

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      I like mixing in the big pygame tutorials when I can! And yeah it’s a good practice program even if you aren’t super into chess! Thanks for commenting flio 😎

    • @flioink
      @flioink ปีที่แล้ว

      @@lemastertech 🍻

  • @FinThePin
    @FinThePin หลายเดือนก่อน

    Bro, this is such a good tutorial! I would like to say something too, when you move your knight to c6 or f6, the pawn behind the knight can move over it. If you would be fixing that, it would be absolutely perfect!

  • @crappyusername69
    @crappyusername69 29 วันที่ผ่านมา +2

    I know this video is old, but the asset load part shows the manual code as "black_queen = pygame.image.scale(black_queen, (80, 80))" and the next screen with all of the code shows "black_queen = pygame.transform.scale(black_queen, (80, 80))"

    • @lemastertech
      @lemastertech  28 วันที่ผ่านมา

      sorry sometimes editing these very long videos gets difficult if I try to make a bathroom break or coughing or me accidentally saying something wrong edited out!

    • @crappyusername69
      @crappyusername69 28 วันที่ผ่านมา

      @lemastertech it just felt worth mentioning because it was the only one done manually. If someone followed that and then did it for the rest of them, even if they noticed it being wrong in the next segment, they'd have redo a bunch of text, and way worse if they don't notice the change.

    • @maisaad9014
      @maisaad9014 6 วันที่ผ่านมา

      I need the source code please❤️​@@lemastertech

  • @mayank2473
    @mayank2473 9 หลายเดือนก่อน +2

    Your explanation is the best thank you very much

    • @lemastertech
      @lemastertech  9 หลายเดือนก่อน +1

      Hey you’re very welcome thank you so much for watching!!

  • @augustinegeorge633
    @augustinegeorge633 ปีที่แล้ว +1

    This really helped me. Thank you so much man

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      You are very welcome!! Thanks for watching!

  • @tommynguyen2508
    @tommynguyen2508 ปีที่แล้ว +2

    Well done,bro!

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Thanks Tommy!! Appreciate you!

  • @Bit_Math
    @Bit_Math 6 หลายเดือนก่อน +1

    yes love the comments and explanations thx

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      You’re super welcome thank you for watching!!

  • @goodevening8362
    @goodevening8362 ปีที่แล้ว +2

    great tutorial! just as we were asked to make a chess game as our final homework task for a programming class, still i need to add more features like castling and other , but i guess i'll figure it out

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Thanks for watching! I know there’s some various minor features that we didn’t cover here but shouldn’t be too bad to add castling or upgrading pawns! Good-luck with your project!

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      If you still need it, I did make that follow up with extra features! th-cam.com/video/s2Dd_obh3fM/w-d-xo.html

    • @goodevening8362
      @goodevening8362 ปีที่แล้ว

      @@lemastertech oh thanks! I'll have a look

  • @hbcoding5553
    @hbcoding5553 ปีที่แล้ว +1

    Great vid bud. Will work through it.

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Thanks man!! Hope you like it!!

  • @vitaskacel777
    @vitaskacel777 ปีที่แล้ว +1

    Great tutorial, I have always wanted to create a Chess geme.

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Thanks so much for watching! I hope you enjoyed this one!

  • @Gabriel-sn6yg
    @Gabriel-sn6yg 2 หลายเดือนก่อน +1

    Was the pawn able to jump over the knight at 2:18?

    • @lemastertech
      @lemastertech  2 หลายเดือนก่อน

      Yes but that is the first thing I patch in my chess part two follow up video!

  • @mayank2473
    @mayank2473 6 หลายเดือนก่อน +2

    If my screen size is small what value should i put in column and row in draw board

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      You don’t need to change the numbers of columns and rows just the size of the squares!

    • @Levi_Ackerman_s
      @Levi_Ackerman_s 29 วันที่ผ่านมา

      How ​@@lemastertech

  • @LqMo
    @LqMo ปีที่แล้ว +1

    thanks helped me get to know how to use pygame and how it works

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      You’re very welcome!! Thanks for watching!

  • @MmesoIruma
    @MmesoIruma ปีที่แล้ว +3

    Hi. I am having a bit of a difficult time trying to draw the chessboard due to a smaller screen size. Any ideas on how I can go about this?

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi, are you having trouble drawing smaller squares and pieces and everything, or just one specific part of the board? If you make variables in the beginning for screen width and height, you can draw your squares to be a percentage of that width, and a percentage of that height to scale it down, then you just need to also scale down the images when you load them in. Most of the movement of pieces is coordinate based so if you adjust the coordinate scaling you should be all set!

    • @MmesoIruma
      @MmesoIruma ปีที่แล้ว

      @@lemastertech I still seem to have a difficult time with this. Let's say my width was 1000 and my height 600 what would the rows and columns be?

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      @@MmesoIruma well I leave a bit of the gap at the bottom for instructions and the side to show the discarded pieces, so I would probably make the 8 squares about 60x60 and then use the space not taken up by the squares for additional buttons and discarded pieces, etc.

  • @shivamkushwaha1061
    @shivamkushwaha1061 ปีที่แล้ว +1

    I'd like to have a pin function like- if a piece is in between my king and other check giving piece, then i should not be able to move that piece and yeah thanks teacher for the great project.

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Sure! Easy enough to add that since we already see when the king is in check you could just add a function to limit possible moves to only those that would remove the check condition!

  • @MortySmith-ji2fx
    @MortySmith-ji2fx 9 หลายเดือนก่อน +1

    great tutorial, thanks a lot🎉

    • @lemastertech
      @lemastertech  9 หลายเดือนก่อน

      Aw geez Morty smith you’re like, super welcome, aw geez 😁

  • @marcmailly8176
    @marcmailly8176 ปีที่แล้ว +1

    Eddie Sharick have a function def loadImages() to load chess images in his main program : a global dictionary of images
    images = {}
    def loadImages():
    pieces = ['wp', 'wN', 'wB', 'wR', 'wQ', 'wK', 'bp', 'bN', 'bB', 'bR', 'bQ', 'bK']
    for piece in pieces:
    images[piece] = pygame.transform.scale(pygame.image.load(f'assets/images/{piece}.png'), (size, size))
    His variable size equals the board width divided by 8 (eclidian division)

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Nice!

    • @marcmailly8176
      @marcmailly8176 ปีที่แล้ว

      @@lemastertech
      Eddie Sharick's chess engine in Python, whith objects programmation, in 16 videos in pygame th-cam.com/play/PLBwF487qi8MGU81nDGaeNE1EnNEPYWKY_.html

  • @shivamkushwaha1061
    @shivamkushwaha1061 ปีที่แล้ว +1

    Amazing guide bro, great work only problem was your cam area😅, you could've moved it on a different spot, I was waiting for you to scroll to write most of the time.

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Haha hey sorry man, it’s hard to find a good spot for my camera window, most of the time the text doesn’t go into the bottom right of the screen but I’ll try to be mindful of that in the future! Thanks for watching!

  • @alaaaaa11234
    @alaaaaa11234 6 หลายเดือนก่อน +1

    Is there any way to make the game resizable...I'm not so sure how to do that as the squares, images and text have to shrink and expand according to the window

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน +1

      There definitely is and I’m sorry I didn’t make the original version fully resize-able! rather than explicitly defining all the shapes sizes with pixels like width = 50 height = 50 you would say each square equals 1/10 of the screen height or something along those lines so all your components could scale when you change screen size!

  • @AamaanKafeel
    @AamaanKafeel ปีที่แล้ว +1

    best video helped me a lot

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Awesome thank you for watching!!

  • @smanzoli
    @smanzoli ปีที่แล้ว +1

    Board should also be a loaded image... nice video!

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi I actually think it was kind of fun and pretty easy to draw the board using native PyGame drawing tools but importing an image would be a fine way of doing it too!

  • @hurpyhurpy6467
    @hurpyhurpy6467 ปีที่แล้ว +1

    Very cool guide, thank you !! Can you maybe show us how you would implement castling, en passant and promoting pieces?

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hey glad you liked it! I probably wouldn’t make another video to follow up with those rules, but for castling just add a few lines to the check rook and check king algorithms to add a check to see if the king and castle are in their required locations for it, for promoting pieces when a pawn move is taken check to see if that carried it to the farthest row and if so allow the player to select a piece from the discarded pieces! Or create a new menu to select a piece. And for en passant you would have to add tracking of the previous moves for each piece to see whether or not the pawn you just passed diagonally used the initial two square movement. You’d just have to add a new list keeping track of pawns first moves and whether or not they got there with the two square move! Goodluck!

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hey I made it after all th-cam.com/video/s2Dd_obh3fM/w-d-xo.html this should have the extra functionality!

  • @kynnotkien
    @kynnotkien หลายเดือนก่อน

    Thanks for the tutorial! But I found that there is a bug in pawns move, when there is a piece in front of it, it can still jump 2 squares. But I fixed it by put the second check for 2 square jumps in side the first one!

    • @lemastertech
      @lemastertech  หลายเดือนก่อน

      Nice fix! I made a follow up to this called “more chess” and that was the first bug I fixed in the follow up haha

  • @hibbanislam9240
    @hibbanislam9240 11 หลายเดือนก่อน +1

    Hello! Could you please add a timer on the chessboard coding?

    • @lemastertech
      @lemastertech  11 หลายเดือนก่อน

      Hi! I am probably not going to be doing any more chess videos for a little while but this should be super doable! Just use the computers and pygame’s built in time functions to check how long has passed during that turn and subtract that from total allowable game time for each player!!

  • @godisgood2482
    @godisgood2482 ปีที่แล้ว +1

    Others : They need to read many books and have multiple teachers to improve their coding skills and add to their resume.
    Me: I believe that I only need lemastertech to take me 100 times further in programming

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Haha wow thank you for the super nice comment, I’m sure books and other teachers will help too, but we’ll try to make it as fun as we can to learn with lemaster tech for sure!!! Thanks for watching :)

  • @anushv2857
    @anushv2857 ปีที่แล้ว +2

    This is so cool! But do you know any way that i could flip the board so that it could be easier for the other player to play?

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hi, answered your more recent comment but yes just transform the x and y coords after every move to put whoever you want at top

  • @thegoodside602
    @thegoodside602 ปีที่แล้ว +1

    Just started watching and spotted an illegal king move for white. 1:15

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi - A few fixes and updates have been made to the project on github, do you know if this move is still allowed in the most recent release? Feel free to correct it in your version!

  • @rimshakhan2707
    @rimshakhan2707 25 วันที่ผ่านมา +1

    Thanks!!!

    • @lemastertech
      @lemastertech  9 วันที่ผ่านมา

      You’re very welcome thank you for watching!

  • @oshiso750
    @oshiso750 ปีที่แล้ว +1

    does anyone encounter that it doesn't draw the select pieces for you?

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hi - it sounds like you might call the draw selected function before draw board which would make the board overwrite the select! Hope this helps

  • @alessandrotaranto5564
    @alessandrotaranto5564 ปีที่แล้ว +1

    hi, how could i be able to access the position of the opposite king during the check_king? because i want to make it so that my king cannot move inside another kings range

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi, you could have the opponents kings moved saved in their own list and then when you run check king just remove any squares that are in the opponents list! Goodluck!

  • @anthonyvela5436
    @anthonyvela5436 ปีที่แล้ว +1

    how do you add the asset folder im new and im stuck on this part and need help

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hi that is just a folder like any other folder that stores files in your computer. So find where your IDE saves the .Py file and make a folder named assets in the same location!

  • @JaydenJoseph-ll1vi
    @JaydenJoseph-ll1vi 6 หลายเดือนก่อน +1

    I followed this tutorial to a T, and I even tried to copy the code that you produced to see if I made an error but it keeps coming up with "SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape". What does that mean and what can I do to fix it?

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      Hi I have not had this same issue myself but I found a useful stack overflow article on it you might want to see if a fix is in there! stackoverflow.com/questions/1347791/unicode-error-unicodeescape-codec-cant-decode-bytes-when-writing-windows

  • @BesongAbigail
    @BesongAbigail 5 หลายเดือนก่อน +1

    please how do you run the code ? because I was running it in vscode and it's not going

    • @lemastertech
      @lemastertech  5 หลายเดือนก่อน

      I use the pycharm IDE - it is free from jetbrains.org!!

  • @philip3746
    @philip3746 ปีที่แล้ว

    I thought in python the cells were (row, column) with the top right being (0,0). But the white locations here are [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0) which would put the white pieces down the left side,

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hi Philip! You could do it that way if you want, but I defined them in coordinate fashion where it is (x_coord, y_coord) and not (row, column)! Either is fine but you'll need to modify the way you draw them on screen! I'm not sure I've ever seen top right as 0,0 because in row, column format that would normally be top left!

  • @harshshah691
    @harshshah691 ปีที่แล้ว +2

    Hi bro,really useful video
    But I had a question:-
    Does this code run on vscode in windows11 and if yess pls explain how
    By the way an excellent tutorial from you
    Thanks

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi sure it could, I run it in pycharm but it would run in python for vscode just fine!

  • @Danmo10492
    @Danmo10492 ปีที่แล้ว +1

    ty really well done

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Very welcome! Thank you for watching!!

  • @seaworldwaters
    @seaworldwaters ปีที่แล้ว +1

    hi, i'm up to the end of drawing valid moves on the screen but when i try to run the program it comes up with an error:
    black_options = check_options(black_pieces, black_locations, 'black')
    moves_list = check_rook(location, turn)
    NameError: name 'check_rook' is not defined. Did you mean: 'black_rook'?
    do you have any idea on what the problem is or how i can fix it (or if ive maybe missed anything)? thank you!

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi! The program can’t find the check_rook function so double check that’s what you called the function checking for valid rook moves!!

    • @seaworldwaters
      @seaworldwaters ปีที่แล้ว

      @@lemastertech ohh thank you i just realised the problem was i wasn't blocking out the code for checking other pieces

  • @OZ1jAKOWO
    @OZ1jAKOWO 5 หลายเดือนก่อน +1

    but its not all good , because king can move in area when this area is on cheek

    • @lemastertech
      @lemastertech  5 หลายเดือนก่อน

      So remove that ability in your version!

  • @muhammadahsanali-pq1er
    @muhammadahsanali-pq1er 28 วันที่ผ่านมา +1

    this is a superb video, but i do have a tiny sugestion
    please use enter more ofter use it after use typed a code that is re;ated and use it before the other code
    thaank u:):)

    • @lemastertech
      @lemastertech  28 วันที่ผ่านมา +1

      thank you for the suggestion I will try to work on doing this more!!

  • @bagiragaming8730
    @bagiragaming8730 7 หลายเดือนก่อน +1

    brother can u tell me which application is used like python itself or visual studio 2019 and in that python

    • @lemastertech
      @lemastertech  7 หลายเดือนก่อน

      Python can be downloaded right from the Python official website and then the environment (IDE) I program in is called pycharm and it’s free from jetbrains

  • @randombloke260
    @randombloke260 11 หลายเดือนก่อน +1

    i dont have the scale mod at the beginning so the program wont run. how do you fix this?

    • @lemastertech
      @lemastertech  11 หลายเดือนก่อน

      Hi - not sure what you mean the scale mod but you need to scale everything to a certain size even if it’s bigger or smaller than I specify here!

    • @randombloke260
      @randombloke260 11 หลายเดือนก่อน +1

      thank you

  • @Entitysupasn
    @Entitysupasn 7 หลายเดือนก่อน +1

    Can it be used for Renpy ?

    • @lemastertech
      @lemastertech  7 หลายเดือนก่อน +1

      I have never used renpy so I am not sure!

    • @Entitysupasn
      @Entitysupasn 7 หลายเดือนก่อน

      @@lemastertech oh okayy I will try to figure it out. Thank you for your reply !

  • @raiden2281
    @raiden2281 ปีที่แล้ว +1

    Can this be used for a project for college?

  • @steamstrategy7670
    @steamstrategy7670 9 หลายเดือนก่อน +1

    Hey, I wanted to ask hwo could one add a AI to the game. Could you suggest a place where I could implement a AI to the program? I was thinking of a min max algorithm or something of that sort. Is it possible?

    • @lemastertech
      @lemastertech  9 หลายเดือนก่อน

      Hi that’s a cool idea but there are sooo many layers of complexity you could attack this with, the simplest might be just analyzing what pieces can move and randomly pick one, next level of complexity might be prioritizing certain pieces movements and things like capturing power pieces or assigning a points value to each type of piece and analyzing opportunities to win trades based on future moves and such, I honestly think building a good Chess AI is probably harder than building the chess app I built here tbh

    • @steamstrategy7670
      @steamstrategy7670 9 หลายเดือนก่อน

      @@lemastertechThanks alot for the reply, I am a bit of a beginner, I was thinking of a random move ai, then using a dictionoary list assiging the peice class a number. I was interested in how I could create a simple random move ai.

  • @anushv2857
    @anushv2857 ปีที่แล้ว +1

    How do you flip the board after every turn?

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hi, I suppose the easiest thing to do would be make a version of the board where you do a coordinate transformation of the white and black pieces, so you’d have to do the math that an x coord of 7 equals 0 and vice versa and same for y coords!

    • @anushv2857
      @anushv2857 ปีที่แล้ว

      thank you soo much really appreciate it@@lemastertech 🙏

  • @ORITSU_M...
    @ORITSU_M... 6 หลายเดือนก่อน +1

    Isn't chess has 8x8 grid... 1:11

    • @ThatOneSweat
      @ThatOneSweat 6 หลายเดือนก่อน +2

      i think he is talking about the pieces

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน +1

      Yes the actual pieces go on a 8x8 grid then I leave room for statuses on the sides

  • @brightsde3511
    @brightsde3511 ปีที่แล้ว +1

    bro plays bongcloud - nice vid

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Best opening in the history of chess lol, thanks for watching

    • @dedtvzqweqwe6799
      @dedtvzqweqwe6799 11 หลายเดือนก่อน +1

      @@lemastertecherror (no file ‘ assets/images/black queen.png’ ?😢 i don’t understand what im supposed to do now Help

  • @milkosirkyov4379
    @milkosirkyov4379 ปีที่แล้ว +1

    Very informative video. I tried to implement additional features and it was all going fine until en passant. Can you give me some advice?

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hello - when a pawn makes the two step forward jump you would need a new variable to track if EP should be active, and if so, what square. I would suggest make an en_passant variable that is a tuple with coordinates 0,0 when it’s not active, then you can check if a pawn is selected and EP is in its valid moves it can capture the pawn who made the move. It’s not gonna be too hard but a fair bit of extra code! You got this! Goodluck!

    • @milkosirkyov4379
      @milkosirkyov4379 ปีที่แล้ว

      @@lemastertech Thank you. I saw where the error comes from.
      If click in white locations:
      Selection = white_locations.index(click)
      If turn step == 0
      turn step = 1
      Here I get the click coordinates
      If click in valid_moves and selection != 100:
      Here I get the place the piece has moved to
      The problem arises only when I select a piece then deselect it. It always takes the initial position of the piece first selected. Do you have any idea how to fix that.

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      @@milkosirkyov4379 I would suggest when you deselect a piece overwrite your original position variables with either nonsense values like 100,100! Then if it still isn't working try printing your location tracking variables in the console window while you troubleshoot - you may be able to track down where the values are not clearing out but should be!

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hey if you still need help with en passant or castling or pawn promotion I did add that! th-cam.com/video/s2Dd_obh3fM/w-d-xo.html

  • @landonquijada
    @landonquijada ปีที่แล้ว +1

    whats the software you use?

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      I use pycharm - it’s a free IDE from jetbrains.org !

  • @TanmayJani-no1yv
    @TanmayJani-no1yv 6 หลายเดือนก่อน +2

    Can we make chess bot who play like top chess player I need video for it, any lead will be appropriate thanks 🙏

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      Hi an intelligent chess bot capable of playing like a human is a massive programming undertaking. There are third party plug ins you can try to integrate but it’s not a quick or easy project to just add AI to the project!

    • @TanmayJani-no1yv
      @TanmayJani-no1yv 6 หลายเดือนก่อน

      @@lemastertech yes, it’s long project can you please guide me ,first I will do extract top 50 players pgn file then combine it to one pgn file then convert into csv format, then implement some model for predicting next move like xgboost or cnn, x label and y label which column should I put like X represent chess board and y will be all the mainline column

  • @dedtvzqweqwe6799
    @dedtvzqweqwe6799 5 หลายเดือนก่อน

    I got an error at loading the images what should i do should i change ( assets/image/.png) into where ever my images are right ? ❤

    • @lemastertech
      @lemastertech  3 หลายเดือนก่อน

      Hi sorry I missed this but what specific error you’re getting would be useful!

  • @greenappleand10mothers10
    @greenappleand10mothers10 2 หลายเดือนก่อน

    what if you wanna let the player choose where to put pieces?

    • @lemastertech
      @lemastertech  2 หลายเดือนก่อน +1

      You could use placeholder lists that players are able to modify with a startup menu or something like that!

  • @swegboy0238
    @swegboy0238 ปีที่แล้ว

    I'm having an issue with the turn_step loop and piece selection/movement. I just finished the knight movement but this has been an issue since I made the pawns.
    In short; it never seems to go around to turn_step 0, and the black pieces never move.
    It starts with white's turn and I think they behave as they should, but once I then select black pieces and see the blue selection marker and valid moves, whenever I try to move any kind of piece to any possible spot, the white counterpart goes there instead. I try to play any pawn, 1 step or 2, the opposing white pawn gets placed there, and it's still black's turn to select a piece (turn_step 2). Try to move a knight and the mirrored white knight teleports right in front of my poor unsuspecting black pawns. Still black's turn. Select a black pawn to capture the knight and the opposite pawn moves 4 squares down and 1 to the side to land on top of the knight. Still black's turn.
    turn_step goes: 0 1 2 3 2 3 2 3 but only white pieces move, so when it's black's turn the white pieces move with the black's valid moves. I cannot select or interact with the black pieces on white's turn.
    So besides crossing the board, they're only making valid moves, aka only moving to squares with colored dots, so I'm guessing it's the turn_step cycle and the white/black_selections/locations lists or something, but I haven't got a clue where I went wrong.

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi! If I were you I’d track down the code conditions that increment to the step step in the sequence, so having a piece selected and then commanding it to move, and just make sure that the conditions to cycle through that are not true after a turn has been made, best way to do this is using the print() command and making sure nothing is selected after a turn finishes! Goodluck!

    • @swegboy0238
      @swegboy0238 ปีที่แล้ว

      @@lemastertech Thank you. So I put debug print functions after every instance of "turn_step", and the 2nd one, at the bottom of the "def draw_board():", is drowning out the rest. Murdering the fps down to 1 shows that sometimes debug 3 or 4 ("def draw_pieces():" after drawing the white and the black pieces, respectively) gives the same value as debug 2. Now again, they show the correct value, but it still never cycles back to 0.
      At first I thought that drawing the board might be updating the state every frame, but rewatching the segment of the tutorial shows that it's only getting the current state, not providing it's own. Debug 3 and 4 are also placed after "if turn_step < 2:" and "if turn_step >= 2:" so they're also not actually doing anything either.
      Removing the 2nd debug print(), the 4th and 6th took over, drawing the black pieces and drawing the valid moves. Debug 9 also chimes in when black "places" a piece. The debug line is at the end of white's turn and before black's, just after the "turn_step = 2 \ selection = 100 \ valid_moves = []" combo. Checking the log, debug 10 also gave what appears to be the correct value, placed in the middle of black's turn, just after "if turn_step == 2: turn_step = 3" and before "if click_coords in valid_moves...".
      The next and final debug after that is after the turn_step reset 3-in-1 combo above the "pygame.QUIT" bit. It hasn't said anything far as I can tell. Do I add a "if turn_step == 3: \ turn_step = 0" at the end of black's turn? Playing the game makes 6 and 4 go wild with the amount they post too, so maybe they're being drawn wonky? They obviously don't look weird. A headscratcher to sleep on, I suppose.

    • @swegboy0238
      @swegboy0238 ปีที่แล้ว

      okay so after using Notepad++'s ComparePlus plugin vs the GitHub code I decided to condense my code and finally found a "white_locations[selection] = click_coords" in black's turn in the # event handling. Changing it to black fixed it and now everything's working as intended! So lesson of the day is be supremely diligent when copying code!

  • @Levi_Ackerman_s
    @Levi_Ackerman_s 29 วันที่ผ่านมา

    In my pc there are screen size issue what size should i have to change
    Please tell me anyone

    • @lemastertech
      @lemastertech  26 วันที่ผ่านมา

      The whole screen is the wrong size or an individual piece is the wrong size? There’s a lot of individual components that would need to be scaled down if you need it smaller! Pretty much every x and y value depends on that

  • @skiBDman
    @skiBDman ปีที่แล้ว

    hey I've just got to the selection part but it's not working. it for some reason is like going up on an angle so like when I click a piece it will be in the right row but it and the bottom rook and the second pawn are correct but all the others are just random should I just start over or do you know what is wrong

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Just sounds like maybe you’ve got an x and a y flipped somewhere, like you click a piece that should be 3,1 and you’re showing 1,3 or even that the coords are backwards for all the possible moves! I’d just double check indentation and whether you’ve got any x and y flip flops!

    • @skiBDman
      @skiBDman ปีที่แล้ว

      @@lemastertech oh tysm I'll try it

    • @skiBDman
      @skiBDman ปีที่แล้ว

      @@lemastertech is this the problem do you think if turn_step

  • @InvisibleBoostGaming
    @InvisibleBoostGaming 3 หลายเดือนก่อน

    Idk why a pawn renders instead of a queen

    • @lemastertech
      @lemastertech  3 หลายเดือนก่อน

      I’m not sure either but sounds like one of your lists that compares numerical values to images might be mapped wrong!

  • @The-Ferret-Man
    @The-Ferret-Man ปีที่แล้ว +1

    i'll sub if you make a short follow up video on how to implement en passant, castling, and pawn promotion

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      If the only reason you’d sub to my channel is I do what you tell me to do I don’t think I need your sub that badly my friend 😂

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      I made your follow-up with those features now you owe me a sub ;) th-cam.com/video/s2Dd_obh3fM/w-d-xo.html

  • @anou3866
    @anou3866 ปีที่แล้ว

    When I run, it only displays a black screen with python doesn’t respond

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi, double check indentation of the statements PyGame.display.flip at the bottom and double check your event handling has of event.type is QUIT then run is false! Sounds like a formatting issue

    • @anou3866
      @anou3866 ปีที่แล้ว

      @@lemastertech I checked it no wrongs in #event handling

    • @anou3866
      @anou3866 ปีที่แล้ว

      @@lemastertech thanks for your help

  • @חגיתכהן-פ3כ
    @חגיתכהן-פ3כ 7 หลายเดือนก่อน

    תודה רבה!
    אתה מסביר בצורה מאוד ברורה
    אני נתקלתי בבעיה שאשמח אם תוכל לעזור לי בזה
    כשאני לוחצת על pawn בselection מוכנס המיקום של אותו לחצן במערך המיקומים => selection = white_locations.index(click_coords)
    וכשאני רוצה אם הלחצן שלחצתי אם הוא מיתוך הרשימה של הלחצנים שיש לי גישה אליהם אני כותבת את זה כך valid_options = options_list[selection]
    והבעיה שלי שהoptions_list הגודל שלו יותר קטן מהseloction ואז התוכנית נופלת לי עם שגיאת IndexError: list index out of range

    • @lemastertech
      @lemastertech  7 หลายเดือนก่อน

      The length of locations should be the same as the length of pieces so doesn’t make you’re getting this error unless something is overwriting at a wrong point, and I don’t speak Greek

  • @Sakshayani
    @Sakshayani ปีที่แล้ว

    i got an error(their is no pygame module)☹

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi you need to make sure you run pip and install the pygame module before it will run!

  • @Belek3
    @Belek3 11 หลายเดือนก่อน +1

    26:58

    • @lemastertech
      @lemastertech  11 หลายเดือนก่อน

      Thanks for watching!

  • @car_fanz_
    @car_fanz_ 9 หลายเดือนก่อน +1

    what python program I don't know

    • @lemastertech
      @lemastertech  9 หลายเดือนก่อน

      I use the pycharm IDE from Jetbrains!

  • @xattv1734
    @xattv1734 ปีที่แล้ว +1

    u forgot about en passant @Lemaster Tech

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Hi! I actually didn’t forget it, I had just never grown up playing that rule so I’d never heard of it til people in my comments told me about it! Should be a pretty easy add but it’s true I didn’t include that, sorry!

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      I did add en passant, castling and pawn promotion in a follow up just so you know! th-cam.com/video/s2Dd_obh3fM/w-d-xo.html

  • @protibadimon4169
    @protibadimon4169 ปีที่แล้ว +1

    Can you make it online multiplayer game? I will pay you

    • @lemastertech
      @lemastertech  ปีที่แล้ว +1

      Hi, I am done with chess content for a while. I made two multi hour videos and now I need a break haha!

  • @gamerlizzy8421
    @gamerlizzy8421 6 หลายเดือนก่อน

    what program are you using? I'm still new to this and when I run python it looks nothing like this

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน +1

      I use the IDE pycharm from the company jetbrains! It’s free and you can get it from jetbrains.org

    • @gamerlizzy8421
      @gamerlizzy8421 6 หลายเดือนก่อน

      @@lemastertech thank you!

  • @tahaneji2102
    @tahaneji2102 ปีที่แล้ว

    which version of python is this ?

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      3.10 or 3.11 don’t remember for certain! I know I haven’t updated to 3.12 - and I use the pycharm ide

  • @lorenzowhois
    @lorenzowhois 9 หลายเดือนก่อน +1

    awesome video daddy!

    • @lemastertech
      @lemastertech  9 หลายเดือนก่อน +1

      TY although I prefer to be called Zaddy

    • @lorenzowhois
      @lorenzowhois 9 หลายเดือนก่อน

      @@lemastertech gotcha zaddy 👌😘

  • @inhcong8263
    @inhcong8263 หลายเดือนก่อน

    great!!

    • @lemastertech
      @lemastertech  หลายเดือนก่อน

      Thank you so much for watching!!

  • @陳詠靖-c9d
    @陳詠靖-c9d 6 หลายเดือนก่อน +1

    It seems like you spent lots of time debugging the moves_list's parentheses. Otherwise you wouldn't keep mentioning it so many times.

    • @lemastertech
      @lemastertech  6 หลายเดือนก่อน

      I spent a lot of time debugging everything in this project it was a huge project but yes in general anything with a bunch of nested parentheses is especially important to pay attention to syntax haha

  • @vadapallipreethi1756
    @vadapallipreethi1756 ปีที่แล้ว +1

    Your so good😊❤❤

  • @jaivikgamer5830
    @jaivikgamer5830 ปีที่แล้ว +1

    I think you should make it's shorter version 👽

    • @lemastertech
      @lemastertech  ปีที่แล้ว

      Haha interesting idea - you mean just reviewing the code or actually making a version with less features?!

  • @ameyhukkeri9874
    @ameyhukkeri9874 ปีที่แล้ว

    Is there any way i can connect to you personally??