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

Method __init__

codeclash/arenas/arena.py:78–108  ·  view source on GitHub ↗

The CodeArena class is responsible for running games, i.e., taking a list of code from different agents/players and running them against each other. It also provides the environments for the game and agents to run in. The central method is `run_round`, which takes a list of

(self, config: dict, *, tournament_id: str, local_output_dir: Path, keep_containers: bool = False)

Source from the content-addressed store, hash-verified

76 default_args: dict = {}
77 submission: str
78
79 # Serializes image builds across concurrent pairs (e.g. `ladder make --workers N`), so
80 # worker threads don't all race `docker build` on a cold start and fail with "already exists".
81 _build_lock = threading.Lock()
82
83 def __init__(self, config: dict, *, tournament_id: str, local_output_dir: Path, keep_containers: bool = False):
84 """The CodeArena class is responsible for running games, i.e., taking a list of code
85 from different agents/players and running them against each other.
86 It also provides the environments for the game and agents to run in.
87
88 The central method is `run_round`, which takes a list of agents and returns the winner of the round.
89
90 At the end of the the tournament, run the `end` method to clean up the game and agents and write the metadata.
91
92 Args:
93 config: The overall config for the tournament.
94 tournament_id: The id of the tournament.
95 local_output_dir: The host/local directory to write logs to.
96 keep_containers: Do not remove containers after games/agent finish.
97 """
98 self.url_gh: str = f"git@github.com:{GH_ORG}/{self.name}.git"
99 self.artifacts: list[Path] = []
100 """Artifact objects that we might want to clean up after the game."""
101 self.config: dict = config
102 self._keep_containers: bool = keep_containers
103 self._metadata: dict = {
104 "name": self.name,
105 "config": self.config["game"],
106 "game_id": tournament_id,
107 "created_timestamp": int(time.time()),
108 }
109 self.log_env: Path = DIR_LOGS
110 self.log_local: Path = local_output_dir
111 self.logger = get_logger(self.name, log_path=self.log_local / "game.log", emoji="🏓")

Callers

nothing calls this directly

Calls 2

get_environmentMethod · 0.95
get_loggerFunction · 0.90

Tested by

no test coverage detected