A local tournament runner for testing Codingame PvP bots against each other.
SelfArena orchestrates matches between your AI implementations, collects statistics, and calculates win rates to help you make sure your changes are effective without uploading to Codingame.
- Node.js
- Java (for running referee JARs)
# Clone repository
git clone https://github.com/Telokis/cg-selfarena.git
cd selfarena
# Install dependencies
npm install
- Create a YAML configuration file in the
configs/
directory - Place referee JARs in the
referees/
directory - Place your bots in the
bots/
directory - Run a tournament:
npm run start -- configs/breakthrough.yml
Override configuration settings. Using the following CLI options will override the values specified in the config file:
npm run start -- configs/breakthrough.yml -n 50 --seed 42 --batches 10 --swap
Options:
-n, --games <num>
: Number of games per matchup-seed <num>
: Set a specific random seed-b, --batches <num>
: Number of parallel matches--swap
: Enable position swapping (for games with first-player advantage)-q, --quiet
: Disable per-match logging-h, --help
: Display help
Example configs/breakthrough.yml
:
referee:
command: "java -jar <referees_dir>/Breakthrough-1.0-SNAPSHOT.jar"
players:
- name: "MCTS Bot"
command: "node <bots_dir>/my_mcts_bot.js"
- name: "Minimax Bot"
command: "<bots_dir>/my_minimax_bot.exe"
game:
seed: 0 # Random seed
games_per_matchup: 100
players_per_game: 2
swap_positions: true # Play each match as both sides (white and black)
execution:
batches: 20 # Runs at most 20 matchs in parallel
In the config file, you can use:
<config_dir>
to point to the directory the config is located in<bots_dir>
which is a shortcut to<config_dir>/../bots
<referees_dir>
which is a shortcut to<config_dir>/../referees
Note: for node
commands, the tool automatically adds -r <helpers_dir>/js_helper.js
to give you access to readline()
.
SelfArena shows match results and calculates overall statistics:
...
Match 42/100: Seed=1234567890 MCTS Bot:1 | Minimax Bot:0
...
Summary of performance:
MCTS Bot: 58.50% (52 win / 35 lose / 13 draw)
Minimax Bot: 41.50% (35 win / 52 lose / 13 draw)