CHESS! // Code Review

  Рет қаралды 237,127

The Cherno

The Cherno

Күн бұрын

Пікірлер: 445
@TheCherno
@TheCherno 2 жыл бұрын
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 2 жыл бұрын
Ready enjoyed the song lol
@iliasalaur
@iliasalaur 2 жыл бұрын
Слушай, как насчёт рассказать как ты переехал в Австралию?
@natetolbert3671
@natetolbert3671 2 жыл бұрын
I believe I'm owed some royalties. Sunglasses McCoolguyface is _my_ thing!😡... 🤪 😎😎😎
@natetolbert3671
@natetolbert3671 2 жыл бұрын
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 жыл бұрын
Oop is not the only way... It's just the only way that is _correct!_ again, 😂... No more, I promise.
@msid9870
@msid9870 2 жыл бұрын
Okay I didn't expect you to go this HARD on singing
@Keregosh
@Keregosh 2 жыл бұрын
It was so good as well!
@emty5526
@emty5526 2 жыл бұрын
@@Keregosh Did he use autotune?
@Keregosh
@Keregosh 2 жыл бұрын
@@emty5526 I have no idea xD
@matrixtoogood5601
@matrixtoogood5601 2 жыл бұрын
It was great! Except for the last bit
@creamy9626
@creamy9626 2 жыл бұрын
i sang along, it made my day!
@beautyofsylence
@beautyofsylence 2 жыл бұрын
When my man played the bong cloud I knew he was a man of culture ♟️
@Avighna
@Avighna 2 жыл бұрын
I'm into chess and programming and now I like him even more.
@josephreynolds7395
@josephreynolds7395 2 жыл бұрын
Cue Hikaru bongcloud speedrun intro.
@megaman2016
@megaman2016 2 жыл бұрын
Hahaha
@IronMaidzen
@IronMaidzen 2 жыл бұрын
SVG (Vector) Images are perfect for these kind of simple textures, small filesize and scalable and supported in SDL
@Dustyy01
@Dustyy01 2 жыл бұрын
Next video: How to build C++ projects and setup a git repo (Best clip btw: kzbin.infoUgkxtL5J8amsZAOkbza7ucYwc6EDEAQEaEQ7 )
@Danfranschwan2
@Danfranschwan2 2 жыл бұрын
This would be so important!
@cioccarellimi
@cioccarellimi 2 жыл бұрын
would be cool
@abhay29
@abhay29 2 жыл бұрын
Yes
@nobytes2
@nobytes2 2 жыл бұрын
Create new repo, clone locally. Create cpp project in another directory. Then copy entire project to the repo dir. Done.
@mr.mirror1213
@mr.mirror1213 2 жыл бұрын
I want this
@illiapyvovar8622
@illiapyvovar8622 2 жыл бұрын
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 2 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@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 жыл бұрын
I don't remember exactly my line of thought but you're right. Sorry for the confusion.
@basaramstefan3098
@basaramstefan3098 2 жыл бұрын
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 2 жыл бұрын
@@J3ekir Same lol
@lakshyarajsinghrathore1902
@lakshyarajsinghrathore1902 2 жыл бұрын
I too saw that.
@kalilinuxuser972
@kalilinuxuser972 2 жыл бұрын
Its not, its just turned around
@keyofdoornarutorscat
@keyofdoornarutorscat 2 жыл бұрын
@@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 😂
@stepanhrbek8151
@stepanhrbek8151 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
@@blablabla7796 the fundamentals of castling isn't to put your king behind the pawns in the corner and your rook into play?
@blablabla7796
@blablabla7796 2 жыл бұрын
@@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.
@APaleDot
@APaleDot 2 жыл бұрын
"What are we thinking... like, Bongcloud opening, probably?" Ah, I see you are a man of culture as well.
@kenan2386
@kenan2386 2 жыл бұрын
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 2 жыл бұрын
😅
@nobytes2
@nobytes2 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. 🤦‍♂️
@emphyriohazzl1510
@emphyriohazzl1510 2 жыл бұрын
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
@eliseimailat6715
@eliseimailat6715 Жыл бұрын
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!!!
@itsyourenotyour9101
@itsyourenotyour9101 2 жыл бұрын
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 11 ай бұрын
he also needs to get rid of that class hierarchy
@MizuFelix
@MizuFelix 4 ай бұрын
Erstmal, Yan, cooles Video! I just keep learning from every video that you post. German game engine programmer here.
@spamfilter32
@spamfilter32 2 жыл бұрын
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
@theuseraccountname
@theuseraccountname 2 жыл бұрын
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.
@gregorymorse8423
@gregorymorse8423 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?
@джамп
@джамп 2 жыл бұрын
This is so entertaining to watch as a programming student. I'm looking forward watching more code reviews 🧐
@AntoniGawlikowski
@AntoniGawlikowski 2 жыл бұрын
Best code review to date. Thanks!
@Katt1n
@Katt1n 2 жыл бұрын
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 2 жыл бұрын
You reffer to the fact that he couldn't castle there in the first minutes of the video?
@Katt1n
@Katt1n 2 жыл бұрын
@@alexandrucalitescu5822 Yeah. I didn't have time to watch the whole thing, but i thought i would point it out anyways.
@alexandrucalitescu5822
@alexandrucalitescu5822 2 жыл бұрын
@@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 2 жыл бұрын
@@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.
@tttm4rt1n49
@tttm4rt1n49 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.
@willuigi64
@willuigi64 2 жыл бұрын
I need a full cover of hello right now Cherno!
@szirsp
@szirsp 11 ай бұрын
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)
@onthepalehorse
@onthepalehorse 2 жыл бұрын
Why is no one talking about the fact the King and Queen are literally in the wrong squares
@K1L0W0G
@K1L0W0G Жыл бұрын
2:27 That was amazing!
@peacewalker365
@peacewalker365 2 жыл бұрын
This is what I'm looking for on KZbin. Really learned a lot on writing clean codes. Thx!
@kenan2386
@kenan2386 2 жыл бұрын
great singing
@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.
@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.
@BenStJohn-un4ee
@BenStJohn-un4ee 2 жыл бұрын
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.
@dariosfulful
@dariosfulful 2 жыл бұрын
Shocking switch language to cyrilic 31:18
@enes737
@enes737 8 ай бұрын
Thank you Cherno. I learned a lot.
@jassskmaster7575
@jassskmaster7575 2 жыл бұрын
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
@Brscheta
@Brscheta 2 жыл бұрын
he did castles hahaha You have to click the rook! :)
@schulz5patrick
@schulz5patrick 2 жыл бұрын
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
@Warmaster2143
@Warmaster2143 2 жыл бұрын
Lol the singing at 2:27 was so cool and funny
@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.
@nothingiseverperfect
@nothingiseverperfect 2 жыл бұрын
2:08 YES YES YES PLZZZZZ SHOW US HOW TO BUILD PROJECTS AND DISTRIBUTE THEM PLZZZZZZZZ
@xhivo97
@xhivo97 2 жыл бұрын
YES, please make the video on how to properly make a project on git.
@coopjmz9627
@coopjmz9627 2 жыл бұрын
Why do you have a Cyrillic keyboard? Where are you from? :)
@ultimatesoup
@ultimatesoup Жыл бұрын
I wouldn't call cleanup in the destructor. It could throw exceptions and you should never have a destructor that throws
@StephenAnimations
@StephenAnimations 2 ай бұрын
Quelle is also a source for the gospels according to some theories
@설리-o2w
@설리-o2w 2 жыл бұрын
Forget the code review was that really him singing holy beautiful voice am shocked so angelic.
@khyle402
@khyle402 2 жыл бұрын
looks like ed sheeran and sing like ed sheeran lol
@KostasOreopoulos
@KostasOreopoulos 2 жыл бұрын
Also the starting position is wrong. The Queens always go at their color. D1 and D8 respectively for white and black queens.
@beterax
@beterax Жыл бұрын
Singing was amazing! :D
@LaurentLaborde
@LaurentLaborde 2 жыл бұрын
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};
@oxyntes3536
@oxyntes3536 2 жыл бұрын
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
@craigyoung8008
@craigyoung8008 Ай бұрын
5:41 WAIT!! The board is set up incorrectly. Kings and queens are on the wrong squares.
@gulneckm.3475
@gulneckm.3475 2 жыл бұрын
2:12 Please, make video how to make repository, project AND as bonus, include how to back it up to drop box/google drive/one drive. use several servers(gitlab+github) so when data got corrupted it's easy to restore. 5:49 "bongcloud opening" PogChamp. I didn't expect cherno to be knowledgeable in current meta 5;56 I'm not that surprised Cherno didn't notice that OOO here is done by moving to king to rook, I'm surprised he missed he didn't check king's possible moves and missed castle move type 35:30, where castle was one of the move type and as result lots of edge cases were left unchecked (castling through check, castling after rook was moved, castling after king was moved, castling after pawn was promoted to the rook and returned the rook to the position where it could be castled).
@nobytes2
@nobytes2 2 жыл бұрын
If you're corrupting a git repo, you're using it wrong. The purpose of a repo is to have complete commit history. There's no need for Google drive. I would suggest that you keep a mirror for backup. Say you push to github, them maintain a mirror on gitlab or own gitea server.
@gulneckm.3475
@gulneckm.3475 2 жыл бұрын
@@nobytes2 Disk failures do not care if you are using git wrong or right. Redundant backups is one of the few things in IT which is not considered harmful and not using several free GB for that is overoptimistic at best. Also git is not a backup: one pushed --force too many and years of progress are gone(which you may discover months after the fact). Any proper workflow should strife towards complete elimination of human error at best, working around at least, because human errors are unavoidable by human nature. Saying "You should not have done this" does absolutely nothing to recover lost data. Clicking "unzip src-2017-11-09T13-14.zip here" does.
@nobytes2
@nobytes2 2 жыл бұрын
@@gulneckm.3475 Well git in a professional environment is a backup 100% because the servers are set with redundancy. The maintainer has control of the default branch. Everyone else should commit to a dev branch, and maintainer merges when ready. If you can force delete your entire code base you have a bad workflow already. If you've never worked with git in a professional environment which I can tell you haven't, I suggest you look up protected branches, and permissions per user. Having Google drive, or other backup sure that's fine as long as you keep git history. Best way is to have a mirror.
@rolandtrepesch276
@rolandtrepesch276 2 жыл бұрын
Thanks for this Interesting and good code review on code, application design and architecture! If you want to build and test a real chess game engine, you will need to add many specific rules, that are not obvious at first sight. It’s not only about adding castling and en-passant, you will also have to test and prepare specific little rules like drawing rules (draw after three-time-repetition, 50-moves-rule and draw through lack of material, even depending on who was to move at the given position, …). Properly implementing and testing these things can become challenging soon, as many of these constellations are not so easy to test and detect and might require specific knowledge, e.g. can you theoretically force a checkmate in a position like king and bishop vs king and knight.
@BenDol90
@BenDol90 2 жыл бұрын
LOL that Hello rendition was bomb
@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
@gicacean
@gicacean 2 жыл бұрын
A video on how to make a project would be really useful honestly
@BeansEnjoyer911
@BeansEnjoyer911 2 жыл бұрын
Please make the video on builds on cpp. And project structure! I work in c# and Haskell now so I’m actually quite rusty on cpp project structure
@genericcommenter1148
@genericcommenter1148 2 жыл бұрын
What a coincidence, I was looking for graphical libraries to make a chess game right as this video dropped.
@crusaderanimation6967
@crusaderanimation6967 2 жыл бұрын
2:07 I'm kinda interested in that.
@manasraut9825
@manasraut9825 2 жыл бұрын
Yess. Plzz make a video for building c++ projects
@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.
@FinBoyXD
@FinBoyXD 2 жыл бұрын
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 жыл бұрын
@@felipegomes6312 That one does.
@codechamp27
@codechamp27 2 жыл бұрын
I have been playing chess for 7 years till now. I have a AIM (Arena International Master) title.
@MrAman47
@MrAman47 2 жыл бұрын
Would love to see how you set up your build tools!
@arsdever8957
@arsdever8957 2 жыл бұрын
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 жыл бұрын
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.
@Danfranschwan2
@Danfranschwan2 2 жыл бұрын
very very educational! thank you
@dafdaf4052
@dafdaf4052 2 жыл бұрын
How to build a project/repo would be excellent, especially coming from you.
@michaelnichxls
@michaelnichxls 2 жыл бұрын
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
@mikefochtman7164
@mikefochtman7164 Жыл бұрын
Work in real-time programming of systems, and that while() loop that never released the CPU made me cringe!!! CPU7 never allowed to do anything. Good thing the 'SDL_PollEvent()' function doesn't lock some system resource while being called. Being called so often when there's no event to process could have potentially locked a vital resource away forever (beyond the CPU itself).
@llamasarus1
@llamasarus1 2 жыл бұрын
"I know a lot of people like to bash on object-oriented programming". I'm starting in game programming by using the OOP inheritence-based approach (in MonoGame) to clone 20 simple games then after that I will look into different software patterns when I make my own (hopefully) commercial game. Am I going down the right path (using the OOP approach) or am I better off dropping that altogether for a different pattern? It feels perfect for what small scale of games I'm making at the moment but I have nothing to compare it to and I hear people bash OOP so much and don't know if I'm going down the wrong path. What do you think?
@johnplays9654
@johnplays9654 2 ай бұрын
You can castle though
@h-0058
@h-0058 2 жыл бұрын
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
@viciousmagician4567
@viciousmagician4567 2 жыл бұрын
You definitely should make that video
@timlind3129
@timlind3129 Жыл бұрын
I don't even do game programming; but I love your videos!
@jonahy-m2099
@jonahy-m2099 2 жыл бұрын
PLEASE do make a build video
@MrTrollland
@MrTrollland 2 жыл бұрын
did u check how it handles pins?
@BradenBest
@BradenBest 2 жыл бұрын
22:56 I disagree with this and would even go as far as arguing that it's bad advice, and I'm going to spend the rest of this comment making the case for why you absolutely should make the comparison explicit. To your credit, you at least acknowledged that leaving the comparison in makes sense. So I guess if anyone wondered why exactly you would want the extra verbosity, you're about to find out. While you _can_ make the comparison of a character or pointer to zero by using implicit truthy/falsy semantics, it's more readable and less bug-prone (bugs from misinterpreting the intent and/or forgetting data types from lack of immediate context) to be clear about exactly what is expected, unless you are _literally_ dealing with integers that you only expect to have the value 0 or 1, like a function that returns 0 for failure or 1 for success; `if(is_valid(value)) ...` is perfectly OK, so is `while(simulation_step(...)) ;`. Otherwise, I strongly advise `ptr == NULL`, `chr == '\0'`, and `n == 0 or ENUMERATOR_CONSTANT` for pedantic clarity. Obviousness is ALWAYS an advantage. The more obvious the code, the better. So to use the code in the video as an example, just by looking at `clickedOn = game->getFieldPos(...);`, can _you_ tell what type clickedOn is? The answer is no. The context is missing, because it's like 20 lines up at the top of the function where the variable is declared, and over in another file where `Game::getFieldPos` is defined. And even then, sometimes people obscure types by overusing typedef (C++ even does this automatically). Ever seen someone typedef a struct or a pointer? Of course you have. So if clickedOn's type is not clear in the immediate context, and it may not even be clear at function scope context, then removing the `!= nullptr` check is an especially bad idea. Frankly, even if the use of an explicit comparison were to do NOTHING but tell human programmers that clickedOn is a pointer, that in itself is a huge reason to do it. And by removing it, you have just made the code less obvious, and thus harder to understand, and encouraged people to make their code harder to understand. Perhaps a counterexample would help: imagine you have an enum for return codes returned by an `int(...)` function, where 0 is ERR_OK, 1 is ERR_BADVALUE, etc. Taking the return value of that function and checking it as, say, `if(validate(value)) return 0;` would be atrocious. Yes, it'll compile and run, but who is going to read that and go "ah yes, the return value is non-zero so it's an error"? No, they're going to see it and think "so validate is returning successfully? Why is it making this function return failure? What the fuck?", look at the implementation, see it returns one of several ERR_* constants and be annoyed and salty. `if(validate(value) != ERR_OK) return 0;` is far more obvious.
@martinalcala4823
@martinalcala4823 2 жыл бұрын
The Queen must be on its color, at 5:36 Kings and Queens are swaped.
@Rikearon
@Rikearon 2 жыл бұрын
Great singing bro! Music channel coming!?!? 2:45
@martinalcala4823
@martinalcala4823 Ай бұрын
Does this consider castling, en passant?
@somuchdirt74
@somuchdirt74 2 жыл бұрын
1:58 Yep, would greatly appreciate a 'how to build' video.
@merseyviking
@merseyviking 2 жыл бұрын
Seems like death by OO. Or OO for OO's sake: "I absolutely have to use every new feature of C++xx!" Instead of going back to core C/C++ principles. I agree 100% with the Cherno's opinions - a few novice mistakes, but a large chunk of "I wouldn't have done it like that, but is otherwise ok".
@Gamerzhut
@Gamerzhut 2 жыл бұрын
Guys , HELP , how to run that code , I'm literally using SDL for first time to review that project , and I have some issues with running the project .
@gommito
@gommito 2 жыл бұрын
41:32 I see what you did there
@Spongman
@Spongman 2 жыл бұрын
can you promote by taking on the 7th rank?
@aburak621
@aburak621 2 жыл бұрын
The castle highlights when you hold queen are you sure you can not castle?
@thelazyguy3735
@thelazyguy3735 2 жыл бұрын
Honestly lack of castling isn't much of an issue, lack of en passant on the other hand would be absolutely barbaric
@JakobRobert00
@JakobRobert00 2 жыл бұрын
21:25 It kind of triggered me that you did not criticize the hardcoded 80 😂
@tiemanowo
@tiemanowo 2 жыл бұрын
28:24 or make it double resolution and game will look like retro pixel game :)
@yakryt7228
@yakryt7228 2 жыл бұрын
Code Review Musical is awesome!
@antoniogoncalves705
@antoniogoncalves705 2 жыл бұрын
2:45 I dont know what the fuck your doing in the IT world, you should be a super star
@EchoVids2u
@EchoVids2u 2 жыл бұрын
Cherno is a genious.
@DM-pg4iv
@DM-pg4iv 2 жыл бұрын
Structs are great.
@traywor
@traywor 2 жыл бұрын
28:12 allergies of cryptic code... No offense, my mind just fills in the gaps xD
@-abhinab
@-abhinab Жыл бұрын
what is on possion???? 8:08
@Ginto_O
@Ginto_O 2 ай бұрын
How did you do singing? Is that an AI?
@iNFaunTae
@iNFaunTae 2 жыл бұрын
you still cant castle if you put the king on the rook?
@samdash3216
@samdash3216 2 жыл бұрын
haha, I feel off the chair when you started singing ...
@trtrtri-18
@trtrtri-18 2 жыл бұрын
adu nice song
@TranscendentBen
@TranscendentBen 2 жыл бұрын
I'm about a third the way through and I'm seeing seeing something. Just about all code is in a class or object. I wonder if the author has been influenced by Java or a similar "everything's an object" environment and brought that concept with them into C++. I learned C++ coming from a C background, don't have such a strong affinity for classes/objects, and I don't see this, uh, "method" as the be-all and end-all for everything.
@trinculo58
@trinculo58 2 жыл бұрын
So Cherno often talks about performance of the Code. What would be a good way of learning what type of code is faster than other? I'm learning C# at the moment and have little to none experience with that so far. I asume a lot of it is just experience but if anyone has a hint on how to learn it. Thanks.
@jensnielsen8612
@jensnielsen8612 2 жыл бұрын
I'd recommend looking into big O notation.
I made it FASTER // Code Review
38:46
The Cherno
Рет қаралды 539 М.
INSANE 10,000 Elo Chess Bot
30:02
GothamChess
Рет қаралды 655 М.
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 30 МЛН
Остановили аттракцион из-за дочки!
00:42
Victoria Portfolio
Рет қаралды 3,7 МЛН
Win This Dodgeball Game or DIE…
00:36
Alan Chikin Chow
Рет қаралды 36 МЛН
All about MEMORY // Code Review
33:42
The Cherno
Рет қаралды 165 М.
Making Minecraft from scratch in 48 hours (NO GAME ENGINE)
16:38
I Rewrote This Entire Main File // Code Review
16:08
The Cherno
Рет қаралды 159 М.
Can THIS win Sebastian Lague's Chess challenge?
10:11
Game Tech Explained
Рет қаралды 200 М.
The WORST BUG in my Game Engine
15:29
The Cherno
Рет қаралды 45 М.
Programming Languages I used at Google (C++ rant)
6:14
NeetCodeIO
Рет қаралды 93 М.
When You Ask the Intern to Review Your Code
4:01
Nicholas T.
Рет қаралды 591 М.
You dont know OOP
50:48
ThePrimeTime
Рет қаралды 334 М.
BINARY vs TEXT File Serialization
13:49
The Cherno
Рет қаралды 52 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 787 М.