For bot developers
Getting your bot on the site
If you develop a backgammon bot and would like it featured on bgbotarena, playing other engines in public rooms, email us at bots@bgbotarena.net. Tell us what it plays (money games, match lengths), its search settings, under what licence we may run it, and which of the ways below suits you.
Nothing about your bot goes public until you say so. While it is new it is visible only to you: you can check how it plays here (see below), and if you rent a room (coming soon), play it against any of the site's bots in a room only you can see.
How we wire a bot in
The arena's referee rolls the dice, generates the legal moves and checks every reply. It talks to each bot through a small line-based text protocol, BGAP: it sends a position, the bot answers with a move, a cube decision or a take decision. Every request carries the whole position, so a bot keeps no state between decisions. Each bot runs in its own Docker container, with networking disabled, pinned to the CPU cores its room gives each bot: one, or several, the same for both bots.
There are three ways to get there.
1. You send us a ready-made image
A Docker image that speaks BGAP itself. You stay in full control of how your bot reads positions. It must:
- speak BGAP version 1 on standard input and output;
- run with no arguments: settings arrive as BGAP options, which the image advertises with
optionlines; - run in our sandbox: under gVisor, with no network, a read-only filesystem apart from a 256 MB
/tmp, as an unprivileged user withHOME=/tmp, at most 2 GB of memory and 256 processes, on the room's cores; - if it can search on several cores, have a
threadsoption: a room that gives each bot several cores sets it to that number; - if it plays beavers, have a
beaversoption: it is set to whether the room plays them, and the position says when a beaver is allowed (Beavers); - be built for linux/amd64 (the server's CPUs have AVX2), with weights and any databases inside;
- start within 120 seconds and answer each decision within the room's limit: 60 seconds, or 10 minutes for settings we mark as slow;
- report its name and version, so every match records what played;
- describe its settings: which ones rooms may choose, how they read, and how its search depth compares with other bots'.
Test it with our test suite, then send it as a registry we can pull from, or as a docker save file. We pin the exact image, so a new version of your bot is a new image.
2. You send us a command-line program
A program that runs on Linux and answers backgammon decisions in its own format, for example a position ID in and a move out. We write the BGAP adapter and the image around it, with the help of an AI coding assistant (Claude). We need the program, a description of its input and output, and above all its conventions: how it reads the score, the cube and who owns it, the Crawford and Jacoby rules, and the bar. That is where wiring bugs hide.
We never run your program, or build it, on a machine that holds anything of ours: we wire it in on a disposable machine, set up afresh for each bot, and only the finished image comes from there to our server, where it goes through the same checks as a ready-made one.
3. You give us access to the source code
A repository, private if you prefer. We build your bot from a pinned commit and write the adapter, either linked against its API or driving its own interface, again with the help of Claude. Most bots on the site today were wired in this way, from their public sources.
With either of the last two, we send you the adapter's source on request, so you can see exactly how your bot is asked. Source code is wired in on a disposable machine too, the same way.
The sandbox
Every bot from a developer runs in this sandbox, and so do the open-source bots we wired in ourselves. It runs under gVisor, a kernel of its own rather than the server's, and can reach nothing but the referee:
docker run --runtime runsc --rm -i --init --network none --read-only --tmpfs /tmp:size=256m \
--user 65534:65534 --env HOME=/tmp --cap-drop ALL --security-opt no-new-privileges \
--memory 2g --memory-swap 2g --pids-limit 256 --cpuset-cpus N imageIf your bot needs more memory, or to write somewhere other than /tmp, tell us; the test suite runs it exactly like this, so you will know before you send it. gVisor supports nearly everything Linux programs do; the test suite uses it if your Docker has it (installing it takes a minute on Linux) and warns you if not.
Testing your image
Our test suite checks an image the way we check it before any room can use it, so you can fix what fails before you send it. It runs on any machine with Docker:
curl -fsSL https://bgbotarena.net/downloads/bgap-test.tar.gz | docker load
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
bgbotarena/bgap-test your/bot:1.0It starts your image through your machine's Docker (hence the socket), exactly as our server does: networking off, pinned to one core. In order, it checks:
- the handshake:
bgapokandreadyokwithin 120 seconds, nothing the referee would stop at, the name and version, and that your bot stops when told to; - the description: that it reads, and the settings rooms will be offered, as the room form will show them;
- every setting: each choice played once, timed as we time it when we register your bot (over 5 seconds a decision is slow; no answer in 2 minutes and the choice isn't offered);
- matches against a simple test bot in every format your bot plays, with every reply checked by the referee;
- the conventions test and the check by kind of position described below, at your cheapest search level.
Add --quick for the protocol alone, in a minute or two. The full run takes a few minutes for a fast bot, and longer the slower its slowest settings are, since each one is timed. --opt NAME=VALUE chooses a setting for the matches and the checks. On a machine that isn't x86-64, such as an Apple Silicon Mac, your bot runs emulated and its times are slower than ours. When it passes, send us the image together with the output. The download's checksum is at bgap-test.tar.gz.sha256.
When our wiring is wrong
Like any software, the wiring we write between the arena and your bot can have bugs. Such a bug doesn't crash anything: your bot just plays worse than it really does, under your name, and the numbers look plausible. So we guard against it in two ways: checks that run automatically, and procedures we commit to follow.
Automatic checks
Every image, and every new version of it, goes through these before any room can use it:
- A conventions test. Decisions whose answer isn't in doubt: doubles after the Crawford game, positions too good to double with and without the Jacoby rule, takes and passes at lopsided scores, a blitz with checkers on the bar, opening moves, and for a bot that plays beavers, races where a double is clearly beavered or clearly only taken. A bot fed the wrong score, cube owner, rule or bar gets at least one of them wrong.
- A check by kind of position. 1,300 positions from gnubg self-play (650 checker plays, 390 cube decisions, 260 takes), each answer scored against gnubg's 3-ply evaluation and grouped by kind of position: checkers on the bar, who owns the cube, Crawford and post-Crawford games, leading or trailing, race, bear-off. A weak bot is weak everywhere; a bot fed a wrong position is wrong in one kind of position. A kind that goes far worse than the bot's own average fails the check, however strong or weak the bot is.
- Proof that the check would notice. The check runs again with simulated wiring bugs: the bar left out on either side, the scores swapped, the cube owner flipped, the Crawford or Jacoby flag wrong, cube decisions asked from the wrong side. It must catch every one that would cost the bot 0.02 or more per decision it affects.
- No check, no rooms. The database refuses to let any room use a bot without a passing report.
The checks have limits. gnubg is the yardstick, not the truth, so they say nothing about how strong a bot is. And a bug that only matters in rare positions, or costs very little, can get through.
Our commitments
- New bots start private. A new bot, and every new version, is visible only to you until you decide otherwise.
- You check our wiring. Once it passes the automatic checks, we play a sample of matches on our setup and email you the match records, every move and cube decision, so you can compare them with what your bot plays at home.
- You decide when it goes public. We feature your bot, or a new version of it, only when you have told us its play is right.
- We look into every report. If you, or anyone, suspects that a bot here plays worse than it should, write to bots@bgbotarena.net. We investigate and tell you what we find.
- We correct the record. If our wiring turns out to be wrong, we stop new rooms with that version at once, stop its running rooms, and archive them with a notice of what was wrong, rather than delete them. We fix the wiring, add a case to the checks so that the same kind of bug is caught from then on, and send you the fixed version to verify before it plays in public again.