Skip to content

Commit e076b6b

Browse files
committed
Remove arena container logs per round; add Battlesnake validation; add -k flag
1 parent eecba21 commit e076b6b

10 files changed

Lines changed: 28 additions & 7 deletions

File tree

codeclash/games/battlesnake/battlesnake.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,18 @@ def get_results(self, agents: list[Player], round_num: int, stats: RoundStats):
146146
stats.player_stats[player].score = score
147147

148148
def validate_code(self, agent: Player) -> tuple[bool, str | None]:
149-
# TODO: implement more checks
149+
if "main.py" not in agent.environment.execute("ls")["output"]:
150+
return False, "No main.py file found in the root directory"
151+
bot_content = agent.environment.execute("cat main.py")["output"].splitlines()
152+
error_msg = []
153+
for func in [
154+
"def info() -> typing.Dict:",
155+
"def start(game_state: typing.Dict):",
156+
"def end(game_state: typing.Dict):",
157+
"def move(game_state: typing.Dict) -> typing.Dict:",
158+
]:
159+
if func not in bot_content:
160+
error_msg.append(f"There should be a `{func}` function implemented in `main.py`")
161+
if len(error_msg) > 0:
162+
return False, "\n".join(error_msg + ["Don't change the function signatures!"])
150163
return True, None

codeclash/games/game.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ def copy_logs_from_env(self, round_num: int) -> None:
145145
dest_path=self.log_round(round_num),
146146
)
147147

148+
# Remove logs from container to save space
149+
assert_zero_exit_code(
150+
self.environment.execute(f"rm -rf {self.log_env}"),
151+
logger=self.logger,
152+
)
153+
148154
def end(self, cleanup: bool = False):
149155
if cleanup:
150156
for artifact in self.artifacts:

configs/test/players/2/battlesnake.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tournament:
22
rounds: 3
33
game:
44
name: BattleSnake
5-
sims_per_round: 20
5+
sims_per_round: 1000
66
args:
77
width: 11
88
height: 11

configs/test/players/2/corewar.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tournament:
22
rounds: 3
33
game:
44
name: CoreWar
5-
sims_per_round: 50
5+
sims_per_round: 1000
66
players:
77
- agent: dummy
88
name: p1

configs/test/players/2/dummy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tournament:
22
rounds: 3
33
game:
44
name: DummyGame
5-
sims_per_round: 100
5+
sims_per_round: 1000
66
players:
77
- agent: dummy
88
name: p1

configs/test/players/2/huskybench.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tournament:
22
rounds: 3
33
game:
44
name: HuskyBench
5-
sims_per_round: 30
5+
sims_per_round: 1000
66
players:
77
- agent: dummy
88
name: p1

configs/test/players/2/robocode.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tournament:
22
rounds: 3
33
game:
44
name: RoboCode
5-
sims_per_round: 30
5+
sims_per_round: 1000
66
battle:
77
battle:
88
gunCoolingRate: 0.1

configs/test/players/2/robotrumble.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tournament:
22
rounds: 2
33
game:
44
name: RobotRumble
5-
sims_per_round: 30
5+
sims_per_round: 1000
66
players:
77
- agent: dummy
88
name: p1

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def main_cli(argv: list[str] | None = None):
7171
default="",
7272
)
7373
parser.add_argument(
74+
"-k",
7475
"--keep-containers",
7576
action="store_true",
7677
help="Do not remove containers after games/agent finish",

main_single_player.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def main_cli(argv: list[str] | None = None):
6464
default="",
6565
)
6666
parser.add_argument(
67+
"-k",
6768
"--keep-containers",
6869
action="store_true",
6970
help="Do not remove containers after games/agent finish",

0 commit comments

Comments
 (0)