Tiny Chess Bots
A downloadable game for Windows, macOS, and Linux
Starting in July 2023, I ran a friendly contest for programmers around the world to try to code their own chess bots. All they had to begin with was as a simple framework that handled basic operations such as generating legal moves and updating the state of the board. The rest was up to them!
As an extra challenge, the size of the bots was limited to just 1024 'tokens' of code. For example, the line 'int rookValue = 500' would count as 4 tokens: the variable type (integer), its name (rookValue), the assignment operator (=) and the numeric value (500).
This challenge ran for a little over 2 months, and by the end there were over 600 unique bots submitted. This is a selection of just a few of the many fantastic entries, covering a wide skill range from around 200 Elo all the way up to grandmaster level. Good luck defeating them!
Meet the bots:
- The CopyCat (Elo: 192). Tries to mirror the moves of its opponent as closely as possible. Far more impressive to lose to than to defeat!
- Bongcloud Enthusiast (Elo: 307). This bot will play the bongcloud no matter what. Beyond that, it moves randomly unless it can capture a piece, promote a pawn, or deliver checkmate!
- WhateverBot (Elo: 677). This bot tries it's best to play a good game of chess. It's only capable of looking one move ahead though, so it doesn't often achieve that goal. Still, it appreciates the value of developing pieces to safe squares, and retreating them when under attack.
- applemethod-orz (Elo: 1085). This bot cares only about material and tempo, and spends most of its time dreaming about capturing your pieces. Unlike the bots before it though, it's capable of looking ahead several moves into the future, so you'd best be on high alert!
- Squeedo (Elo: 1276). This bot likes to advance its pawns, develop its pieces, and get its king to safety. It also prefers positions where it has lots of possible moves, and its opponent has very few. Struggles with tactical lines though, often thinking that hanging pieces are doomed, instead of fully calculating the outcome.
- 200 Tokens Monstrosity (Elo: 1569). This bot uses only 200 of the available 1024 tokens (a personal challenge by the author), but is surprisingly strong nonethless. It cares about material and piece mobility, and has a decent search algorithm squeezed into its tiny brain, allowing it to calculate far better than the bots before it.
- Game Tech Explained (Elo: 1713). This bot has some idea of which squares its pieces will generally be good on, and is capable of looking ahead to figure out how to get them there. More importantly though, the code has been written to resemble a pawn. Some claim that this gives the bot superhuman chess powers, rendering it impossible for mere mortals to defeat.
- Electric Shockwave Gambit (Elo: 2001). In the tiny chess bot tournament, this sneaky bot tried to exploit a loop-hole in the rules in order to stun its opponents while they were thinking. Beyond that, it values both the mobility and safety of its pieces (and the opposite for its enemy of course!), and is able to look quite far ahead to achieve this.
- King Gambot IV (Elo : 2172). This bot uses many techniques to search deep into the position. It has a good understanding of where its pieces should be placed, but is hindered drastically by the king's (usually misplaced) faith in his ability to lead the attack. This entry was intended as a joke, but is nonetheless a force to be reckoned with.
- NNBot (Elo : 2246). This bot uses a neural network for its positional evaluations, though due to the competition's size limit, the network had to be very small and cleverly compressed. This gives it a good understanding of tempo and piece placement, and it's capable of searching fairly far into the future.
- TinyHugeBot (Elo: 2513). This team found a very clever exploit that allowed them to pack almost 5x as much code into their entry as anyone else, while still technically remaining within the limit. It has a good understanding of piece placement, and can quickly search quite deep into the position.
- Boychesser (Elo: 2772). The undisputed winner of the tiny chess bot tournament. This bot has been painstakingly optimized to see further ahead than all the others, allowing it often to crush its foes with tactical blows. Beyond this, it has a good understanding of piece placement, mobility, and pawn structure.
Download
Install instructions
- Windows: If the game is blocked by Microsoft Defender, press the text that says 'More info', and a 'Run Anyway' button will appear.
- Mac: The game will most likely be blocked by the gatekeeper when you try to run it. To get around that, first double-click the game to get the first warning message. Close it. Then try opening the game again, but this time via the right-click dropdown menu. The warning message that shows now should have an option to run the program. If that doesn't work, you can also install the itch.io app, and run the game from there.
- Linux: Untested -- please let me know if it works!
Development log
- Version 0.1Dec 23, 2023
Comments
Log in with itch.io to leave a comment.
Hello all, I know the competition is over yet. I want to learn programming a chess bot for my personnal knowledge. I have already loaded sebastian's code and tried to analyse it. My question is : Could someone over here provide a roadmap of the different implementations to carry on in order to run a simple yet functionning chess bot ? Would be much appreciated, thanks a lot !
PS : I have also watched the project videos which are extremely well done and useful btw
Please make a way to import other bots too
App deployment tip: For Windows, you should change the File Description & Product Name from "Godot Engine", so a shortcut to Tiny-Chess-Bots.exe is named correctly.
Very cool bots, King Gambot IV, is my favorite. Check out my game against it here(I played black): https://lichess.org/analysis/pgn/d4_Nf6_Nc3_d5_Nf3_Bf5_Kd2_e6_Ne5_Bd6_Nb5_O-O_h3...
Does work on linux, verified!
but how?
first make the binary executable
then run it
Doesn't seem to work on OSX. GUI loads, but each bot is "bot name" on the buttons and clicking it does nothing.
I have the same problem on macOS Sonoma 14.1; there are 12 buttons labeled "Bot Name" that do not do anything, and "Bot info" on the bottom does nothing.
Does not work on macOS Sonoma 14.3.1 either, same thing: the bots probably cannot load. Could it be a missing permissions thing? Which permission should I set in Settings?
Works fine for me on 14.2.1
After marking the file as executable, it appears to work well on linux :)
Turns out I'm really bad at chess though...
Wow, I lost to the Copy Cat bot first try! Ended up sacking all my pieces (with checks) except for a knight, and replicating a queen checkmate on the other side of the board with knight moves! Btw, loved the video!
Here's the full game on Lichess https://lichess.org/analysis/pgn/a4_a5_b4_b5_c4_c5_d4_d5_e4_e5_f4_f5_g4_g5_h4_h5...
Nice! And I'm happy you enjoyed the video :)
Very fun ! I've been trying to lose to the Copy Cat bot, and I've failed 3 out of 3 attempts... However, I did manage 2 stalemates, and 1 draw by repetition, and the official stats record that as 3 draws 3 losses.. So I guess that counts?
Side note, I've also been trying out a game that has a demo in Steam called Master of Chess, also written in Godot I believe - pretty cool concept as well.
Haha thanks for letting me know about the bug -- I've fixed it in V0.1. Let me know if you succeed in losing legitimately :)
This worked excellently on my Windows 10 PC (run from itch desktop app).
In the online description... the rating system is Elo, not ELO.
Happy to hear it! Oh good point, will fix it, thanks.
Applemethod and the further bots with higher rating have infinite thinking time. They don't make a move. I hope it gets fixed with the next patch.
Thanks for such a fun event.
That's strange! If you're on windows, would you mind downloading the debug build I just added, and try running the 'Tiny-Chess-Bots.console.exe'? Would love to hear if you get any error messages in the console when trying to play against the bots that don't work (and if so could you please paste them here).
The same mistake "Input string was not in a correct format." with multiple bots when they start thinking:
Thank you! If you have a minute could you please try the latest (non-debug) build. It should say v0.1 in the bottom right of the menu screen, and will hopefully work now.
Works! :-)
hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Cool Idea! I cannot run most of the Engines on windows, other than that the GUI works, maybe some bugs if I drag pieces in some weird ways. Im sure thats an easy fix or you uploaded the wrong version.
I'll look into it, thank you!
Hey, if it's not too much trouble could you download the debug build I just added, and try running the 'Tiny-Chess-Bots.console.exe'? Would love to hear if you get any error messages in the console when trying to play against the bots that don't work (and if so could you please paste them here).
I am getting the following error almost randomly when I click on an engine:
That's very helpful, thank you! If you get a chance could you please try the new (non-debug) version. Fingers crossed, it should work now.
works!
I'm running on macOS 12.6 but can't get this to run unfortunately, even using the itch io app.
I got Linux working! After unzipping, I had to `chmod +x Tiny-Chess-Bots.x86_64` so I could run it, but after that I was able to get it started with no problems.