Skip to content

Commit 43d82df

Browse files
committed
Rename get_game -> get_arena; Add Halite II
1 parent 05c9b54 commit 43d82df

File tree

8 files changed

+48
-21
lines changed

8 files changed

+48
-21
lines changed

codeclash/analysis/matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from codeclash.agents.dummy_agent import Dummy
1010
from codeclash.agents.utils import GameContext
11-
from codeclash.arenas import get_game
11+
from codeclash.arenas import get_arena
1212
from codeclash.constants import DIR_WORK
1313
from codeclash.tournaments.utils.git_utils import filter_git_diff
1414
from codeclash.utils.atomic_write import atomic_write
@@ -109,7 +109,7 @@ def _initialize_game_pool(self):
109109
config = self.config.copy()
110110
config["game"]["sims_per_round"] = self.n_repetitions
111111

112-
game = get_game(
112+
game = get_arena(
113113
config,
114114
tournament_id=tournament_id,
115115
local_output_dir=self.pvp_output_dir / "matrix_eval" / f"worker_{i}",

codeclash/arenas/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from codeclash.arenas.corewar.corewar import CoreWarArena
55
from codeclash.arenas.dummy.dummy import DummyArena
66
from codeclash.arenas.halite.halite import HaliteArena
7+
from codeclash.arenas.halite2.halite2 import Halite2Arena
78

8-
# from codeclash.games.halite2.halite2 import Halite2Game # WIP
99
# from codeclash.games.halite3.halite3 import Halite3Game # WIP
1010
from codeclash.arenas.huskybench.huskybench import HuskyBenchArena
1111
from codeclash.arenas.robocode.robocode import RoboCodeArena
@@ -17,14 +17,15 @@
1717
CoreWarArena,
1818
DummyArena,
1919
HaliteArena,
20+
Halite2Arena,
2021
HuskyBenchArena,
2122
RoboCodeArena,
2223
RobotRumbleArena,
2324
]
2425

2526

2627
# might consider postponing imports to avoid loading things we don't need
27-
def get_game(config: dict, **kwargs) -> CodeArena:
28+
def get_arena(config: dict, **kwargs) -> CodeArena:
2829
game = {x.name: x for x in ARENAS}.get(config["game"]["name"])
2930
if game is None:
3031
raise ValueError(f"Unknown game: {config['game']['name']}")

codeclash/arenas/halite/halite.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
# Command to be run in each agent's `submission/` folder to compile agent
1818
MAP_FILE_TYPE_TO_COMPILE = {
19-
".cpp": "g++ -std=c++11 {path}.cpp -o {name}.o",
20-
".c": "gcc {path}.c -o {name}.o",
19+
".cpp": "g++ -std=c++11 {name}.cpp -o {name}.o",
20+
".c": "gcc {name}.c -o {name}.o",
21+
".hs": "ghc --make {name}.hs -O -v0 -rtsopts -outputdir dist",
2122
".ml": "ocamlbuild -lib unix {name}.native",
2223
".rs": "cargo build",
2324
}
@@ -26,6 +27,7 @@
2627
MAP_FILE_TYPE_TO_RUN = {
2728
".c": "{path}/{name}.o",
2829
".cpp": "{path}/{name}.o",
30+
".hs": "{path}/{name}",
2931
".js": "node {path}/{name}.js",
3032
".ml": "{path}/{name}.native",
3133
".py": "python {path}/{name}.py",
@@ -145,7 +147,7 @@ def validate_code(self, agent: Player) -> tuple[bool, str | None]:
145147

146148
# Check that the submission compiles if necessary
147149
if main_ext in MAP_FILE_TYPE_TO_COMPILE:
148-
compile_cmd = MAP_FILE_TYPE_TO_COMPILE[main_ext].format(path="main", name="main")
150+
compile_cmd = MAP_FILE_TYPE_TO_COMPILE[main_ext].format(name="main")
149151
try:
150152
compile_response = agent.environment.execute(compile_cmd, timeout=15, cwd=sub_path)
151153
except subprocess.TimeoutExpired:

codeclash/arenas/halite2/Halite-II.Dockerfile renamed to codeclash/arenas/halite2/Halite2.Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,24 @@ ENV PATH="/root/.cargo/bin:${PATH}"
1818
# Install ocaml
1919
RUN apt-get update && apt-get install -y ocaml ocamlbuild
2020

21+
# Install Haskell
22+
RUN apt-get update && apt-get install -y libgmp-dev \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Install GHCup non-interactively
26+
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
27+
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 sh
28+
29+
# Add ghcup to PATH
30+
ENV PATH="/root/.ghcup/bin:${PATH}"
31+
32+
# Verify installation
33+
RUN ghc --version && cabal --version
34+
2135
# Clone Halite repository
22-
RUN git clone https://github.com/CodeClash-ai/Halite-II.git /workspace \
36+
RUN git clone https://github.com/CodeClash-ai/Halite2.git /workspace \
2337
&& cd /workspace \
24-
&& git remote set-url origin https://github.com/CodeClash-ai/Halite-II.git \
25-
38+
&& git remote set-url origin https://github.com/CodeClash-ai/Halite2.git
2639
WORKDIR /workspace
2740

2841
RUN cd environment && cmake . && make

codeclash/arenas/halite2/halite2.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33

44
class Halite2Arena(HaliteArena):
5-
name: str = "Halite-II"
6-
description: str = ""
7-
default_args: dict = {}
8-
submission: str = "submission"
5+
name: str = "Halite2"
6+
description: str = """Halite II is a multi-player AI-programming challenge in which bots pilot fleets of spaceships across a continuous space-themed universe.
7+
Players command ships to mine planets for halite, use that resource to build additional ships, and expand control across the map.
8+
Victory depends on efficient resource gathering, fleet management, and strategic expansion to outcompete rival bots for dominance.
9+
10+
You have the choice of writing your Halite bot in one of four programming languages: C++, Haskell, OCaml, or Rust.
11+
Example implementations can be found under the `airesources/` folder.
12+
Your submission should be stored in the `submission/` folder. This folder currently contains an example OCaml bot, but feel free to use any of the supported languages.
13+
Please make sure your main file is named `main.<ext>`, where `<ext>` is the appropriate file extension for your chosen programming language.
14+
You may include additional files as needed, but please ensure:
15+
1. The `submission/` folder contains only files relevant to your bot.
16+
2. The `submission/` folder ONLY contains a single bot (no multiple bots in one submission).
17+
3. Your bot can be compiled. See `runGame.sh` under the corresponding `submission/<language>/` folder to see how we will compile and run your bot.
18+
"""

codeclash/tournaments/pvp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from codeclash.agents import get_agent
1212
from codeclash.agents.player import Player
1313
from codeclash.agents.utils import GameContext
14-
from codeclash.arenas import get_game
14+
from codeclash.arenas import get_arena
1515
from codeclash.arenas.arena import CodeArena
1616
from codeclash.constants import DIR_LOGS, DIR_WORK, FILE_RESULTS, OPPONENT_CODEBASES_DIR_NAME
1717
from codeclash.tournaments.tournament import AbstractTournament
@@ -35,7 +35,7 @@ def __init__(
3535
self.logger.critical(f"Metadata file already exists: {self.metadata_file}")
3636
raise FileExistsError(f"Metadata file already exists: {self.metadata_file}")
3737
self.cleanup_on_end = cleanup
38-
self.game: CodeArena = get_game(
38+
self.game: CodeArena = get_arena(
3939
self.config,
4040
tournament_id=self.tournament_id,
4141
local_output_dir=self.local_output_dir,

codeclash/tournaments/single_player.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from codeclash.agents.dummy_agent import Dummy
1111
from codeclash.agents.player import Player
1212
from codeclash.agents.utils import GameContext
13-
from codeclash.arenas import get_game
13+
from codeclash.arenas import get_arena
1414
from codeclash.arenas.arena import CodeArena
1515
from codeclash.constants import DIR_WORK, FILE_RESULTS
1616
from codeclash.tournaments.tournament import AbstractTournament
@@ -24,7 +24,7 @@ class SinglePlayerTraining(AbstractTournament):
2424
def __init__(self, config: dict, *, output_dir: Path, cleanup: bool = False, keep_containers: bool = False):
2525
super().__init__(config, name="SinglePlayerTraining", output_dir=output_dir)
2626
self.cleanup_on_end = cleanup
27-
self.game: CodeArena = get_game(
27+
self.game: CodeArena = get_arena(
2828
self.config,
2929
tournament_id=self.tournament_id,
3030
local_output_dir=self.local_output_dir,

configs/test/halite2.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ players:
1010
name: p2
1111
prompts:
1212
game_description: |
13-
You are a software developer ({{player_id}}) competing in an arena called Halite.
14-
In this game, you will write code to control ships that gather resources, build structures, and compete for dominance on a grid-based map.
15-
Victory is achieved by outmaneuvering opponents, optimizing resource collection, and strategically expanding your territory.
13+
You are a software developer ({{player_id}}) competing in an arena called Halite2.
14+
In this game, you will write code to control fleets of spaceships across a continuous space-themed universe.
15+
Players command ships to mine planets for halite, use that resource to build additional ships, and expand control across the map.
16+
Victory depends on efficient resource gathering, fleet management, and strategic expansion to outcompete rival bots for dominance.
1617
1718
The game is played in {{rounds}} rounds. For every round, you (and your competitor) edit program code that controls your bot. This is round {{round}}.
1819
After you and your competitor finish editing your codebases, the game is run automatically.

0 commit comments

Comments
 (0)