Coding Adventure: Chess AI -

Coding Adventure: Chess AI

Sebastian Lague
Views: 895292
Like: 48180
My attempt at creating a little chess playing program!
Think you can beat it? Give it a go over here:

If you’d like to support the creation of more videos (and get early access to new content), I’d greatly appreciate the support here:

Project Source:

Learning Resources:

If you’re interested in a video about some weird and interesting chess strategies, I highly recommend taking a look at this video by suckerpinch (and all other videos on that channel too!)

00:00 The Board and Pieces
03:20 Generating Moves
06:54 A Random Adversary
07:52 Optimization and Testing
12:11 Search and Evaluation
17:43 Easy Endgames
20:00 The Transposition Table
23:03 Openings
25:09 Game One
26:06 Game Two
27:01 Game Three
28:05 Game Four

Devoted Mind by Wild Colors
Intuition by Lincoln Davis
Wonderland by Shimmer
Selfless by Eleven Tales
Floating Point by Roie Shpigler
Nobility by Wicked Cinema
A Quiet Place by Jordan White
Air by Assaf Ayalon
Heart Wide Open by Sounds Like Sander
Thoughts by Anbr
Deep Blue Sea by Sivan Talmor
Flight of the Inner Bird by Sivan Talmor
Kings and Queens by Wicked Cinema


  1. What program did you use to render the board?

  2. unfortunately, only a small selection of nerds will get to appreciate how funny you are 😀

  3. Sooo you spent a lot of time just to lose a match… right?

  4. This was recommended to me bc of the chess. I have absolutely no idea what just happened but I watched the whole 29 mins and I have to say I liked it. Idk what it was but it was cool

  5. this is awesome. i was half-expecting you to write the evaluation code in a compute shader complete with visualizations of the millions of moves it was simulating 😛

  6. ENjoyed the content…. Hope to see you fixed the last two issues you talked about soon. I agree, following the timeline is most important thing; still, I feel we can always find some room for it. Thanks for the stuff! Keep going 🙂

  7. i was hoping you finish the video with "how does this AI compete against existing AI f.e. the MS Chess-AI

  8. beating the computer using london, the computer got checkmated
    me: damn, I can't believe I beated it

  9. Artificial Intelligence WILL be humanity's downfall. Thank you for contributing to the most dangerous invention in history!

  10. And that's how stockfish for alone people who don't wanna get beaten up by a bot was creayed

  11. What code editor do you use?

  12. i just started the machine-learning courses on youtube and ,I don't want to be racist but, Indian guys are EVERYWHERE!!!! so yeah my accent is slowely turning to Indian..

  13. how can someone think of all this code and write it? I am so intimidated by that

  14. Hi, great video and very informative. I have a question, what program did you use? Thank you very much!

  15. Very nice video. The funny bugs and edits (like brokend screen) are awesome 😀 Good job

  16. I see you really changed the video and optimized the code, not?

  17. In the position at 19:57, please teach the computer to play Qb8# instead of Qd7#. If Eric Rosen and Ben Finegold have taught me anything it's that the queen is lazy and would like to travel as little as possible to deliver mate.

  18. what is your IDE? and whats the programming language that you used in the video?

  19. That bot's elo is roughly 1600 – not bad for something you created

    Good enough to beat me at least

  20. The answer to the chess puzzle at 2:30 is 1. Nf7 Kg8 2. Qe8 Qf8 3. Qxf8

  21. hi ,which language is it in and which compiler or ide are you using ?

  22. With alpha-beta pruning, wouldn't that stop the AI from doing useful sacrifices of valuable pieces that might later win them the game?

  23. 7:32 Black just hangged it's queen for like 15 moves and white didn't even take it.

  24. I have no idea what all that code says and how it functions, but it is somehow really entertaining to listen and also very interesting.
    Maybe one day I'll be able to understand what you are doing.

  25. Thank you for this concise but deep introduction to creating a chess AI. I myself coded a chess engine for once and now you made me eager to go back and improve things 😀

  26. As a chess player who studied computer science at university, I thank you for this video. While doing 3rd year courses, we did AI and the concepts you mentioned were really challenging yet enjoyable to me. I had a personal project back then, trying to code a chess playing program.
    I remember having to deal with legal moves, a chessboard world, etc. My program never got as far as yours. I created a number of search and path-finding applications just to better understand the concept, but I decided it would take too long to teach my AI about good moves vs bad. I thought I needed to be a GM myself in order to get it that far. I was not advanced enough to allow one AI to play against another, and the winner remembers what it learned. My knowledge of pruning, algorithms, searching and path finding was not enough to go further and so I abandoned the project.

  27. Hey,
    so, im trying to program a chess bot too, but im wondering what engine are you using?
    im relatively new to programming, so i dont know a lot of stuff.

  28. i love the way the things appear on the screen on your videos they look so nice to look at

  29. This makes my own coding skills feel severely inadequate.

  30. Hi, I'm just here to say that if u made bishop=3,25 instead of 3 it would be more accurate😉

  31. Hey everyone, hope you enjoy the video! Quick note – I noticed some slightly distracting compression issues after uploading, where squares of the chess board would sometimes blur together and flicker a bit. The only solution I could find was upscaling to 4k, so if you have the bandwidth I'd recommend watching in 1440 or 2160p.

    By the way if you'd like to play against the AI, you can find downloads here:
    And source code for the project is over here:

Leave a Reply

Your email address will not be published. Required fields are marked *