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!

Project source code

Meet the bots:

  1. 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!
  2. 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!
  3. 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.
  4. 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!
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
StatusReleased
PlatformsWindows, macOS, Linux
Rating
Rated 4.9 out of 5 stars
(9 total ratings)
AuthorSebastian Lague
GenrePuzzle
TagsChess

Download

Download
Tiny Chess Bots (windows) 58 MB
Download
Tiny Chess Bots (mac) 110 MB
Download
Tiny Chess Bots (linux) 57 MB
Download
TinyChessBots_DebugBuild (windows) 57 MB

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

    Comments

    Log in with itch.io to leave a comment.

    (1 edit)

    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

    (+1)

    Please make a way to import other bots too

    (+1)

    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

    sudo chmod +x Tiny-Chess-Bots.x86_64
    

    then run it

    ./Tiny-Chess-Bots.x86_64
    
    (+2)

    Doesn't seem to work on OSX.   GUI loads, but each bot is "bot name" on the buttons and clicking it does nothing.

    (+1)

    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.

    (1 edit)

    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...

    (2 edits)

    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.

    (4 edits)

    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).

    (2 edits)

    The same mistake "Input string was not in a correct format." with multiple bots when they start thinking:

    ERROR: System.FormatException: Input string was not in a correct format.     at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)     at System.Double.Parse(String s)     at TinyOpeningBook.<>c.<trygetmove>b__3_0(String s) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\TinyOpeningBook.cs:line 23     at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()     at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)     at TinyOpeningBook.TryGetMove(Board board, Double randomlyDontUseBookProb) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\TinyOpeningBook.cs:line 23     at auto_Bot_70.Bot_70.Think(Board board, Timer timer) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\chess-challenge\Bots\Bot_70.cs:line 128     at BotRunner.NotifyTurnToMove(Board board) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\BotRunner.cs:line 35     at GameManager.NotifyTurnToMove() in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\GameManager.cs:line 187     at GameManager.OnMoveChosen(Move move) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\GameManager.cs:line 162     at HumanPlayer.ChoseMove(Move move) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\HumanPlayer.cs:line 212     at HumanPlayer.TryMakeMove(Coord startSquare, Coord targetSquare) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\HumanPlayer.cs:line 201     at HumanPlayer.HandlePiecePlacement(Vector2 mousePos) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\HumanPlayer.cs:line 113     at HumanPlayer.HandleDragMovement(Vector2 mousePos) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\HumanPlayer.cs:line 85     at HumanPlayer._Process(Double delta) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\application\HumanPlayer.cs:line 62     at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret)     at HumanPlayer.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\HumanPlayer_ScriptMethods.generated.cs:line 73     at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret)     at: godotsharp_pusherror (modules/mono/glue/runtime_interop.cpp:1324)</trygetmove>
    

    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

    (1 edit)

    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).

    (1 edit)

    I am getting the following error almost randomly when I click on an engine:

    ERROR: System.FormatException: Input string was not in a correct format.
       at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
       at System.Double.Parse(String s)
       at TinyOpeningBook.<>c.<TryGetMove>b__3_0(String s) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challen3
       at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at TinyOpeningBook.TryGetMove(Board board, Double randomlyDontUseBookProb) in C:\Users\sebas\Desktop\Sebastian\Proje3
       at auto_Bot_614.Bot_614.Think(Board boardOrig, Timer timerOrig) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\C9
       at BotRunner.NotifyTurnToMove(Board board) in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-C5
       at GameManager.NotifyTurnToMove() in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godo7
       at GameManager.StartGame() in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scrip5
       at GameManager._Ready() in C:\Users\sebas\Desktop\Sebastian\Projects\Chess\Chess Challenge\Tiny-Chess-Godot\scripts\6
       at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret)
       at GameManager.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in C5
       at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** arg)
       at: godotsharp_pusherror (modules/mono/glue/runtime_interop.cpp:1324)
    

    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.

    (+1)

    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.