Skip to content

Latest commit

 

History

History
76 lines (53 loc) · 2.13 KB

File metadata and controls

76 lines (53 loc) · 2.13 KB

Example setup for CodinGame

We are going to setup CG Arena for generic CodinGame challenge. We would use Cellularena as an example.

Creating the new arena

First, let's create a new arena:

cgarena init winter-challenge-2024
cd winter-challenge-2024

Configuration

We can use the default config generated by cgarena init for the most settings.

Let's review the game settings part:

  • [game]
    • min_players is already set to 2
    • max_players is already set to 2
    • symmetric is already set to true

Worker configuration

Concurrency

We would need to set threads based on our CPU. In my case I set to 4.

threads = 4

Commands

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

Languages that need workspace

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.sh file for cmd_build command
  • inside the build.sh copy source.txt to that project folder (e.g. main.rs for 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"