Skip to content

Add Ants arena (fog-of-war swarm RTS) - #119

Merged
john-b-yang merged 4 commits into
mainfrom
ants
Jul 9, 2026
Merged

john-b-yang merged 4 commits into
mainfrom
ants

Conversation

@john-b-yang

Copy link
Copy Markdown
Contributor

Summary

Adds Ants, a fog-of-war swarm RTS in the spirit of the 2010 Google/Waterloo Ants AI Challenge. Each player commands many ants on a toroidal grid; every turn all ants move one cell at once. Highlights:

  • Fog of war — you only see within your ants' view radius; you remember the rest yourself.
  • Focus-fire combat — an ant dies unless it has strictly fewer attackers than every enemy attacking it (locally outnumbered = dead), so ganging up wins fights.
  • Food → growth — food adjacent to a single player's ants spawns a new ant on a hill.
  • Hills & razing — move onto an enemy hill to raze it; most hills razed (tiebreak: ants alive) wins.

Engine lives in its own repo (cloned by the Dockerfile, matching the other arenas): CodeClash-ai/Ants.

Bot API

def do_turn(obs: dict) -> list:   # list of [row, col, "N"/"S"/"E"/"W"] moves

Fog-limited obs: turn/max_turns, rows/cols (toroidal), the *radius2 constants, my_ants, my_hills, and only-where-visible enemy_ants, enemy_hills, food, water. do_turn runs in one long-lived process, so bots can remember the discovered map in module globals. Un-ordered ants stay; moving into water is ignored; two ants onto one cell both die.

Features

  • Deterministic + replayable, seeded per sim (symmetric maps/water/food vary per seed; half-shift symmetry makes 2-player games fair).
  • N-player capable (2-player default).
  • Replay renderer — spectator view of ants/hills/food/water with per-player ant & hill counts, per-sim winner via peek_winner.
  • Swarm starter bot (remembers water/hills, seeks food, razes known enemy hills, explores, avoids self-collisions) + README documenting the API and turn resolution.

Testing

  • Deterministic (same seed → identical games); starter beats an idle bot 10–0; ants grow, combat + razing occur; 3/4-player free-for-alls work.
  • Fog verified (enemy hill at dist²=512 invisible under view²=77; partial water visibility); maps verified symmetric + connected.
  • Full codeclash run configs/test/ants.yaml end-to-end (Docker build, sims, scoring, replay) passes.
Thin arena wrapper cloning CodeClash-ai/Ants, replay renderer (spectator view of
ants/hills/food/water, per-sim winner via peek_winner), registration, and test config.
…label default

- Sort AntsArena import (ruff isort) and reformat replay.py (ruff format)
- single_player: default commit_label to '' (fixes test_single_player_battlesnake KeyError)
… ants

# Conflicts:
#	codeclash/replay/__init__.py
@john-b-yang
john-b-yang merged commit fc25764 into main Jul 9, 2026
5 checks passed
@john-b-yang
john-b-yang deleted the ants branch July 9, 2026 20:51
@john-b-yang john-b-yang mentioned this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant