The PROPER Chess Game, Not a Rip Off

hey guys, I know that this sounds crazy impossible but i really want to make a proper chess game. Like proper. Not multiplayer but like an ai bot that can see forks pins, and can predict checkmates to make the best possible moves. We would need to make a piece know if it is in danger of being taken and have a variable for that so that the bot would take your piece in a situation but would always take the best piece meaning the pieces have to be ranked in a variable also. I know this sounds impossible but if @UnsignedArduino is ok with this then I will create a copy of his game form the forum Arcade Advanced Stream #211 - Recreating ALL of Chess in ONE STREAM (post 15) on my laptop and make major changes. This might have the most block code of all time, but no promises. I also know that I seem like a noob at coding as i don’t have many posts on the forums but I’m not as terrible as you think.

5 Likes

So making a chess bot? I wonder if you could use @randomuser’s AI Extension to make one…

2 Likes

Chess bots usually work based on evaluation algorithms, not machine learning. You only introduce real AI when you get to a very high level, but that’s waaay outside of the scope of makecode

2 Likes

Thanks for summoning me Luke! Looking it over, I could modify my extension to fit this bot, but the TLDR is it would suck at chess. Chess is hard, complicated, and long- training would be a nightmare! Even getting it to make legal moves would take forever.

An AI opponent in a video game is a great idea though, and I’m working on an RPG style one! :wink:

2 Likes

Of course! (I’m pretty sure I stole the assets from Vivian when I did this :sweat_smile:)


The Chess Programming Wiki will be your best friend!

If you do it the typical way chess engines do it, your engine does not directly see forks, pins, and attacks. The most common method chess engines use, including Stockfish (the best chess engine in the world), is a highly-optimized mini-max search tree with alpha-beta pruning so that bad moves (such as walking into an absolute pin or not defending against checkmate) are pruned from the search tree. This allows the engine to search millions of positions per second deep into the future, often 20+ moves ahead. You will also need to write a fast evaluation function, which can be handcrafted (like old Stockfish) or using a neural network trained on billions of positions to estimate the chance of a side winning from this position. (New Stockfish and Leela Chess Zero use this) Unfortunately, I don’t think it will be practical to train a neural network of that size and load it into MakeCode, so have fun writing an evaluation function!

The Chess Programming Wiki has a great getting started guide that will guide you through creating a chess engine, including pseudo-code for algorithms and other ideas. Unfortunately, my code will not be very useful because it does not have a good complete bug-free board representation, you should create your own in an extension using classes.


As mentioned above, I think the network will have to be extremely big to have decent strength…I think it will be better to write your own custom evaluation function instead. (But if you try I’d love to see the results!)


Shameless self-promotion: My friend and I have been working on TinyChess - a chess engine optimized for memory usage - perfect for a constrained environment like MakeCode Arcade’s VM! It’s still not complete, has many bugs, is slow, sees like 4 moves into the future, looks ugly AF, and has some unholy C++ code (yea it’s written in C++ :grimacing:) but if you would like to take a look here it is:


Ugh, now I want to make a real working chess game as well that has a working chess bot…

4 Likes

Oooooh! I can help! I recently made a chess bot using minimax!

1 Like

To elaborate on what I mean, here’s an example

Sebastian Lague made a chess bot, which does not include any machine learning, but rather just a complex set of algorithms that predict good next moves.

3 Likes

Wow, that’s amazing!

I’m literally watching the premiere for his chess bot tournament right now lol

1 Like