We are going to setup CG Arena for generic CodinGame challenge. We would use Cellularena as an example.
First, let's create a new arena:
cgarena init winter-challenge-2024
cd winter-challenge-2024
We can use the default config generated by cgarena init for the most settings.
Let's review the game settings part:
[game]min_playersis already set to 2max_playersis already set to 2symmetricis already set to true
We would need to set threads based on our CPU. In my case I set to 4.
threads = 4Let's review the default settings for the embedded worker:
cmd_play_match = "python play_game.py {SEED} {PLAYERS}"
cmd_build = "g++ -std=c++20 -x c++ {DIR}/source.txt -o {DIR}/a"
cmd_run = "./{DIR}/a"As you might have noticed, the default config supports c++ language only.
The cgarena init command we used to create an arena also generated the play_game.py file for us which can play games using brutaltester-compatible referee (how to make one).
For languages which need project folder (e.g. Rust) you build bot the following way:
- create a single project somewhere and configure it to be the same as CG (e.g. has all the dependencies)
- use
build.shfile forcmd_buildcommand - inside the
build.shcopysource.txtto that project folder (e.g.main.rsfor Rust) - build the project
- copy the executable from the project build to the bot directory
The cargo.toml inside rust-workdir looks like this (this is same as CG, might be outdated):
[package]
name = "rust-workdir"
version = "0.1.0"
edition = "2018"
[dependencies]
chrono = "0.4.26"
itertools = "0.11.0"
libc = "0.2.147"
# rand is a bit of a mess, see https://www.codingame.com/forum/t/languages-update/1574/120
rand_core = "0.6.3"
rand = { version = "0.8.5", features = ["small_rng"] }
regex = "1.8.4"
time = "0.3.22"