MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / main

Function main

codeclash/utils/generate_confs_transparent.py:11–63  ·  view source on GitHub ↗
(models: str, arenas: str, rounds: int, simulations: int, record_ratio: float, output: Path)

Source from the content-addressed store, hash-verified

9
10
11def main(models: str, arenas: str, rounds: int, simulations: int, record_ratio: float, output: Path):
12 # Get all models
13 models = yaml.safe_load(open(models))
14 output.mkdir(parents=True, exist_ok=True)
15 pairs = []
16 for i in range(len(models)):
17 for j in range(i + 1, len(models)):
18 pairs.append((models[i], models[j]))
19
20 # Get arenas
21 arenas_list = ARENAS if arenas == "all" else [a for a in ARENAS if a.name in arenas.split(",")]
22 if not arenas_list:
23 print(f"No valid arenas found from {arenas}. Choose from {[a.name for a in ARENAS]}.")
24 return # Stop execution if no valid arenas are found
25
26 configs_created = 0
27 for arena in arenas_list:
28 print(f"Generating configs for arena: {arena.name}")
29 for pair in pairs:
30 print(f" - {[p['model_name'] for p in pair]}")
31 config = get_config(rounds, simulations, arena, pair)
32
33 # Inform model that it can see opponent's codebases
34 config["tournament"]["transparent"] = True
35 config["prompts"]["game_description"] += f"""
36In this tournament, you have full access to your opponent(s)' codebase.
37You can access their codebase(s) under /{OPPONENT_CODEBASES_DIR_NAME}/.
38If you wish, you may read and analyze your opponent(s)' code to inform your strategy.
39Note that:
40- Your opponent(s) also has access to your codebase ({DIR_WORK})
41- You are shown a *copy* of the opponent(s)' codebase from the prior round; any changes you make will not affect their actual code.
42"""
43
44 pair_names = "__".join(sorted([get_name(pair[0]), get_name(pair[1])]))
45 config_name = f"{arena.name}__{pair_names}__r{rounds}__s{simulations}.yaml"
46 with open(output / config_name, "w") as f:
47 yaml.dump(
48 config,
49 f,
50 default_style=None,
51 sort_keys=False,
52 allow_unicode=True,
53 default_flow_style=False,
54 Dumper=yaml.SafeDumper,
55 )
56 clean_config(output / config_name)
57 configs_created += 1
58
59 print(f"Generated {configs_created} configuration files in '{output}'.")
60 print(f"- # Models: {len(models)}")
61 print(f"- # Arenas: {len(arenas_list)}")
62 print(f"- r (rounds) {rounds}")
63 print(f"- s (sims_per_round) {simulations}")
64
65
66if __name__ == "__main__":

Callers 1

Calls 3

get_configFunction · 0.90
get_nameFunction · 0.90
clean_configFunction · 0.90

Tested by

no test coverage detected