As a developer and a lifelong chess lover, this video made me happy! Your pacing was simple, easy to understand and though the ideas were complex, you demonstrated and explained them in a neat and organized fashion. Cheers my friend - looking forward to the next one!
Damn, I felt like the video had just started, and then boom, it's already over. If you keep up the style/quality, you definitely have a future among the greats of video essays on programming/CS
@@ahmoin freya Holmer, Tsoding, Sebastian Lague, mattkc, no boilerplate, 3blue1brown, fasterthanlime And these are just the ones that came to mind first, there are many others
I love how walked through implementing the minimax algorithm - the whole explanation felt very natural in the way you explained it, and the animation adding the bits of code was lovely because that's exactly how implementation unfolds. Great work!
I was confused by the King placement evaluation since those values would quickly have the opposite gradation as pieces are traded off. This type of value assumption based on board placement would have to be dynamically evaluated and not taken as a static truth.
This is usually solved by having two king placement tables: one for opening/middle game and one for the endgame. One then computes something like a number for "endgame-ness" (might be based on the number of pieces left) that smoothly interpolates between the two tables.
The heuristic for evaluation is still primitive which is why neural networks have significantly improved modern engines. Also bishop pair, passed pawns, controling open files, etc should go into a strong heuristic. What is described here is primitive compared to state of the art. Also a position isn't merely 64 bits as having castling ability, move repetitions, 50 move rule, en pessante are also part of the game state. These nuances arent as important but they are amplified when engines play each other. Unless a mathematically perfect evaluation function is found such that chess is solved, maching learning is of course the most powerful modern statistical tool which is why it has become nearly universal in production engines. In general the strength of the eval function might be more important than efficient raw calculation as time is better spent. The interaction of pieces is more important than simple criterion. Its likely worth looking into how stockfish does the eval in non NNUE builds because it has one of the most nuanced heuristics imaginable.
This is just amazing. I was fascinated most by how the board conveniently fit into an int64 and how from there everything just rolled as mathematics. Matrix multiplication in particular.
Friendly reminder that certain kinds of matrix multiplications have become faster with AI recently finding a new method, a mathematician taking that to the next level, and then AI improving it once more.
After watching this video, so many "informative" programming related videos seem so over the top edited or cinematic. I don't want a dramatic intro or unnecessarily upbeat music. I want THIS
Great video! It was in a style somewhat similar to Sebastian but with his personality. It would be interesting to see the game 2048 being dissected by the expectimax algorithm or monte carlo.
can you tell me how do you do your presentation( the video you showed) I need to present my project about the same topic and I don t know how to start?
I think it would be interesting to go over how to make the min max processing multi-threaded and in a compiled language. Fundamentally this was a beautiful video, and python was an excellent choice to show the algorithm at a high level, but a practical engine would need to be scalable and take advantage of as many cpu cores as possible. Keep up the good work!
Functionally, there's no difference to a compiled language - the executable would just be faster. Multithreading is, unsurprisngly, hard to implement - the current best chess engine (Stockfish) uses a method called lazy SMP, which starts each thread on the same start position but gives them all access to the same shared transposition table. Very slight deviations in CPU time that each thread will have (due to unpredictable kernel scheduling) will cause some threads to reach positions slightly earlier than others and write the result into the table. This means that the other threads that reach that position microseconds later will just take the value in the table instead of searching it. These slight differences in what positions each thread searches quickly add up, meaning the threads quickly start searching completely different parts of the whole possible minimax tree.
I once implemented a minmax algorithm for Tic Tac Toe in Python, its quite simple to implement, the hardest part of a program like this is making it efficient and implementing a good eval function, neither of which my Tic Tac Toe AI needed since it could simply exhaust all possible moves. The thing I've been more curious about is not necessarily the conceptual part of the engine, but rather how you would go about making a engine that could, potentially, work with programs like Chessbase and participate in competitions like TCEC. If you make your own Chess program, doing a working engine is relatively simple, but making a engine that can work with programs and APIs made by other people I don't really know much about.
If interested, I can link you to a couple of Chess programming Discord servers with seasoned authors willing to help. Creating a good Chess engine can be hard--- much harder than writing minimax for tic-tac-toe. Even plain Minimax (with no optimization) can solve tic-tac-toe in seconds, building a table that maps positions to best moves. A tic-tac-toe AI doesn't even need to search the game tree more than once. However, the game tree complexity of Chess is so high that we will all be dead long before the game is solved. A Chess AI must search the game tree during the midgame, and optimization there is critical.
The primary issue with the minimax algorithm is its inefficiency in terms of time, especially when applied to a game like chess. Given that even at a depth of 3, chess presents millions of potential move combinations, the algorithm becomes impractically slow. Additionally, it's my belief that pruning does not significantly mitigate this problem.
There are a bunch of small computer science channels out there with really well-made videos that are ready to blow up, and I'm all for it. Best of luck, if that's your goal. Lovely video
how do you only have 166 subscribers!? you have made the concept easily understandable and presented it better than channels with 100x-1000x your subs. amazing!!!!
when i saw the length of the video, i thought to myself "alright what can he really teach me about chess programming in 6 mins lol lemme see" and these 6 mins felt like 1 min and 60 mins at the same time. So much info stuffed so precisely and explaining it in such calm and simplistic manner, kuddos man!🙌
Really nicely produced video 👍 recently created chess in c++ and have been interested in engines, I realised how inefficient an array would be and had no idea about this method, I’d been using fen notation. Also, Well deserved channel growth 🎉 👏
Video was great. Background piano was cringe. Why the fake video essay and fake "dramatic" feel? No need to be "beautiful" with your video. It's annoying.
Nice video although min/max won't help you if a sacrifice yields material advantage (or checkmate) at a depth greater than the depth you search the chess tree. In other words, a chess tree branch might be pruned as yielding nothing useful when in fact, going a bit deeper, the tree branch pruned might have been a deep sacrifice for material gain or checkmate. But admittedly such "GM Mikhail Tal" moves are rare, so a low-depth alpha-beta min/max algorithm indeed makes for a relatively strong chess engine, all things being equal.
Wow! Ok Bartek, just want to say thank you. Not just for the video but for the raw inspiration. I’ve got a learning engine to build, which like your chess engine, needs to be able to strategize on how to best position a learner for further strategic positions. So the challenge is to design the engine to provide the learner with a weighted numerical map of where they might want to head to learn more things. This way a learner can try to grasp the rabbit holes they can possibly traverse, prior to traversing them and strategize as they see fit for themselves. I have to do this in a more 3d type of board, but the principle is the same. So THANK YOU for the nudge I needed to just start building this as an engine. I owe you a beer/coffee/highFive!
it feels like a very dry subject.. either you spend years fine tuning a pipeline you've built through experimentation or you implement some known algorithms and/or neural networks and call it a day, all just for watching a computer play chess at slightly more incomprehensible levels than before unless you do it competitively/professionally, I don't see the thrill and as for the programming techniques, at least most of what was discussed in the first part should be obvious if you have programmed for some time
I had a ZX81 in the mid-80s and had a chess game on it that was only 1k in memory. It always amazed me how they managed to programme a chess game into such a tiny amount of memory. Modern programmers could probably learn a lot from those tiny memory constraints.
While programming a computer/engine to evaluate chess, some things needs to be taken into consideration. One crucial factor is mobility of pieces. Stronger the piece is placed (depends on how many squares it controls), better is the position for that side. Also, though brute force algorithm would be required for evaluating the position, but to make the engine take lesser time, candidate moves can be programed via recursion. Surely not easy, but as a programmer, that can well be done.
THIS VIDEO WAS LIKE THIS „!!“ BRILLIANT. As a chess lover and young programmer I found it amazing how you explained and visualized everything. Also the sound effects your voice and your explanation itself. I would love to see a continuation or a deeper analysis
Since you're already using a float and a win is the best possible position, wouldnt it make much more sense to use Inf as the evaluation for a win position? (And -Inf for loss ofc)
The video was very nice. Calming, informative, and inspiring. I love Sebastians videos too and i definitiely saw some of what i see in his videos in this one.
I really love your animation with motion canvas. I am working on learning motion canvas in order to make code challenge tutorials. Do you have a github repo that shows the code you used to create the animation? It would help me learn how you created the animation. Thanks.
Isn't it a bad idea to prune immediately, because if you have a position that sacrifices a piece to gain a better piece, or a win, that path would be pruned because of the sacrifice, if you don't search it deep enough?
The evaluation is, in my opinion inherently wrong since it only takes into account some very basic tips we teach children that are just starting out but that lose almist all relevence when you become even an intermediate player.
Is there any benefit to be gained from representing bitboards in even more compressed ways? For example, there is only one king per player, and he can only be in one of 64 squares, so you can represent him in a 6-bit number. Same for the other king, and the queen. And all other pieces. You could use a 6 × 32 pieces = 192-bit number, or just 3 int64s instead of 12 int64s, to represent the entire board.
Unfortunately that would break the idea of using Bitboards. For example, in move generation, Bitboards can be used to create occupancy masks by ANDing all the bitboards together.
Subscribed! This intro to chess engine development was very interesting, and I loved how you implemented the minimax algorithm into it. Maybe next time you could use genetic algorithm for the engine, using optimized material as heuristics?
the fact that this channel has.... huh! wait, it was 17 just 6 months ago, and now, I see 11k subscribers! This fact is bewildering, perplexing, and puzzling and.... don't know what to say. Exponential growth like this 🤯
Wonderful video. I loved how you walked through your processes in making this. Wished it was a bit longer/more in-depth, but that's just a personal preference.
It's fairly demanding writing a chess engine and certainly isn't for everyone. My own little program (bikesandkites Fun Chess) plays moderately well and looks quite sweet but it took far more time than I anticipated. It doesn't use bit moves so that does impact it's strength but it destroys most people, including me, fairly easily.
As a developer and a lifelong chess lover, this video made me happy! Your pacing was simple, easy to understand and though the ideas were complex, you demonstrated and explained them in a neat and organized fashion. Cheers my friend - looking forward to the next one!
the fact that this channel has 17 subscribers is bewildering, perplexing, and puzzling for me
the fact that this channel has 125 subscribers is bewildering, perplexing, and puzzling for me
the fact that this channel has 212 subscribers is bewildering, perplexing, and puzzling for me
the fact that this channel has 217 subscribers is bewildering, perplexing, and puzzling for me.
the fact that this channel has 287 subscribers is bewildering, perplexing, and puzzling for me
the fact that this channel has 313 subscribers is bewildering, perplexing, and puzzling for me
Damn, I felt like the video had just started, and then boom, it's already over.
If you keep up the style/quality, you definitely have a future among the greats of video essays on programming/CS
Yes, this whole video was mesmerizing. I was expecting at least twenty minutes. So good.
@@ahmoin freya Holmer, Tsoding, Sebastian Lague, mattkc, no boilerplate, 3blue1brown, fasterthanlime
And these are just the ones that came to mind first, there are many others
I love how walked through implementing the minimax algorithm - the whole explanation felt very natural in the way you explained it, and the animation adding the bits of code was lovely because that's exactly how implementation unfolds. Great work!
Fully agree! The code editing animations is great!
I give this video a high evaluation score for the youtube algorithm.
haha thanks 😅
Thank you for wishing me a happy day :) I also wish you and whoever reads this comment a happy day!
I was confused by the King placement evaluation since those values would quickly have the opposite gradation as pieces are traded off. This type of value assumption based on board placement would have to be dynamically evaluated and not taken as a static truth.
This is usually solved by having two king placement tables: one for opening/middle game and one for the endgame. One then computes something like a number for "endgame-ness" (might be based on the number of pieces left) that smoothly interpolates between the two tables.
This was a very well made video! I couldn't believe in the amount of subscribers you had because your production is top notch!
A lot of obscure channels with high quality videos have been appearing in my feed, and I'm all for it.
I always enjoy hearing of new ways to apply bitwise operators.
I am seeing this after learning Hello world in Python
The heuristic for evaluation is still primitive which is why neural networks have significantly improved modern engines. Also bishop pair, passed pawns, controling open files, etc should go into a strong heuristic. What is described here is primitive compared to state of the art. Also a position isn't merely 64 bits as having castling ability, move repetitions, 50 move rule, en pessante are also part of the game state. These nuances arent as important but they are amplified when engines play each other. Unless a mathematically perfect evaluation function is found such that chess is solved, maching learning is of course the most powerful modern statistical tool which is why it has become nearly universal in production engines. In general the strength of the eval function might be more important than efficient raw calculation as time is better spent. The interaction of pieces is more important than simple criterion. Its likely worth looking into how stockfish does the eval in non NNUE builds because it has one of the most nuanced heuristics imaginable.
May I ask what video editor are you using to make those animations?
Love it, kudos to your whole effort. Peace.
Great video thank you, I thought you would show a demo at the end of the video, but anyway keep up the excellent work.
Can you explain how does the neural network work? I have heard that Stockfish 16 uses one
This video is ridiculously brillant... This is so clean, well explained, and the purpose is so exciting
Great video. Can you please tell me what program/software do you use for creating these visuals/animations?
Its almost all Motion Canvas along with some Davinci Resolve/After Effects :)
Very nice video, and it shows that a lot of effort went into it. Congrats!
man if this video was 10 hours long I would certainly watch it all 😂
This is just amazing.
I was fascinated most by how the board conveniently fit into an int64 and how from there everything just rolled as mathematics. Matrix multiplication in particular.
Friendly reminder that certain kinds of matrix multiplications have become faster with AI recently finding a new method, a mathematician taking that to the next level, and then AI improving it once more.
Could you do a similar video for Dou Shou Qi (Jungle) ?
After watching this video, so many "informative" programming related videos seem so over the top edited or cinematic. I don't want a dramatic intro or unnecessarily upbeat music. I want THIS
Great video! It was in a style somewhat similar to Sebastian but with his personality. It would be interesting to see the game 2048 being dissected by the expectimax algorithm or monte carlo.
Indeed.. 2048 is a fun game!
can you tell me how do you do your presentation( the video you showed) I need to present my project about the same topic and I don t know how to start?
Made with motion canvas, check description
Incredible visualizations, love this so much
I think it would be interesting to go over how to make the min max processing multi-threaded and in a compiled language. Fundamentally this was a beautiful video, and python was an excellent choice to show the algorithm at a high level, but a practical engine would need to be scalable and take advantage of as many cpu cores as possible. Keep up the good work!
Functionally, there's no difference to a compiled language - the executable would just be faster.
Multithreading is, unsurprisngly, hard to implement - the current best chess engine (Stockfish) uses a method called lazy SMP, which starts each thread on the same start position but gives them all access to the same shared transposition table. Very slight deviations in CPU time that each thread will have (due to unpredictable kernel scheduling) will cause some threads to reach positions slightly earlier than others and write the result into the table. This means that the other threads that reach that position microseconds later will just take the value in the table instead of searching it. These slight differences in what positions each thread searches quickly add up, meaning the threads quickly start searching completely different parts of the whole possible minimax tree.
Oh wow that’s actually really cool! Having a shared memory cache is actually quite nifty here. Thanks for sharing 🔥🔥🔥
I once implemented a minmax algorithm for Tic Tac Toe in Python, its quite simple to implement, the hardest part of a program like this is making it efficient and implementing a good eval function, neither of which my Tic Tac Toe AI needed since it could simply exhaust all possible moves. The thing I've been more curious about is not necessarily the conceptual part of the engine, but rather how you would go about making a engine that could, potentially, work with programs like Chessbase and participate in competitions like TCEC. If you make your own Chess program, doing a working engine is relatively simple, but making a engine that can work with programs and APIs made by other people I don't really know much about.
If interested, I can link you to a couple of Chess programming Discord servers with seasoned authors willing to help.
Creating a good Chess engine can be hard--- much harder than writing minimax for tic-tac-toe. Even plain Minimax (with no optimization) can solve tic-tac-toe in seconds, building a table that maps positions to best moves. A tic-tac-toe AI doesn't even need to search the game tree more than once.
However, the game tree complexity of Chess is so high that we will all be dead long before the game is solved. A Chess AI must search the game tree during the midgame, and optimization there is critical.
Wow. Im a software developer and hearing you explain something so complex in such a simple way is a freaking gift. Hats off to you sir.
The primary issue with the minimax algorithm is its inefficiency in terms of time, especially when applied to a game like chess. Given that even at a depth of 3, chess presents millions of potential move combinations, the algorithm becomes impractically slow. Additionally, it's my belief that pruning does not significantly mitigate this problem.
Informative video, really enjoyed it! Keep it up
Great video. Keep doing java ones too 😂❤
what do you use to create graphics?
I use Motion Canvas and a bit of Davinci Resolve :)
@@BartekSpitzaVery nice work. Loved the video. =]
There are a bunch of small computer science channels out there with really well-made videos that are ready to blow up, and I'm all for it.
Best of luck, if that's your goal. Lovely video
As a CS graduate, I love seeing the concepts we learned applied to real world things like chess.
Fascinating stuff
What a wonderful coincidence that chess has 64 squares and a large integer has 64 bits 🥰
It really is 😅
@@BartekSpitza ruclips.net/video/R-3qm5W__ug/видео.htmlsi=UdCrYFEMNnJ0bAQ6&t=8
how do you only have 166 subscribers!? you have made the concept easily understandable and presented it better than channels with 100x-1000x your subs. amazing!!!!
when i saw the length of the video, i thought to myself "alright what can he really teach me about chess programming in 6 mins lol lemme see" and these 6 mins felt like 1 min and 60 mins at the same time. So much info stuffed so precisely and explaining it in such calm and simplistic manner, kuddos man!🙌
Really nicely produced video 👍 recently created chess in c++ and have been interested in engines, I realised how inefficient an array would be and had no idea about this method, I’d been using fen notation. Also, Well deserved channel growth 🎉 👏
Video was great. Background piano was cringe. Why the fake video essay and fake "dramatic" feel? No need to be "beautiful" with your video. It's annoying.
Good job. Have you implement perft, transposition table as well?
underrated channel
Your chess engine have really big chess problem, but, it’s good vidéo, you get subscriber ❤️
Nice video although min/max won't help you if a sacrifice yields material advantage (or checkmate) at a depth greater than the depth you search the chess tree. In other words, a chess tree branch might be pruned as yielding nothing useful when in fact, going a bit deeper, the tree branch pruned might have been a deep sacrifice for material gain or checkmate. But admittedly such "GM Mikhail Tal" moves are rare, so a low-depth alpha-beta min/max algorithm indeed makes for a relatively strong chess engine, all things being equal.
Wow! Ok Bartek, just want to say thank you. Not just for the video but for the raw inspiration. I’ve got a learning engine to build, which like your chess engine, needs to be able to strategize on how to best position a learner for further strategic positions. So the challenge is to design the engine to provide the learner with a weighted numerical map of where they might want to head to learn more things. This way a learner can try to grasp the rabbit holes they can possibly traverse, prior to traversing them and strategize as they see fit for themselves. I have to do this in a more 3d type of board, but the principle is the same. So THANK YOU for the nudge I needed to just start building this as an engine. I owe you a beer/coffee/highFive!
it feels like a very dry subject.. either you spend years fine tuning a pipeline you've built through experimentation or you implement some known algorithms and/or neural networks and call it a day, all just for watching a computer play chess at slightly more incomprehensible levels than before
unless you do it competitively/professionally, I don't see the thrill and as for the programming techniques, at least most of what was discussed in the first part should be obvious if you have programmed for some time
I had a ZX81 in the mid-80s and had a chess game on it that was only 1k in memory. It always amazed me how they managed to programme a chess game into such a tiny amount of memory. Modern programmers could probably learn a lot from those tiny memory constraints.
While programming a computer/engine to evaluate chess, some things needs to be taken into consideration. One crucial factor is mobility of pieces. Stronger the piece is placed (depends on how many squares it controls), better is the position for that side. Also, though brute force algorithm would be required for evaluating the position, but to make the engine take lesser time, candidate moves can be programed via recursion. Surely not easy, but as a programmer, that can well be done.
These are very basic techniques known in the eighties. You add no value.
THIS VIDEO WAS LIKE THIS „!!“ BRILLIANT. As a chess lover and young programmer I found it amazing how you explained and visualized everything. Also the sound effects your voice and your explanation itself. I would love to see a continuation or a deeper analysis
Hey, how did you create the animations for this video? Its so smooth!
Since you're already using a float and a win is the best possible position, wouldnt it make much more sense to use Inf as the evaluation for a win position? (And -Inf for loss ofc)
How strong would such a simple engine (that takes into account only the position-adjusted material value of the pieces) be in practice?
The video was very nice. Calming, informative, and inspiring. I love Sebastians videos too and i definitiely saw some of what i see in his videos in this one.
Wow, I hadn't heard this song before. I love your taste in music.
I barely know anything about programming but this is a really cool video!
I really love your animation with motion canvas. I am working on learning motion canvas in order to make code challenge tutorials. Do you have a github repo that shows the code you used to create the animation? It would help me learn how you created the animation. Thanks.
Dude! Really nice vid. You explain the concept in simple terms without all the unnecessary details. Looking forward to more of that!
The fact that this channel has 11.1k subscribera only is indeed surprising.
I had a hard time following why that pruning optimization was possible. I rewatched it and got it.
I would love to see some simple game's program inside. this one is to complicated for me right now. after 3min my brain lefts xd
I liked the video, but if each position is a "bit" how do you program how pieces can move?
Isn't it a bad idea to prune immediately, because if you have a position that sacrifices a piece to gain a better piece, or a win, that path would be pruned because of the sacrifice, if you don't search it deep enough?
now I understand how chess evaluation works.
2:13 capturing pieces is good but in that specific position it as M2
The video ended so abruptly 😩 i for some reason expected to hear about more advanced chess algorithms, at least in general terms
Great video, but what you needed is playing against your engine at the end.
Im early and I know this will get 1 million views one day so I want to claim my spot
I got 3blue1brown vibes from the editing, very nice to look at
The evaluation is, in my opinion inherently wrong since it only takes into account some very basic tips we teach children that are just starting out but that lose almist all relevence when you become even an intermediate player.
I know nothing about coding, not much about chess aside from the movement but this video came to my recommendations at random. It was interesting
make for ludu game
Like comment subscribe to pump the algorithm you know how it goes 🎉
this gave me some ideas of how to mKe an engine for a local boad game played in my country.
Are we sure this guy didn't reupload from someone else? This is good for this less subs
Is there any benefit to be gained from representing bitboards in even more compressed ways?
For example, there is only one king per player, and he can only be in one of 64 squares, so you can represent him in a 6-bit number. Same for the other king, and the queen. And all other pieces. You could use a 6 × 32 pieces = 192-bit number, or just 3 int64s instead of 12 int64s, to represent the entire board.
Unfortunately that would break the idea of using Bitboards. For example, in move generation, Bitboards can be used to create occupancy masks by ANDing all the bitboards together.
How on earth do you run the code lol. Don't think the average person knows how to do this.
does anyone know how this guy creates his videos the animation style is super cool and id like to know
Can I get the SVG of video's thumbnail?
Very nice explaaanation video and Also Music Thanks
Reminds me of the Sebastian Lague video, great content :D
i swear theres a youtuber with a similar animation as you, I forgot their channel name
I never thought about the fact that the board could be described as a set of 64 bit words.
Subscribed! This intro to chess engine development was very interesting, and I loved how you implemented the minimax algorithm into it. Maybe next time you could use genetic algorithm for the engine, using optimized material as heuristics?
Can you make a video tutorial on coding and how to make a chess engine better
Very nice project, impressive. I use chess engines to generate chess movies...
Great Video! Can you estimate how strong your AI is?
Great video!! 😲What program did you use to animate this video?
Bravo. I'm a terrible programmer so I admire this so much!
How do you make such animations . Can someone tell ?
the fact that this channel has.... huh! wait, it was 17 just 6 months ago, and now, I see 11k subscribers! This fact is bewildering, perplexing, and puzzling and.... don't know what to say. Exponential growth like this 🤯
वास्तव में यह हैरान करने वाला, भ्रमित करने वाला और बहुत आश्चर्यजनक है।
I got a lot of satisfactioncy from the word "elegancy".
Wish you a happy day . On my way to make a chess engine.
Amazing video, How did you make those animations ?
Beautiful video
How does he make these animations and graphics?
The fact that this channel has 1.62 k subscribers is bewildering, puzzling and perplexing for me😊
Could you let us know what editing software did you used?
Wonderful video. I loved how you walked through your processes in making this. Wished it was a bit longer/more in-depth, but that's just a personal preference.
It's fairly demanding writing a chess engine and certainly isn't for everyone. My own little program (bikesandkites Fun Chess) plays moderately well and looks quite sweet but it took far more time than I anticipated. It doesn't use bit moves so that does impact it's strength but it destroys most people, including me, fairly easily.
How you create the vizualiizations?
I Wish you happy day too mate 😊 as well as hell of a lot more subscribers, what?? I hate yt algorithm... Btw awesome video, thanks