File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from codeclash .games .abstract import CodeGame
2+ from codeclash .games .battlecode .main import BattleCodeGame
23from codeclash .games .battlesnake .main import BattleSnakeGame
34from codeclash .games .corewar .main import CoreWarGame
45from codeclash .games .robocode .main import RoboCodeGame
89# might consider postponing imports to avoid loading things we don't need
910def get_game (config : dict ) -> CodeGame :
1011 game = {
11- BattleSnakeGame .name : BattleSnakeGame ,
12- CoreWarGame .name : CoreWarGame ,
13- RoboCodeGame .name : RoboCodeGame ,
14- RobotRumbleGame .name : RobotRumbleGame ,
12+ x .name : x for x in [
13+ BattleCodeGame ,
14+ BattleSnakeGame ,
15+ CoreWarGame ,
16+ RoboCodeGame ,
17+ RobotRumbleGame
18+ ]
1519 }.get (config ["game" ]["name" ])
1620 if game is None :
1721 raise ValueError (f"Unknown game: { config ['game' ]['name' ]} " )
Original file line number Diff line number Diff line change 1+ from typing import Any
2+
3+ from codeclash .games .abstract import CodeGame
4+
5+
6+ class BattleCodeGame (CodeGame ):
7+ name : str = "BattleCode"
8+
9+ def __init__ (self , config ):
10+ super ().__init__ (config )
11+ assert len (config ["players" ]) == 2 , "BattleCode is a two-player game"
12+ self .run_cmd_round : str = "python run.py run"
13+
14+ def determine_winner (self , agents : list [Any ]):
15+ response = self .environment .execute (f"tail -2 { self .round_log_path } " )
16+ self .scoreboard .append ((self .round , "BLAH" )) # TODO
17+
18+ def execute_round (self , agents : list [Any ]):
19+ args = [f"/{ agent .name } /src/" for agent in agents ]
20+ cmd = f"{ self .run_cmd_round } " # TODO
21+ response = self .environment .execute (cmd )
22+ assert response ["returncode" ] == 0 , response
Original file line number Diff line number Diff line change 1+ game :
2+ name : BattleCode
3+ rounds : 2
4+ players :
5+ - agent : dummy
6+ name : p1
7+ - agent : dummy
8+ name : p2
Original file line number Diff line number Diff line change 1+ FROM python:3.12-slim-bookworm
2+
3+ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
4+ RUN apt-get update && apt-get install -y --no-install-recommends \
5+ build-essential git curl && \
6+ rm -rf /var/lib/apt/lists/*
7+
8+ RUN git clone https://github.com/emagedoc/BattleCode.git /testbed
9+
10+ WORKDIR /testbed
11+
12+ RUN python run.py update
You can’t perform that action at this time.
0 commit comments