CHESS! // Code Review

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

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

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

    Thanks for watching! Code Review album drops next summer 😎 Don't forget that the first 1,000 people to use this link will get a 1 month free trial of Skillshare: skl.sh/thecherno11211
    Couple things I missed in the video:
    - The king and queen positions are flipped! Not sure how I managed to not notice…
    - Castling _does_ actually work, but you have to drag the king onto the rook - I’m used to castling by dragging the king two spaces over, which doesn’t work in this game

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

      Ready enjoyed the song lol

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

      Слушай, как насчёт рассказать как ты переехал в Австралию?

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

      I believe I'm owed some royalties. Sunglasses McCoolguyface is _my_ thing!😡... 🤪 😎😎😎

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

      Btw, I need that compressor in my life. Where can I get one?! If you don't know what the hell I'm talking about, just point me to your audio person. Thx in advance.

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

      Oop is not the only way... It's just the only way that is _correct!_ again, 😂... No more, I promise.

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

    Okay I didn't expect you to go this HARD on singing

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

      It was so good as well!

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

      @@Keregosh Did he use autotune?

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

      @@emty5526 I have no idea xD

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

      It was great! Except for the last bit

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

      i sang along, it made my day!

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

    Next video: How to build C++ projects and setup a git repo
    (Best clip btw: th-cam.com/users/clipUgkxtL5J8amsZAOkbza7ucYwc6EDEAQEaEQ7 )

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

      This would be so important!

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

      would be cool

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

      Yes

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

      Create new repo, clone locally. Create cpp project in another directory. Then copy entire project to the repo dir. Done.

    • @mr.mirror1213
      @mr.mirror1213 3 ปีที่แล้ว

      I want this

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

    When my man played the bong cloud I knew he was a man of culture ♟️

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

      I'm into chess and programming and now I like him even more.

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

      Cue Hikaru bongcloud speedrun intro.

    • @megaman2016
      @megaman2016 2 ปีที่แล้ว

      Hahaha

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

    SVG (Vector) Images are perfect for these kind of simple textures, small filesize and scalable and supported in SDL

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

    Hey, did you try clicking on the king and then on the rook? I think that might trigger castling, since when you clicked the king, it showed the rook square as a possible option.

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

      We do see a MoveType CASTLE so I also guess it's there somewhere (haven't finished watching.. just noticed it now and ran to comments :P )

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

      This annoyed me so much xD. Cherno bashing so hard on not being able to Castle. It's more an intuitive problem than it not being there. But ah well.

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

      @@AgentM124 I think moving two squares with the King is like the fundamental principle of castling and “moving to the rook” is more of a quality of life improvement. Which is probably why Cherno’s assumption that castling didn’t exist is a valid one.

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

      @@blablabla7796 the fundamentals of castling isn't to put your king behind the pawns in the corner and your rook into play?

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

      @@AgentM124 the concept of castling is moving your King by two squares in one move provided the following conditions are met:…. The same as moving your pawn from the 2nd or 7th rank to the 4th or 5th which is two squares in a single move given the following conditions … respectively. The idea is that they are special moves that typically involve multiple moves but only take a single move if certain conditions are met. The king swapping positions with the rook somewhere in the middle is more of a derivative idea based on the previously mentioned underlying concept as a way to better visualize the move.

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

    I like how he never realized that the queens and kings were placed incorrectly on the board.
    Would really love to see Chess made in Hazel2D!

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

      @@J3ekir Same lol

    • @lakshyarajsinghrathore1902
      @lakshyarajsinghrathore1902 3 ปีที่แล้ว

      I too saw that.

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

      Its not, its just turned around

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

      @@kalilinuxuser972 king and queen need to swap or the colors need to flip

    • @ShardCollector
      @ShardCollector 2 ปีที่แล้ว

      I literally thought you were trying to castle with the queen, because it was in that position 😂

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

    As a full time C++ dev i can only say excellent code review! You pointed out all of the major pinpoints with an easy to understand explanation on why and how to improve it without going into any super advanced C++ topics that would easily confuse & overwhelm a beginner programmer. Great Job! I wish i had someone like you when i was first getting into C++.

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

    "What are we thinking... like, Bongcloud opening, probably?"
    Ah, I see you are a man of culture as well.

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

    I'm about 8 minutes into the video and I just couldn't hold back. How did no one notice that the kings and queens starting positions are switched. I wouldn't have noticed until the Cherno started playing. Maybe you'll point that out later in the video but ahhhh.

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

      Haha lol good point! I totally missed that! I guess I didn’t notice because it changes depending on which side you play, and I must not have paid too much attention to the colours since I was playing myself here

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

      Actually the pieces are on the correct coordinate but the color of the squares are "wrong".
      If you imagine the coordinates, White's King is on e1 and Black's King is on e8 which is correct. Changing places would make kings start on the D-file which would be completely wrong.
      The rule "White's queen on white square and Black's queen on black square" can't overrule the coords, in order to make it right, black pieces should be arranged on top of that board and white pieces on the bottom of it.

    • @Batman-bh6vw
      @Batman-bh6vw 2 ปีที่แล้ว +2

      @@ScorpionG4merBr I'm not quite sure I understand what you mean by the coordinates. Currently the kings are on the D file. The only problem with the layout is that the respective kings and queens need to be switched around.

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

      I don't remember exactly my line of thought but you're right.
      Sorry for the confusion.

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

    Pretty sure he did castling but you need to drag the king to the rook..

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

      Ya I saw the rook light up so it seemed like it was working.

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

      I was so annoyed by this hahaha

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

      Well, that would be misleading interface...

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

      if he played chess often he'd realize absolutely no chess clone does that, you have to drag the king two squares (3 squares if it's on queen side) close to the rook to trigger castling

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

    I love how he just instantly understands every function/class, tears it down and reduces the CPU usage by 99% in the first 5 mins of seeing the code 😂

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

    I think one of the biggest design problems in the code that you missed is that they didn't decouple the rendering stuff from the actual chess engine

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

      Exactly what I thought

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

    Another vote for a video on build and distribution processes.
    I also like how you separate your own opinions on code from actual issues in the code.

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

    Even if you have a constant (like 8 tiles per row), it's good to use a constant instead if you're gonna type if more than once so that you know exactly what that 8 is. Maybe there are other things that also have the value 8. It will help you understand your code.

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

      That's true a lot of the times, but in a situation where you are writing something like:
      for (int row_number = 0; row_number < 8; ++row_number) {}
      I think it's obvious from context what that 8 means and if you accidentally type 9 instead, you will catch that mistake immediately from context. If you write a lot of words, instead of numbers, it can infact confuse you because you need to spend some mental energy deciphering what the words mean. If you see 8, you know the loop will iterate 8 times, if you see BOARD_SIZE, you first have to find out what BOARD_SIZE is - is it 8, is it the number of pixels in one dimension, .... My point is, you have to think more when you are using words instead of numbers. In cases where it may not be clear from context what the 8 means I agree with you fully, but considering this is a chess application and the person reading your code, be it you, or someone else, is most likely not stupid, it's a reasonanble thing to assume that they know what the 8 means.

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

      @@stewartzayat7526Literal numbers are always bad:
      - Forbids you to ever change. Otherwise you'll have to go replacing the entire project.
      - May mistake their meaning.
      - Words can always describe better. If the number "is obvious", the word could has it: BOARD_SIZE_8.
      - ~100% chance of a word typo resulting in compile error.
      - C++ Core Guidelines says to always avoid them.

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

    I just want to say, that seeing the way you go through the code, how quick you are and all looks so damn cool holy shit-
    I love you videos

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

    A video on building c++ code and about build systems will be great. The main problem for people is that they don't understand how compilation and linking works. And how to deal with libraries.
    Btw loved your voice 😋

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

      I second this so much. I really wanna learn CMake as a linux user but it's just so complicated and there are pretty much no tutorials that go beyond the very basics

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

      YESYESYES

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

      Yes would love to see that too!

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

      Yes this would be very helpful

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

      Build systems would be extremely helpful. I never understood it.

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

    Very tough to see king and queen in the wrong place at the start of every game. Otherwise very cool project and great review!

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

    The build system in C++ is one of the reason I moved to Rust. Everybody does things differently and it's so hard to put the pieces together. Most of the people uses CMake, so it makes things just a little bit easier, but it's always terrible =/

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

      Backend eng here, which uses python, cpp, dotnet, and rust. I love cpp, but not the build system lol. I don't know why no one in 20+ years streamlined this process with a standard. If anyone is interested I created some cmake templates for sdl2 and sfml which can make life easier for simple game dev projects. Is a work in progress. Would love feedback, so far every template works on windows and Linux. Need to write docs for running.

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

      autotools is also fairly common. its amazing once it gets working (it can make porting things into an almost trivial task in some cases), but having to mess with it is an absolute pain.

  • @Ken-Creates
    @Ken-Creates 3 ปีที่แล้ว +35

    Lets be fair, most of the projects on github (including big name ones) have many of the same issues - missing files or the expectation that the person building the code has just the right version of python / ninja / environment paths / ceiling cat set up. A huge amount of pain and wasted time would go away if we could solve this. My steps when I'm about to put anything out public is to take a totally fresh windows/linux/mac install as necessary (a vm is fine) and then see what it takes to build / run the thing I'm putting out. I document everything needed at that point and either "fix" stupid requirements and start again or ensure all steps are clearly documented.

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

      Docker is the way

    • @Ken-Creates
      @Ken-Creates ปีที่แล้ว

      @@sebastianmorris5394 It's really not though, I've had just as many issues trying to install docker versions of things as non docker versions. It just adds yet another layer of potentially broken stuff. The few times I have deployed something docker based that worked right away broke within a few weeks after an update was required and pushing that update either to docker or to the thing itself left it so broken I had to start back from scratch.

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

      @@Ken-Creates you're probably not being specific enough with your yaml file container versions

    • @Ken-Creates
      @Ken-Creates ปีที่แล้ว

      @@sebastianmorris5394 Haha, I'll take that as agreement that it's not the way. 😆

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

      @@Ken-Creates ok kiddo

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

    when he clicked the king, the rook was highlighted, suggesting that he could've castled.

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

    6:04 I'm pretty sure you can, it's just not standard, the rook is highlighted as a possible move
    34:30 isMyPiece() or canMovePiece()
    36:00 still doesn't notice you can castle :)
    49:50 Or create once then copy construct the rest? (not sure what the non default copy constructor did, why it set texture to null)

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

    18:15
    Everyone chilling while cpu7 is dying
    18:33
    Cpu7: my suffering is finally over, i am out of event polling hell

    • @josephlabs
      @josephlabs 3 ปีที่แล้ว

      😅

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

      I just checked the github repo, and dude didn't even made that fix. wtf. Why send code for review and then not listen to the recommendations. 🤦‍♂️

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

    Why is no one talking about the fact the King and Queen are literally in the wrong squares

  • @exlpt2234
    @exlpt2234 10 หลายเดือนก่อน +4

    2:50 why can bro sing so well

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

    I think you can castle is you click on the rook after selecting the king.. the rook square is highlighted as a valid king move bro, you missed that

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

    One thing to add (months later), try not to hard code values everywhere. You could calculate the division value for example as a global. So if you change the resolution, the division values also change. You could still leave them const manual updates as well, but it would be better if they were all together in one place. Not spread out through the code.
    Edit: Nvm, just saw he mentions it later haha

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

    that performance brought a tear to my eye. what a truly angelic voice. adele ain't shit.

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

    I like how he never realised that he could castle the king because in the MoveType there was castle in the list, probably when he tried the game he couldn't castle because he had to drag the piece on top of the rook, but this is irrelevant, beautiful video!!!

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

    It's fun to see that how you quickly tested checks, castling, checkmate and prise en-passant (and later promotion), but failed to notice that the king and queen's position were inverted in the initial position, which striked me the second I saw the board :P.
    It perfectly illustates why it's so important to have experienced alpha/beta testers (and sometimes a few team advisers familiar with the game genre during the design and early development) when developping games.

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

      he probably just didn't wanna spend too long on it, cuz he didnt test promotion, playing an actual game of chess or a few would have definitely been enough to make one realise

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

    I remember the first chess game I programed with my dad, well he did all the programing as I was like 8. Done in BASIC on an old IBM computer with no hard drive and 5 1/4" floppies! It was written such that you gave the coordinate position of the piece, then named the piece and then gave the coordinate position that you wanted to move too and the name of the piece. I think most of you can guess the bug.
    ...
    As long as the move was a legal move for the piece you were moving (at the start of the movie), you could rename the piece in the destination field and promote it to anything you wanted

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

    3 move draw rule, 50 move without a capture rule, stalemate, insufficient material, draw offer, resigning, plenty of other test cases to deal with that are probably not implemented but more time consuming to test. It doesn't show the moves, who is to move or offer PGNs to clipboard which also is not great.

    • @liptak391
      @liptak391 2 ปีที่แล้ว

      Did he test for discovered check?

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

    came here for the code review and now I am waiting for your debut album.

  • @джамп
    @джамп 2 ปีที่แล้ว +1

    This is so entertaining to watch as a programming student. I'm looking forward watching more code reviews 🧐

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

    Best code review to date. Thanks!

  • @albratgaming2348
    @albratgaming2348 2 ปีที่แล้ว

    One thing you did not say but is something I heard as a point of graphics... If you need a texture at 80*80 and you can scale the textures... Always go larger than what you want and never smaller unless you are mapping and applying to a model. With 2d at least... Always scale down or match scale. It avoids the graphics blurring.

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

    There is a cool wiki on chess programming of situations that could happen. Like en passant and ending up in check etc. There are a few cases that are difficult. Also some cool books on using bit fields to get the best speed.

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

      do you happen to have a link for the wiki (is it on wikipedia or something else?) im curious lol

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

      he also needs to get rid of that class hierarchy

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

    6:00 the initial position of the pieces is wrong! For both Black and White, the positions of King and Queen should be interchanged. White queen in the initial position is only on white square, and black queen is initially only on black square.
    Another way to have things correct, would be to keep the chessboard as it is (not rotate it in any way) but put the white pieces lower, and the Black pieces upper.

  • @peacewalker365
    @peacewalker365 3 ปีที่แล้ว

    This is what I'm looking for on TH-cam. Really learned a lot on writing clean codes. Thx!

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

    His best album yet, the code review

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

    Awesome glimpse into the mind of a professional. Thanks for the opportunity.

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

    Please more singing, I love it 😂

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

    Erstmal, Yan, cooles Video! I just keep learning from every video that you post. German game engine programmer here.

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

    I've seen some versions of online chess where if you click the king, you have to click the corresponding rook, and when you clicked the king, the corresponding rook highlighted, so that would likely have worked.

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

    Instead of using std::pair for points he could have just used SDL_Point provided by SDL. This would then also be compatible with some other SDL functions as they only accept SDL_Points.

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

    16:26, sure. It's less energy spent, less thing to write, read and think, since it has the same syntax as a pointer or class object evaluated against bool. Plus, if the boolean variable ever changes to a pointer by design, no refactoring will be needed here.
    23:45, since this pointer is not meant to move, it'd be better as a reference: safer, less typing and a visual hint.
    24:53, struct has better performance than tupple, because it doesn't get members by number. Generates much less bytecode too.
    30:45, literal numbers are dangerous due to this kind of thing. Right thing to do would be to has it attached to the screen size, either at compile time, like a global constant, or at runtime (in case of user being allowed to change it) as information from a class, calculated together with the screen size.
    36:25, bold security flaw here: this f() should not be public. If a piece goes to a wrong place, he'll has to look the entire project for calls to it. Fix: remove it from public domain, get a compile error, mark the f() who is calling it as 'friend', and only if it's actually 1 of the few that should be allowed to change piece location.
    38:40, a good design choice is to separate the character logic from its multimedia resources, so that its logic may go to the CPU caches, becoming much faster.

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

    I'm sure you will find this out later in the video, but castling seems to be possible by dragging the king to the rook rather than the square next to it. (:

    • @alexandrucalitescu5822
      @alexandrucalitescu5822 3 ปีที่แล้ว

      You reffer to the fact that he couldn't castle there in the first minutes of the video?

    • @Katt1n
      @Katt1n 3 ปีที่แล้ว

      @@alexandrucalitescu5822 Yeah. I didn't have time to watch the whole thing, but i thought i would point it out anyways.

    • @alexandrucalitescu5822
      @alexandrucalitescu5822 3 ปีที่แล้ว

      @@Katt1n Well there, he couldn't castle because you can't castle trough a line of check. The bishop was up there. And it was implemented in the game I think, it even lighted that line of check in order to show why the castle is not possible there.

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

      @@alexandrucalitescu5822 I understand the rules of chess, for the first few minutes of the video he implied that castling was not implemented which is not true.

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

    I need a full cover of hello right now Cherno!

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

    Also the starting position is wrong. The Queens always go at their color. D1 and D8 respectively for white and black queens.

  • @flamendless
    @flamendless 3 ปีที่แล้ว

    One thing ive noticed is that the board is not actually reversed when the white is on the top side, it's always the white king should be on a black square.

  • @Johnny-tw5pr
    @Johnny-tw5pr 3 ปีที่แล้ว +12

    Small tip: You shouldn't have 12 different images for each piece, instead put it all in one file and then crop that image accordingly. That's exactly how I made playing card games, imagine having to load 52 images separately lmao

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

      You load them only once per game so it shouldn't matter.

    • @Johnny-tw5pr
      @Johnny-tw5pr 2 ปีที่แล้ว +1

      @@smrtfasizmu6161 I'm just saying it's good practice to do that. What if it was 100 images?

    • @randomnessslayer
      @randomnessslayer 2 ปีที่แล้ว

      52 images??? Bruh it's 4 suits, 13 cards (so 13 ranks, 3 face cards, that's 20 image assets.
      Like if you're concerned about space and loading, make the images from those 20 components.
      Cache the cards as needed, 52 generated assets using 20 image assets.

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

    I wish you would make a video on how to build and distribute it, Because I too am having problems with that part of it...

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

    At 44 mins, i would even use std::array. Just use Point[] = {the squares}. Use array length macro which uses sizeof to iterate over them.

  • @mirkomasetti1367
    @mirkomasetti1367 3 ปีที่แล้ว

    With the Hello Again song you literally had me crying LOOOOL

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

    Cherno lowkey flexing his singing skills 😂

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

    great singing

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

    the singing was so on point i didn't realize it was you

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

    I wouldn't call cleanup in the destructor. It could throw exceptions and you should never have a destructor that throws

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

    that cpu core usage hack was cool !

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

    I wouldn't put any magic numbers in my code. They all should be a constant so it's clear, even that 8. But good job! :)

  • @smrtfasizmu6161
    @smrtfasizmu6161 3 ปีที่แล้ว

    When I made a chess program, I didn't instruct the computer to find all the legal moves in a position, instead I instructed it to wait for the player to make a move and then check whether the move is legal or not. I instructed the computer to make 4 checks to see whether a move is legal or not:
    1) Natural Movement of a piece (for instance you want to move a bishop, computer checks whether you are trying to move the bishop diagonally or not. If you try to move a rook, then computer checks whether you are trying to move the rook horizontally/ vertically or not, if you are trying to move the knight computer checks whether you are trying to move it in L shape or not etc.)
    2) Whether you are capturing your own piece
    3) Whether you are jumping over a piece
    4) Whether you are in check after your move (in chess you must not be in check after your own move).
    If those 4 checks are done then the move is legal and computer changes the location of the chess piece. If the move is illegal, then computer does nothing.

    • @sebastianweilhammer3101
      @sebastianweilhammer3101 2 ปีที่แล้ว

      If you want to creat visualisation's of possible moves as in this example you need to check before the move.

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

    King is placed wrongly. Black king needs to be in a white square, e8, not d8. White king needs to be in black square, e1, not d1

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

    Just an fyi, but you cannot castle out of check. That’s why you weren’t able to castle in the first game as black

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

    That singing was pretty good actually

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

    Honestly lack of castling isn't much of an issue, lack of en passant on the other hand would be absolutely barbaric

  • @BenDol90
    @BenDol90 3 ปีที่แล้ว

    LOL that Hello rendition was bomb

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

    The comment on "Initialize the field", I think it is a word-to-word translation from German. It would translate to "Intizialisiere das Feld" with "Feld" = "field" and means in this context the chessboard.
    So I guess it's just an unlucky translation on his part, I think he meant "Initialize the board" or something.

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

    31:19 didn't expect to see cyrillic here

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

      He speaks Russian

  • @arsdever8957
    @arsdever8957 3 ปีที่แล้ว

    First of all, the positioning of king and queen is reversed. Next, 6:04 you can castle. You had to release the mouse button on rook instead. See the blue background behind the rook.

  • @smrtfasizmu6161
    @smrtfasizmu6161 2 ปีที่แล้ว

    I am new to opengl and GLFW so the first project that I have done in C with openGL was a tic tac toe project, I put nothing on the heap there. OK, tic tac toe is a lot simpler than a chess app (I have made a chess app in Java), but I think that even if I were to make a chess app in C with opengl and GLFW I could just initialize all the objects for chess pieces in the function which contains the main loop (while (! glfwWindowShouldClose(window) loop) and I would put all the chess piece objects on the stack frame of this function which runs in its own thread (I would put it in a different thread). The stack frame of this function lasts as long as the window lasts. I don't think I need to put anything on the heap whatsoever. Even when dealing with promotion when a pawn becomes a queen/rook/knight/Bishop, I can still put that queen on the stack frame of the promotion function and then use memcpy to copy it into where the pawn used to be and that should work correctly as long as the size of the pawn object is bigger or equal to the size of the queen/rook/knight/Bishop object.
    My variables on the stack will last as long as the window of their chess board exists, their stack frame will exist as long as the main loop of their chess game exists, only after the main loop of that chess game is over, that function is over and leaveq CPU instruction is executed (leaveq is basically the same as add numberOfBytesInThisStackFrame, %rsp and then pop %rbp, I am talking about x86-64 architecture here)
    the stack frame of that function no longer exists.

  • @BenStJohn-un4ee
    @BenStJohn-un4ee 2 ปีที่แล้ว +1

    Thanks for an interesting code review, and nice polling fix!
    From a readability standpoint (and to some degree safety) I would have expected more feedback on the code duplication -- I like what you did for the knight moves loop, but would have taken it further, e.g. all of the x + dx > 7 && ... that is, you should do that once (x_new = x + dx) (even better with a point class) and then (OnBoard(p) && Free(p)).
    I think a bit more of an investigation into how you want to handle the polymorphism would have been interesting too.

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

    5:41 WAIT!!
    The board is set up incorrectly.
    Kings and queens are on the wrong squares.

  • @xhivo97
    @xhivo97 3 ปีที่แล้ว

    YES, please make the video on how to properly make a project on git.

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

    2:08
    YES YES YES PLZZZZZ SHOW US HOW TO BUILD PROJECTS AND DISTRIBUTE THEM PLZZZZZZZZ

  • @davidm.johnston8994
    @davidm.johnston8994 3 ปีที่แล้ว +1

    I would be super interested in a video about distributing c++ code, getting it to build. This has been my biggest pain point with getting into c++.

  • @gicacean
    @gicacean 3 ปีที่แล้ว

    A video on how to make a project would be really useful honestly

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

    Thank you Cherno. I learned a lot.

  • @oskardeeream1846
    @oskardeeream1846 2 ปีที่แล้ว

    I noticed the queen is on the E file when playing as black. They didn't flip where the pieces are drawn to the screen based on if you are playing as white or black

  • @Warmaster2143
    @Warmaster2143 3 ปีที่แล้ว

    Lol the singing at 2:27 was so cool and funny

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

    I would love to see a video on building C++ code :)

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

    2:27 That was amazing!

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

    When I'm writing code I like to use the principle of "least astonishment" when writing my comments.

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

    Great review and great Code overall!
    I want to deepen my C/C++ knowledge and was wondering about the tuple thing. I really like to use tuples (C#) when readability is given since you can name your tuple values, kinda sad about that

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

    Can we take a second to appreciate how good this code is for a beginner? Sure, there are some things to be improved, but this is quite remarkable. Well done!

  • @LaurentLaborde
    @LaurentLaborde 3 ปีที่แล้ว

    using SDL properly the RAII way is slightly more difficult. I do it that way :
    std::unique_ptr window {nullptr, &SDL_DestroyWindow};
    std::unique_ptr renderer {nullptr, &SDL_DestroyRenderer};

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

    OMG, the singing!! 😂😂 Epic!

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

    He did do castling, you just have to drag the king to the rook.

    • @felipegomes6312
      @felipegomes6312 2 ปีที่แล้ว

      no chess game castles this way, so he has to fix it anyway

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

      @@felipegomes6312 That one does.

  • @Waschlack
    @Waschlack 3 ปีที่แล้ว

    "Quelle" also means source, which kind of makes sense for the water thing too since thats where the water comes from

  • @sangamo38
    @sangamo38 2 ปีที่แล้ว

    Isn't there a callback system from every event. instead of polling, coz at once there is going to only one event. but that could be slow depending upon how the library handles callback. besides one more optimizations that can be done is to calculate all possible moves once and make a set of them and later update them depending upon actual moves made. not a huge deal but it will save time when user is clicking all over the place.

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

    Shocking switch language to cyrilic 31:18

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

    What a coincidence, I was looking for graphical libraries to make a chess game right as this video dropped.

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

    bro were you in a band? If that wasn't autotuned your voice is incredible. would def want to hear you release a single or something

  • @sundayschooldropout6641
    @sundayschooldropout6641 3 ปีที่แล้ว

    Subscribed after the singing🤣🤣🤣. I love this channel already

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

    Hey Cherno, please make a video dedicated to a polymorphism in cpp.

  • @h-0058
    @h-0058 3 ปีที่แล้ว +1

    Castle by clicking on the rook, not on the square next to it (in online chess usually both should work)
    Also, the king and the queen. For godness sake. Srsly?
    Nice project though

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

    1:58 when a C++ developers realizes that *no one, literally no one finds C++ building intuitive and understandable,* but acts annoyed and states that is everyone else's fault.
    EDIT : 2:55 "I tried to add SDL2, messed up everything" -- _every SDL C++ project ever_ for anyone who hasn't been a C++ programmer for at least 2 years.

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

    Why do you have a Cyrillic keyboard? Where are you from? :)

  • @smrtfasizmu6161
    @smrtfasizmu6161 2 ปีที่แล้ว

    I remember 3 months ago watching this and not being able to understand a lot of things, now I watched this and I understood almost everything Cherno said in this video. I studied Java and C in the meantime, I guess that helped for C++ understanding as well. Still, it is not quite clear to me what tulp is and some usages of :: I don't understand.
    I even get the frustration of cherno that this guy didn't put more things on the stack, if I were making a chess game in C I would put everything on the stack, I don't think I would call malloc even once. As long as I put my chess pieces in the same stack frame where the game loop is, I will not get a seg fault, because that stack frame is alive as long as the game is alive.

  • @natetolbert3671
    @natetolbert3671 2 ปีที่แล้ว

    @ ~2:10 (the line about making a vid on building cpp progs)
    More like a series. If you're wondering why nobody (new to cpp) understands it, take a look at the autotools documentation and you'll begin to understand.

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

    Quelle is also a source for the gospels according to some theories