Skip to content

Commit c3ab07b

Browse files
committed
Add transparent ablation configs
1 parent 6954bdf commit c3ab07b

7 files changed

Lines changed: 399 additions & 2 deletions

codeclash/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
FILE_RESULTS = "results.json"
99
GH_ORG = "emagedoc"
1010
RESULT_TIE = "Tie"
11+
OPPONENT_CODEBASES_DIR_NAME = "opponent_codebases"

codeclash/tournaments/pvp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from codeclash.agents import get_agent
1212
from codeclash.agents.player import Player
1313
from codeclash.agents.utils import GameContext
14-
from codeclash.constants import DIR_LOGS, DIR_WORK, FILE_RESULTS
14+
from codeclash.constants import DIR_LOGS, DIR_WORK, FILE_RESULTS, OPPONENT_CODEBASES_DIR_NAME
1515
from codeclash.games import get_game
1616
from codeclash.games.game import CodeGame
1717
from codeclash.tournaments.tournament import AbstractTournament
@@ -136,7 +136,7 @@ def run_edit_phase(self, round_num: int) -> None:
136136
agent.environment,
137137
opp.environment,
138138
agent.environment.config.cwd,
139-
f"/{agent.name}/",
139+
f"/{OPPONENT_CODEBASES_DIR_NAME}/{agent.name}/",
140140
)
141141

142142
with ThreadPoolExecutor() as executor:
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import argparse
2+
from pathlib import Path
3+
4+
import yaml
5+
6+
from codeclash.constants import DIR_WORK, OPPONENT_CODEBASES_DIR_NAME
7+
from codeclash.games import (
8+
ARENAS,
9+
DummyGame,
10+
)
11+
from codeclash.utils.generate_confs import clean_config, get_config, get_name
12+
13+
14+
def main(models: str, arenas: str, rounds: int, simulations: int, record_ratio: float, output: Path):
15+
# Get all models
16+
models = yaml.safe_load(open(models))
17+
output.mkdir(parents=True, exist_ok=True)
18+
pairs = []
19+
for i in range(len(models)):
20+
for j in range(i + 1, len(models)):
21+
pairs.append((models[i], models[j]))
22+
23+
# Get arenas
24+
arenas_list = ARENAS if arenas == "all" else [a for a in ARENAS if a.name in arenas.split(",")]
25+
if DummyGame in arenas_list:
26+
arenas_list.remove(DummyGame) # Skip DummyGame for config generation
27+
if not arenas_list:
28+
print(f"No valid arenas found from {arenas}. Choose from {[a.name for a in ARENAS]}.")
29+
return # Stop execution if no valid arenas are found
30+
31+
configs_created = 0
32+
for arena in arenas_list:
33+
print(f"Generating configs for arena: {arena.name}")
34+
for pair in pairs:
35+
print(f" - {[p['model_name'] for p in pair]}")
36+
config = get_config(rounds, simulations, arena, pair)
37+
38+
# Inform model that it can see opponent's codebases
39+
config["prompts"]["game_description"] += f"""
40+
In this tournament, you have full access to your opponent(s)' codebase.
41+
You can access their codebase(s) under /{OPPONENT_CODEBASES_DIR_NAME}/.
42+
If you wish, you may read and analyze your opponent(s)' code to inform your strategy.
43+
Note that:
44+
- Your opponent(s) also has access to your codebase ({DIR_WORK})
45+
- You are shown a *copy* of the opponent(s)' codebase from the prior round; any changes you make will not affect their actual code.
46+
"""
47+
48+
pair_names = "__".join(sorted([get_name(pair[0]), get_name(pair[1])]))
49+
config_name = f"{arena.name}__{pair_names}__r{rounds}__s{simulations}.yaml"
50+
with open(output / config_name, "w") as f:
51+
yaml.dump(
52+
config,
53+
f,
54+
default_style=None,
55+
sort_keys=False,
56+
allow_unicode=True,
57+
default_flow_style=False,
58+
Dumper=yaml.SafeDumper,
59+
)
60+
clean_config(output / config_name)
61+
configs_created += 1
62+
63+
print(f"Generated {configs_created} configuration files in '{output}'.")
64+
print(f"- # Models: {len(models)}")
65+
print(f"- # Arenas: {len(arenas_list)}")
66+
print(f"- r (rounds) {rounds}")
67+
print(f"- s (sims_per_round) {simulations}")
68+
69+
70+
if __name__ == "__main__":
71+
parser = argparse.ArgumentParser(description="Generate configuration files.")
72+
parser.add_argument(
73+
"-m",
74+
"--models",
75+
type=str,
76+
default="configs/models_transparent.yaml",
77+
help="Path to model configurations.",
78+
)
79+
parser.add_argument(
80+
"-a",
81+
"--arenas",
82+
type=str,
83+
default="all",
84+
help="Comma separated list of arenas to generate configs for (default: all).",
85+
)
86+
parser.add_argument(
87+
"-r",
88+
"--rounds",
89+
type=int,
90+
default=15,
91+
help="Number of rounds per tournament for the configuration (default: 15).",
92+
)
93+
parser.add_argument(
94+
"-s",
95+
"--simulations",
96+
type=int,
97+
default=1000,
98+
help="Number of simulations to run per round (default: 1000).",
99+
)
100+
parser.add_argument(
101+
"--record_ratio",
102+
type=float,
103+
default=1,
104+
help="Fraction of simulations to record (default: 1 = all).",
105+
)
106+
parser.add_argument(
107+
"-o",
108+
"--output",
109+
type=Path,
110+
default=Path("configs/transparent/"),
111+
help="Output directory for configuration files (default: multi/).",
112+
)
113+
args = parser.parse_args()
114+
main(**vars(args))

configs/models_transparent.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- model_name: "@anthropic/claude-sonnet-4-5-20250929"
2+
model_class: portkey
3+
model_kwargs:
4+
temperature: 0.2
5+
max_tokens: 4096
6+
- model_name: "@google/gemini-2.5-pro"
7+
model_class: portkey
8+
model_kwargs:
9+
temperature: 0.2
10+
- model_name: "@openai/gpt-5"
11+
model_class: portkey
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
tournament:
2+
rounds: 15
3+
game:
4+
name: Halite
5+
sims_per_round: 250
6+
args: {}
7+
players:
8+
- agent: mini
9+
name: claude-sonnet-4-5-20250929
10+
config:
11+
agent: !include mini/default.yaml
12+
model:
13+
model_name: '@anthropic/claude-sonnet-4-5-20250929'
14+
model_class: portkey
15+
model_kwargs:
16+
temperature: 0.2
17+
max_tokens: 4096
18+
- agent: mini
19+
name: gemini-2.5-pro
20+
config:
21+
agent: !include mini/default.yaml
22+
model:
23+
model_name: '@google/gemini-2.5-pro'
24+
model_class: portkey
25+
model_kwargs:
26+
temperature: 0.2
27+
prompts:
28+
game_description: 'You are a software developer ({{player_id}}) competing in a coding
29+
game called Halite.
30+
31+
Halite is a multi-player turn-based strategy game where bots compete on a rectangular
32+
grid to capture territory and accumulate strength.
33+
34+
Players control pieces that can move across the map to conquer neutral and enemy
35+
territory, with each cell providing production that increases the strength of
36+
pieces occupying it.
37+
38+
The goal is to control the most territory by the end of the game through strategic
39+
expansion, consolidation of forces, and tactical combat decisions.
40+
41+
42+
You have the choice of writing your Halite bot in one of four programming languages:
43+
C, C++, OCaml, or Rust.
44+
45+
Example implementations can be found under the `airesources/` folder.
46+
47+
Your submission should be stored in the `submission/` folder. This folder currently
48+
contains an example C bot, but feel free to use any of the supported languages.
49+
50+
Please make sure your main file is named `main.<ext>`, where `<ext>` is the appropriate
51+
file extension for your chosen programming language.
52+
53+
You may include additional files as needed, but please ensure:
54+
55+
1. The `submission/` folder contains only files relevant to your bot.
56+
57+
2. The `submission/` folder ONLY contains a single bot (no multiple bots in one
58+
submission).
59+
60+
3. Your bot can be compiled. See `runGame.sh` under the corresponding `submission/<language>/`
61+
folder to see how we will compile and run your bot.
62+
63+
64+
65+
The game is played in 15 rounds. For every round, you (and your competitors) edit
66+
program code that controls your bot. This is round {{round}}.
67+
68+
After you and your competitor finish editing your codebases, the game is run automatically.
69+
70+
71+
Your task: improve the bot in `submission`, located in {{working_dir}}.
72+
73+
{{working_dir}} is your codebase, which contains both your both and supporting
74+
assets.
75+
76+
All of your commands will be executed in the {{working_dir}} directory (see notes
77+
below).
78+
79+
In this tournament, you have full access to your opponent(s)'' codebase.
80+
81+
You can access their codebase(s) under /opponent_codebases/.
82+
83+
If you wish, you may read and analyze your opponent(s)'' code to inform your strategy.
84+
85+
Note that:
86+
87+
- Your opponent(s) also has access to your codebase (/workspace)
88+
89+
- You are shown a *copy* of the opponent(s)'' codebase from the prior round; any
90+
changes you make will not affect their actual code.
91+
92+
'
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
tournament:
2+
rounds: 15
3+
game:
4+
name: Halite
5+
sims_per_round: 250
6+
args: {}
7+
players:
8+
- agent: mini
9+
name: claude-sonnet-4-5-20250929
10+
config:
11+
agent: !include mini/default.yaml
12+
model:
13+
model_name: '@anthropic/claude-sonnet-4-5-20250929'
14+
model_class: portkey
15+
model_kwargs:
16+
temperature: 0.2
17+
max_tokens: 4096
18+
- agent: mini
19+
name: gpt-5
20+
config:
21+
agent: !include mini/default.yaml
22+
model:
23+
model_name: '@openai/gpt-5'
24+
model_class: portkey
25+
prompts:
26+
game_description: 'You are a software developer ({{player_id}}) competing in a coding
27+
game called Halite.
28+
29+
Halite is a multi-player turn-based strategy game where bots compete on a rectangular
30+
grid to capture territory and accumulate strength.
31+
32+
Players control pieces that can move across the map to conquer neutral and enemy
33+
territory, with each cell providing production that increases the strength of
34+
pieces occupying it.
35+
36+
The goal is to control the most territory by the end of the game through strategic
37+
expansion, consolidation of forces, and tactical combat decisions.
38+
39+
40+
You have the choice of writing your Halite bot in one of four programming languages:
41+
C, C++, OCaml, or Rust.
42+
43+
Example implementations can be found under the `airesources/` folder.
44+
45+
Your submission should be stored in the `submission/` folder. This folder currently
46+
contains an example C bot, but feel free to use any of the supported languages.
47+
48+
Please make sure your main file is named `main.<ext>`, where `<ext>` is the appropriate
49+
file extension for your chosen programming language.
50+
51+
You may include additional files as needed, but please ensure:
52+
53+
1. The `submission/` folder contains only files relevant to your bot.
54+
55+
2. The `submission/` folder ONLY contains a single bot (no multiple bots in one
56+
submission).
57+
58+
3. Your bot can be compiled. See `runGame.sh` under the corresponding `submission/<language>/`
59+
folder to see how we will compile and run your bot.
60+
61+
62+
63+
The game is played in 15 rounds. For every round, you (and your competitors) edit
64+
program code that controls your bot. This is round {{round}}.
65+
66+
After you and your competitor finish editing your codebases, the game is run automatically.
67+
68+
69+
Your task: improve the bot in `submission`, located in {{working_dir}}.
70+
71+
{{working_dir}} is your codebase, which contains both your both and supporting
72+
assets.
73+
74+
All of your commands will be executed in the {{working_dir}} directory (see notes
75+
below).
76+
77+
In this tournament, you have full access to your opponent(s)'' codebase.
78+
79+
You can access their codebase(s) under /opponent_codebases/.
80+
81+
If you wish, you may read and analyze your opponent(s)'' code to inform your strategy.
82+
83+
Note that:
84+
85+
- Your opponent(s) also has access to your codebase (/workspace)
86+
87+
- You are shown a *copy* of the opponent(s)'' codebase from the prior round; any
88+
changes you make will not affect their actual code.
89+
90+
'

0 commit comments

Comments
 (0)