I Made a Weird Chess AI from Scratch
Вставка
- Опубліковано 25 чер 2024
- I made an algorithm that can play you in chess in Python. It uses the minimax algorithm with alpha-beta pruning. I ended up creating a custom chess engine for it that works okay.
I considered using Java and Javascript for this but decided against it for some reason. Another way to approach this is to use machine learning, neural networks, or some other form of artificial intelligence. This was a similar process to my tic tac toe video, which goes a lot more into the detail of how a program like this is made.
This video was loosely inspired by Code Bullet's "I Created an AI to Play Chess" video. The next video will be a Keeper devlog.
Follow me on Twitter! / nextprogramyt
Support me on Patreon! / nextprogram
Join the Discord! discord.me/nextprogram (if link doesn't work, check newer video)
(Next Program) - Розваги
This video took like 70 hours to make :)
😳 wow that’s very impressive. You clearly put lots of effort into your videos and I’m glad you’re getting the well deserved recognition!
Very big oof size
Good job!
Can u do a face reveal after 10k subs
#youtubeputallthisdudesvideosinrecommendedsohegetslotsofnewsubsbecauseheisawsomeandmakesamazingcontent that is hard to read
Ahh, the programmer's paradox: That which seems the simplest takes the longest and that which seems the hardest takes a minute.
clavesi very true
That's probably because computers are extremely good at what we are bad at, but extremely bad at what we are good at
"ah yeah, writing a function that checks for when a 'check mate' state occurs is gonna be easy, about 5 minutes"
Literally takes a week to do it
how dfq does that make any sense
Well, normally, unless you expect it to. Then it does what it seems like, so that when you pick the complex-seeming thing, it is complex.
“I made my own engine.”
You poor soul.
I'm making one too.
(I think I'm going insane please help me)
@@chappie3642 stop
For your own sanity
@@ptato3010 No he has to do it, to become a man.
@@tla9231 He's gonna die if he does! We can't loose another one... Not like this... Not like this...
@@ptato3010 It's too late, he already did it. Now he either dies or succeeds. It's for the greater good.
Great video! That little game you made called “chess” could definitely take off.
Yeah I think it has some potential haha
@@nextProgram I think it really benefits from its roots in the structure of old medieval governments, which should make it quite relatable for a lot of people from the western world. Perhaps you could make a similar version of it that could reel in more eastern cultures as well? You could call it "shogi".
@@nextProgram I sense sarcasm
CheSs is AlrEadY a gAmE yoU stUpId
Not The boi r/wooosh
*if(aboutToLose):*
*dont()*
The best code in existence, just don't forget your functions.
If(about To Win) :
do()
@@barrrakudam Functions/Variables do not have spaces, try using underscores. (_)
@@someone58932
if(aboutToWin):
do()
@@clonefighter1996 better
Fun fact, dont( ) is a recursive function 🤣
"95% of the time that a novice programmer complains that something is 'terrible to use', it's because they don't know what they're doing."
...
"Anyway, pygame is terrible to use."
lololol
To be fair could probably be waay wore beginner friendly
Just use pyglet instead of pygame
lelelelelelel
I don't like Java for exactly that reason lol
@@ekremdincel1505 What is pyglet? I've never heard of it
Imagine still playing Chess when Chess 2 has been out for years
Green Mario True
wait where
@@noyz-anything en.m.wikipedia.org/wiki/Chess_2:_The_Sequel
@@greenmario3011 Wait, are you saying D&D is not the sequel to chess?
@@rockman7perez Yea, dungeons and dragons is actually the sequel to snakes and ladders.
*Sees the thumbnail*
Me: This man is a genius.
Watches the video: Oh... never mind.
You see this, this content right here? Yeah it’s called quality content. Just saying
ez dub
He talked 5 minutes about bullshit that no one cares about and 1 minute about his program, how is this quality??
Don’t question it :)
As a person who has made a real chess engine, I can say that there's million things to add to this. For example AB-pruning, null move, bitboards, proper rules, transposition tables, opening books, uci protocol. And just switch to C++
I gave up in pain at 4 minutes. Did he mention perft?
@@joshuascholar3220 Oh god I remember that when I programmed an engine and it had so many random tiny errors in the move generation function, for example capturing en passant but then discovering an attack on your own king was somehow possible... Don't ask me...
okay nerd
/s
Searching null move now
When he talked about how he wrote the engine so quick it caused my physical pain considering how bad it is, great content though
When the title says scratch, but he doesn't make it using scratch
sad scratch noises
Was looking for this comment, someone should use scratch to do this
I'll probably end up doing it
It should take about 3 hours to make a decent chess move... but it will be worth it.
John Eaves
I made a 256 bit integer and it slows down at about 2000
Shinju Kim scratch is really bad tbh. It would take like 10 days to actually even make a really bad chess bot
SCRATCH IS GARBAGE!
This dude: What am I some kind of nerd?
Also this dude: *programs a chess engine from scratch *
that feeling when a chess ad plays before this chess video
🤔
@@nextProgram yes (insert that emoji) indeed
Google is spying on you lol.
@@aidanthird I think this vid only has 2 ads in the start and in the end ·-·
@@animationgamer3564 yes and the ad played right before this video
Please nerf the Queen, chess players haven't received any update for hundred years.
Hahahaha
Disenchantedcard GD Lol
Next time make a weird chess AI *IN* Scratch.
Mad Mew Mew cool,can you make a physics engine(I can’t)
Angry Pickle? _gestures vaguely at GriffPatch’s tutorial project_ (I think that’s the name)
Larree I know,I was just wondering how good she/he is
Mad Mew Mew so you’re not as good as you said
@Mad Mew Mew Chess is 100% possible in scratch and has been made several times in the last 10 years. Personally, I've made a full Texas Hold'em Poker emulator in it.
When will you upload the next devlog video
Hopefully in the next couple weeks!
I love how you called the bishop the fancy pawn
chess grandmaster watching those chess games be like:" pathetic"
I'm not a grandmaster but these games are advanced stupid. Like 3rd stage stupid.
When’s the next vid?
In a few weeks hopefully!
@@nextProgram ok :)
Was listening to Queen and saw this clicked on it straight away
Wow that's saying something
@@nextProgram its is, cant wait for next video
W
H
O
A
S
K
E
D
@@mateczink1026 not you i was saying it to @nextProgram
W
H
O
A
S
K
E
D
The thumbnail: “Oh yeah, it’s big brain time”
This reminds me a lot of a chess engine I made in high school, I went through a lot of the same steps as you did, although mine recognized checkmate by not playing when the evaluation passed the value of the king. It ended up much weaker than I had hoped, but it did beat one of my friends so I was happy. Thank you for your videos!
Wow I love your video! Interesting and funny too. The fancy pun got me the most xD
Glad you enjoyed it!
Just found this channel a few hours ago and now I've watched all your videos and subscribed. Hope you upload another video soon.
“Sorry that was a dumb intro”
You LIE!
it's always fun to find a new channel to watch
I should know, I'm subscribed to more than 750 of them
fun right
I recently did an assignment on game trees and AI. I used a minimax algorithm and I related so hard when you said “mentally preparing myself before looking at code”
This is so cool! I tried this project a couple weeks ago, but decided to quit since I know barely any python and know nothing about machine learning. Anyway, it’s cool to see someone who made it work.
So as someone with a little more experience programming and has even done a lot of work in pygame... Pygame sucks
Can confirm!
Yes
lwjgl is better
It doesn't suck, it really depends on what you are trying to do. Its just a simple drawing library basically, if that's what you need pygame will get you there pretty straight forward.
Nothing really "sucks" that works. It's just a matter of when to use it.
I’ve never had a real problem with it
"Chess" is going to be *revolutionary!*
I didn’t know this channel but it’s awesome . Congratulations man
Normally I don't like videos like these but this one I enjoy :) It's not overly dramatic with the jokes, you explain the issues you faced and sacrifices you had to take overall it's just a really humble video made by a transparent and honest creator. Not like most other youtubers who try to paint themselves under some perfect light. Well done!
"The fancy pawn" 😂🤣
2:51 "oh, BTW, this don't support moves like casting or l'passante... "
Me:I think that's ok, just start with the basics and-
"or checkmate"
Me: Wha..?
Can't wait to see your next video!! I really love your content and how good it is, it makes my day. Hoping to see you soon over here!
Thank you so much!
This is so impressive it’s insane! I love watching people code, it’s so satisfying.
Thanks :)
Nah, it was an ok intro
Make this ai a minigame in your game, and make it so it gives you a prize for beating it!!!!
Haha cool idea
yea some sort of an npc that won't let you pass till you beat him
@@nextProgram haha *_Do it_*
You are definitely a super underrated UA-camr. You should have triple the amount of subscribers
I just listen to your 4 last video, that's nice. You make easy explanation if I can say. It is fun to watch your progress in programming your game and you got a great voice to listen. Your game look nice but I hope to see some gameplay with enemy. Keep up the good works!
Thanks for watching!
"But then I decided that Python was better to use, because I found a library with an already made chess engine"
- nextProgram 2020
noice thumbnail, noicer video
Appreciate it!
this is great cause pogchamps is currently happening and youtube recommended your video to me, and it was good
It’s always nice to sit back and look at code you have created, and compare a compact algorithm to a class.. I like the patterns in the code c:
True!
that thumbnail haha love it
Yeah this video has been in development for months haha. I had a lot of time to come up with dumb jokes lol
UA-cam's algorithm blessed me with your channel.
Welcome!
I love the thumbnail: If about to lose, DONT
Cant wait tell next devlog
Soon!
“The horsey”
Me: it’s called a knight
“Fancy pawn that can’t jump over stuff”
That’s called a bishop
In my language it's actually called a horse lol
It's called a ponyhorse and bunnyrabbit
In German it's a jumper. Let that sink in
In Russian, a bishop is an elephant
You know your early when the video doesn't even have 500 views yet.
He's a smaller UA-camr, that's not really uncommon. It's 9hrs later and the video isn't at 3k yet.
Lol that thumbnail code perfect works everytime
There are so many game devs that are sprouting up and showing how they made their indie games and it's so cool to see. Welcome to the cool game devs table and keep trying new things cause that's how you get better and better :) 👍
where did you go? why you haven't uploaded videos for 4 months?
I'll be back soon!
@@nextProgram thanks
Damn this was cool and all man but... what’s a chess?
Lee Doyle Dude i wish i knew
pls continue to make these kind of videos
You’re awesome man! Already coming up on 10k subs?! Nice👌
"i cheched on yahoo and..."
*google.com*
LIAR
;)
As someone who just created a chess engine last week and made a whole program with python-chess, I'm happy seeing I'm not the only one struggling !
AI In the thumbnail: "IM GONNA LOSE!!!!!!" **tips over chess board**
Sweet man. Sweet. And I can totally sympathize with creating an environment for your agent taking more time than making the agent itself. Kudos man.
Absolutely!
thx for insight in chess programms
That is an amazing video! Thanks for all you work.
Thanks for watching!
nextProgram upload, must watch now
;)
What IDE do you use and what's your color theme, I really like it! Anyway, love your videos, keep at it.
You get 10k subs in 2 weeks....
That proves that your content is amazing
your content is amazing bro!
Felipe thanks!
The best part was the thumbnail which could be seen from outside the video
That thumbnail is one of the biggest memes I've ever seen. lol
"Now the ai can play a masterful game of chess"
*ai plays a5*
Good effort. I'm interested in making my own engine too.
this might be the best thumbnail ever!
Really good video, i just have a question, what python idle did you use? I use pycharm but this one seems really simple,
Thanks and have a great day
Lol that thumbnail was perfect!
where did you start learning on how to program?
no one did this before, great idea!
It finally releases!
Btw I implemented checking by going through each piece and seeing if any of those attack king(have kings position in their possible moves.) And sometimes your piece is pinned(cant move because it would put your king in check.) This is fairly easy to stop as well.
You just "let him" do the move and if your king is in check before blacks turn it is illegal move
I love your vids!keep doing what you do!!!!:)
Hey thanks!
Love chess... but also looking forward to the next DevLog :D
Coming soon!
Did you see SuckerPinch's video on 30 weird chess algorithms? This feels like a fun companion video to that. I have no doubt that UA-cam recommended this video to me because I have watched that one like 5 times. New sub!
Thanks, I'll check it out!
@@nextProgram It's delightful and hilarious. SuckerPinch is one of the most amazing programmers on youtube, and you should binge all his videos.
I made a chess AI using alpha beta without the pruning for a term project for an intro to cs class and I had the same experience getting the game to display and all the rules to work including the "fake rules" took the majority of the time where as throwing together the AI that made somewhat reasonable moves took very little time surprisingly. the main issue I had was adding any type of algorithm to my 3000 lines one file shit code was gonna be hell
nextProgram: Has a series on indie game development
also nextProgram: Dies programming chess
This was honestly harder lol
@@nextProgram Could've used Unity for it, too, especially since the AI code was so simple 😄
I thought this was going to be a weird chess AI in Scratch. now that would be impressive
Loving the content keep it up!
Appreciate it!
Good vid man. Also its not really a AI since it doesnt use any ml algorithms like neat etc. Its just ur brain that made that alg and applied it. Keep going mate good job
Congrats mate you doubled again!
You're like the code bullet but more polite
Haha that's good
Where has he gone?(>﹏
I love this kind of videos!
i was expecting it to be like if the ai is about to lose it flips the board or a gust of wind comes along
Have you considered uploading the code you used for everyone to take a look at?
If you continue this project, you should add a delay before the opponent's move to make it more realistic. Also, when a piece is moved, it should quickly slide across the screen to the chosen square. Nice vid :)
thx for the heart :D
Cool idea!
"The fancy pawn that can move diagonally but not jump over pieces." See now if we all described Bishops like this, Chess would be solved by now.
10 videos, 24k subscribers! Thats is amazing!! Please teach us your wisdom!
I wish i could use some more of that if statement...
I like thumbnail of the video saying: if about to lose - don't
I tried making a proper chess engine once. Like, with all the actual rules implemented. It was hell
what’s the stock music you use in this video?
What is your color scheme and theme for sublime text?
omg i love your vids! I feel like we are on the same page learning to make videogames and your vids inspire me to stop being lazy😂
that intro was beautiful
This is the type of inspiration i need in order to not give up on my game. I hate coding and as someone who has no idea what they're typing, I have to decide between the will to live and opening up Unity! Glad to see your hard work payed of for you!
Good luck!