βοΈ Create & Upload Your Chess Bot to Battle AggressiveBot
qWelcome to FightScript! This guide helps you build your own C++ chess bot, upload it, and fight a match against our built-in AggressiveBot, powered by Stockfish and against other developer developed bots.
β What You Need
- A working C++ environment (
g++
recommended) - Basic knowledge of the UCI (Universal Chess Interface)
- Your bot should:
- Read input via
std::cin
- Output moves via
std::cout
- Handle standard UCI commands
- Read input via
π§ Your final upload must be a compiled Linux binary (
your_bot
), not the source.cpp
file.
π Sample C++ Bot Code
This example bot picks a basic move depending on the color and follows the UCI protocol strictly:
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <chrono>
std::string get_move(const std::string& fen) {
bool is_white = fen.find(" w ") != std::string::npos;
std::vector<std::string> moves;
if (is_white) {
moves = {"e2e4", "d2d4", "g1f3", "b1c3", "f1c4", "f1b5"};
} else {
moves = {"e7e5", "d7d5", "g8f6", "b8c6", "f8c5", "f8b4"};
}
auto seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 gen(seed);
std::uniform_int_distribution<> dis(0, moves.size() - 1);
return moves[dis(gen)];
}
int main() {
std::string line;
std::string current_fen;
while (std::getline(std::cin, line)) {
if (line == "uci") {
std::cout << "id name MyBot\n";
std::cout << "id author Your Name\n";
std::cout << "uciok\n";
} else if (line == "isready") {
std::cout << "readyok\n";
} else if (line.rfind("position", 0) == 0) {
size_t fenIndex = line.find("fen ");
if (fenIndex != std::string::npos) {
current_fen = line.substr(fenIndex + 4);
}
} else if (line == "go") {
std::string move = get_move(current_fen);
std::cout << "bestmove " << move << "\n";
} else if (line == "quit") {
break;
}
}
return 0;
}
βοΈ How to Compile (on your local machine)
Use this command to generate an executable Linux-compatible binary:
g++ -std=c++17 your_bot.cpp -o your_bot
Make sure the compiled binary:
- Has no platform dependencies (compile on Linux or WSL for best compatibility)
- Is tested locally before upload:
./your_bot
and type in UCI commands - Has execution permissions:
chmod +x your_bot
π€ Uploading Your Bot
Once compiled:
- Rename it meaningfully, e.g.,
my_bot
- Upload it using the Upload Bot button on the site
- The server downloads it from Google Drive
- Itβs executed inside a secure environment alongside Stockfish
π Match Flow
- Your bot is treated like a UCI engine
- Stockfish sends standard
uci
,isready
,position
,go
commands - Your bot replies with
bestmove XYZ
- The game ends when one side wins or it's a draw
- You'll get:
- Game result
- Move history
- Winner and reason
β οΈ Rules & Tips
- Your bot must:
- Respond to
uci
,isready
,position
,go
,quit
- Output only UCI responses (no debug prints to stdout)
- Respond to
- Keep your response time < 1 second
- Avoid memory leaks or background threads
- You can build advanced bots with:
- Minimax
- Evaluation functions
- Libraries like chesslib
β Final Upload Checklist
β
Compiled binary (Linux-compatible)
β
Tested with UCI manually
β
Named appropriately (no spaces/special characters)
β
Set as executable (chmod +x my_bot
)
β
Uploaded via the site interface (https://fightscript.io/competitions/chess)