A collection of Java bots developed for MIT Battlecode 2025.
Team bytebyte: 91/504 placement in the leaderboards.
Battlecode is a strategy programming competition in which every robot runs autonomously. The 2025 game centers on spreading paint, constructing towers on ruins, managing resources, and fighting for control of the map.
This repository preserves several generations of the bot. The latest generation is s2rd.
Battlecode robots have limited vision, separate memory, and a fixed computation budget each turn. The bot therefore uses local algorithms instead of maintaining a shared map or planning the entire game ahead.
Battlecode robots have limited vision and do not know the map beforehand, so diffusion is used to explore when there is no clear target.
Each robot keeps moving in one direction until it is blocked by a wall or another robot, then changes direction and continues exploring. When it finds a ruin or enemy tower, the relevant target behavior takes priority.
Implementation: diffusion movement.
Each robot selects between a small number of behaviors using its current observations and stored state.
A soldier prioritizes tower combat, active construction, new construction, and finally exploration. Flags and counters preserve unfinished work between turns, while higher-priority behaviors stop lower-priority behaviors from running that turn.
Implementation: soldier controller.
Robots must act before they know the rest of the map, so they repeatedly choose the best option visible during the current turn.
Soldiers select the nearest unfinished ruin, attackers select the nearest enemy tower, and towers prefer low-health targets. Moppers search every possible swing direction and choose the one that hits the most enemies.
Implementations: ruin selection, tower selection, tower target selection, and mop swing search.
Resource patterns occupy fixed areas of the map, so placing them is a grid-packing problem.
Before starting a pattern, a soldier checks for unfinished ruins and conflicting resource patterns. It permits the cardinal spacing where neighboring patterns fit, then converts map positions into coordinates within the pattern to paint the correct cells.
Implementation: resource pattern placement.
| Package | Role |
|---|---|
s1 |
First integrated bot with construction, combat, and economy logic in one controller. |
s1d, s1d2, s1dMixed |
Movement experiments combining diffusion, paint awareness, and different robot behaviors. |
s2 |
Refactor into separate controllers for soldiers, moppers, splashers, towers, pathing, and tower engagement. |
s2rd |
Latest generation, adding energy-based diffusion, crowd awareness, reflected spawn directions, and further economy tuning. |
The older packages are useful snapshots of how individual ideas changed during development rather than merely obsolete copies.
java/src/— Java bot implementations.java/maps/— custom Battlecode maps.java/test/— Java test sources.
The project uses the official Battlecode 2025 scaffold.
From the java directory:
./gradlew build
./gradlew run -PteamA=s2rd -PteamB=s2 -Pmaps=DefaultSmallOn Windows, use gradlew.bat in place of ./gradlew.
The bot names and map can also be changed in java/gradle.properties.