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

Class BattleCode23Arena

codeclash/arenas/battlecode23/battlecode23.py:39–370  ·  view source on GitHub ↗

BattleCode23 arena implementation. Lifecycle: 1. validate_code() - Source-level structural checks only (in agent container) 2. execute_round() - Compile and run simulations (in game container) 3. get_results() - Parse logs and determine winner Failure handling: - If one age

Source from the content-addressed store, hash-verified

37
38
39class BattleCode23Arena(CodeArena):
40 """BattleCode23 arena implementation.
41
42 Lifecycle:
43 1. validate_code() - Source-level structural checks only (in agent container)
44 2. execute_round() - Compile and run simulations (in game container)
45 3. get_results() - Parse logs and determine winner
46
47 Failure handling:
48 - If one agent fails to compile, the other wins automatically
49 - If both fail to compile, round is a no-contest (tie)
50 - Individual simulation failures don't count toward either player
51 """
52
53 name: str = "BattleCode23"
54 description: str = """Battlecode 2023: Tempest is a real-time strategy game where your Java bot controls a team of robots competing to conquer sky islands.
55Your mission: conquer 75% or more of all sky islands by placing reality anchors on them. The first team to succeed immediately wins.
56Robots include Headquarters (craft anchors and build units), Carriers (transport anchors and gather resources), Launchers (combat units), and specialized units like Boosters and Destabilizers.
57Islands are conquered by placing reality anchors on them, which are crafted at headquarters using resources (Adamantium, Mana, Elixir) gathered from wells."""
58 default_args: dict = {
59 "maps": "maptestsmall",
60 }
61 submission: str = "src/mysubmission"
62
63 def __init__(self, config, **kwargs):
64 super().__init__(config, **kwargs)
65 assert len(config["players"]) == 2, "BattleCode23 is a two-player game"
66
67 # Build base run command
68 self.run_cmd_base: str = "./gradlew --no-daemon run"
69 for arg, val in self.game_config.get("args", self.default_args).items():
70 if isinstance(val, bool):
71 if val:
72 self.run_cmd_base += f" -P{arg}=true"
73 else:
74 self.run_cmd_base += f" -P{arg}={val}"
75
76 # Round state (set by execute_round, used by get_results)
77 self._round_result: RoundResult | None = None
78
79 def validate_code(self, agent: Player) -> tuple[bool, str | None]:
80 """Validate source structure. No compilation - that happens in execute_round.
81
82 Checks:
83 1. src/mysubmission/ directory exists
84 2. RobotPlayer.java file exists
85 3. run(RobotController rc) method signature present
86 4. Correct package declaration
87 """
88 # Check for mysubmission directory
89 ls_output = agent.environment.execute("ls src")["output"]
90 if BC23_FOLDER not in ls_output:
91 return False, f"There should be a `src/{BC23_FOLDER}/` directory"
92
93 # Check for RobotPlayer.java file
94 ls_mysubmission = agent.environment.execute(f"ls src/{BC23_FOLDER}")["output"]
95 if "RobotPlayer.java" not in ls_mysubmission:
96 return False, f"There should be a `src/{BC23_FOLDER}/RobotPlayer.java` file"

Calls

no outgoing calls