Skip to content

Commit 79d8d17

Browse files
committed
HuskyBench working
1 parent 95a8402 commit 79d8d17

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

codeclash/games/huskybench/huskybench.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,21 @@ def __init__(self, config, *, tournament_id: str, local_output_dir: Path):
2929
def execute_round(self, agents: list[Player]):
3030
cmd = f"{self.run_cmd_round} > {self.log_env / HB_LOG_ENGINE} 2>&1 &"
3131
self.logger.debug(f"Starting game engine with command: {cmd}")
32-
script = [cmd, "sleep 0.5"]
32+
# Remove previous outputs, kill previous game if any, start engine, start server
33+
script = ["rm -rf /app/output/*", "kill -9 $(lsof -ti :8000)", cmd, "sleep 0.5"]
3334
for agent in agents:
35+
# Start each agent in background, redirecting output to log file
3436
cmd = f"cd /{agent.name} && python client/main.py --port 8000 > {self.log_env / f'{agent.name}.log'} 2>&1 &"
3537
self.logger.info(f"Adding player {agent.name} with command: {cmd}")
3638
script.append(cmd)
3739
script.append("wait")
40+
script.append(f"mv /app/output/* {self.log_env}") # Move logs to log directory
3841
create_file_in_container(
3942
container=self.environment, content="\n".join(script), dest_path="/testbed/run_game.sh"
4043
)
4144

42-
current = self.environment.config.timeout
43-
self.environment.config.timeout = 60
45+
# Run game
4446
self.environment.execute("chmod +x run_game.sh; ./run_game.sh")
45-
self.environment.config.timeout = current
4647

4748
def get_results(self, agents: list[Player], round_num: int, stats: RoundStats):
4849
map_id_to_agent = {}

docker/HuskyBench.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ wget \
88
git \
99
build-essential \
1010
unzip \
11+
lsof \
1112
&& rm -rf /var/lib/apt/lists/*
1213

1314
ARG GITHUB_TOKEN

0 commit comments

Comments
 (0)