Skip to content

Commit 530359a

Browse files
committed
Minor bug fix (config -> self.config); change print to logger.info
1 parent 758243d commit 530359a

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

codeclash/games/abstract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
22
import subprocess
3+
import time
34
import traceback
45
from abc import ABC, abstractmethod
56
from collections import Counter
67
from pathlib import Path
78
from typing import Any
8-
from uuid import uuid4
99

1010
from minisweagent.environments.docker import DockerEnvironment
1111

@@ -26,7 +26,7 @@ def __init__(self, config: dict):
2626
self.config: dict = config["game"]
2727
self.rounds: int = self.config.get("rounds", 1)
2828
self.round: int = 0
29-
self.game_id: str = f"{self.name}{uuid4().hex[:6]}"
29+
self.game_id: str = f"{self.name}{time.strftime('%y%m%d%H%M')}"
3030
self.log_path: Path = (DIR_WORK / DIR_LOGS / self.game_id).resolve()
3131
self.logger = get_logger(
3232
self.name, log_path=DIR_LOGS / self.game_id / "game.log", emoji="🏓"

codeclash/games/battlecode/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, config):
1212
super().__init__(config)
1313
assert len(config["players"]) == 2, "BattleCode is a two-player game"
1414
self.run_cmd_round: str = "python run.py run"
15-
for arg, val in config.get("args", {}).items():
15+
for arg, val in self.config.get("args", {}).items():
1616
if isinstance(val, bool):
1717
if val:
1818
self.run_cmd_round += f" --{arg}"
@@ -36,6 +36,6 @@ def execute_round(self, agents: list[Any]):
3636
for idx, agent in enumerate(agents)
3737
]
3838
cmd = f"{self.run_cmd_round} {' '.join(args)} > {self.round_log_path}"
39-
print(f"Running command: {cmd}")
39+
self.logger.info(f"Running command: {cmd}")
4040
response = self.environment.execute(cmd)
4141
assert response["returncode"] == 0, response

codeclash/games/battlesnake/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BattleSnakeGame(CodeGame):
1212
def __init__(self, config):
1313
super().__init__(config)
1414
self.run_cmd_round: str = "./battlesnake play"
15-
for arg, val in config.get("args", {}).items():
15+
for arg, val in self.config.get("args", {}).items():
1616
if isinstance(val, bool):
1717
if val:
1818
self.run_cmd_round += f" --{arg}"

codeclash/games/corewar/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CoreWarGame(CodeGame):
1010
def __init__(self, config):
1111
super().__init__(config)
1212
self.run_cmd_round: str = "./src/pmars"
13-
for arg, val in config.get("args", {}).items():
13+
for arg, val in self.config.get("args", {}).items():
1414
if isinstance(val, bool):
1515
if val:
1616
self.run_cmd_round += f" -{arg}"
@@ -31,6 +31,6 @@ def determine_winner(self, agents: list[Player]):
3131
def execute_round(self, agents: list[Player]):
3232
args = [f"/{agent.name}/warriors/warrior.red" for agent in agents]
3333
cmd = f"{self.run_cmd_round} {' '.join(args)} > {self.round_log_path}"
34-
print(f"Running command: {cmd}")
34+
self.logger.info(f"Running command: {cmd}")
3535
response = self.environment.execute(cmd)
3636
assert response["returncode"] == 0, response

codeclash/games/robocode/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RoboCodeGame(CodeGame):
1111
def __init__(self, config):
1212
super().__init__(config)
1313
self.run_cmd_round: str = "./robocode.sh"
14-
for arg, val in config.get("args", {}).items():
14+
for arg, val in self.config.get("args", {}).items():
1515
if isinstance(val, bool):
1616
if val:
1717
self.run_cmd_round += f" -{arg}"
@@ -84,6 +84,6 @@ def execute_round(self, agents: list[Player]):
8484
cmd = (
8585
f"{self.run_cmd_round} -battle {battle_file} -results {self.round_log_path}"
8686
)
87-
print(f"Running command: {cmd}")
87+
self.logger.info(f"Running command: {cmd}")
8888
response = self.environment.execute(cmd)
8989
assert response["returncode"] == 0, response

codeclash/games/robotrumble/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ def determine_winner(self, agents: list[Player]):
2323
def execute_round(self, agents: list[Player]):
2424
args = [f"/{agent.name}/robot.py" for agent in agents]
2525
cmd = f"{self.run_cmd_round} {' '.join(args)} > {self.round_log_path}"
26-
print(f"Running command: {cmd}")
26+
self.logger.info(f"Running command: {cmd}")
2727
response = self.environment.execute(cmd)
2828
assert response["returncode"] == 0, response

0 commit comments

Comments
 (0)