No description
Problem: At 25% spawn radius (5 tiles from center, 10 tiles apart), bots were too far apart. The zone started at radius 10 (maxDist + 5) and shrank by 2 tiles/turn. By turn 13, zone radius was 4, killing bots at distance 5 before they could reach attack range (5 tiles). Result: 0 combat deaths, only zone deaths. Solution: Reduce spawn radius to 20% (4 tiles from center, 8 tiles apart). Now zone starts at radius 9, shrinks to 5 by turn 12. Strategy bots (gatherer, rusher) move toward center, reaching attack range within 2-5 turns, ensuring combat before zone kills them. Results with 20% spawn radius: - Strategy bots: 100% combat deaths, 0 zone deaths, 2-5 turn matches - Random bots: 0% combat deaths, 100% zone deaths (expected per plan §3.7.1) - Achieves >65% combat density target with strategy bots This balances avoiding turn-1 mutual destruction while ensuring combat occurs before the zone kills bots. The zone serves as a forcing function per plan §3.7.1: aggressive bots fight, passive bots die. Closes: bf-5nmx Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .github/workflows | ||
| .wrangler/cache | ||
| bots | ||
| cmd | ||
| docs | ||
| engine | ||
| manifests | ||
| maps | ||
| metrics | ||
| migrations | ||
| notes | ||
| ratelimit | ||
| scripts | ||
| starters | ||
| wasm | ||
| web | ||
| .env.example | ||
| .gitignore | ||
| .needle-predispatch-sha | ||
| acb-map-evolver | ||
| arena.test | ||
| DEPLOYMENT.md | ||
| DEPLOYMENT_STEPS.md | ||
| docker-compose.bots.yml | ||
| docker-compose.workers.yml | ||
| fix-iad-acb-openbao.sh | ||
| fix-iad-acb-r2-credentials.sh | ||
| go.mod | ||
| go.sum | ||
| IAD-ACB-OPENBAO-FIX.md | ||
| IAD-ACB-R2-CREDENTIALS-FIX.md | ||
| Makefile | ||
| MATCH_LIST_TEST_RESULTS.md | ||
| MATCH_LIST_VERIFICATION_SUMMARY.md | ||
| PROGRESS.md | ||
| R2_ACCESS_KEY_SOURCE.md | ||
| README.md | ||
| REPLAY_VIEWER_TEST_RESULTS.md | ||
| REPLAY_VIEWER_VERIFICATION_SUMMARY.md | ||
| test-replay.json | ||
| test_routes.sh | ||
| wrangler.toml | ||
AI Code Battle
A competitive bot programming platform where participants write HTTP servers that control units on a grid world.
Overview
AI Code Battle is a game simulation platform where:
- Participants write bots in any language that expose HTTP endpoints
- Bots compete on a toroidal (wrapping) grid world
- Matches are executed offline and presented as completed replays
- A web platform shows leaderboards, match history, and replay viewers
Quick Start
Prerequisites
- Go 1.21+ (for game engine and CLI tools)
- Node.js 18+ (for web and worker components)
- Docker (for containerized deployment)
Running Locally
# Build CLI tools
go build ./cmd/acb-local
go build ./cmd/acb-mapgen
# Run a match between built-in bots
./acb-local -seed 42 -max-turns 100 -output replay.json -verbose
# Start web development server
cd web && npm install && npm run dev
# Open http://localhost:3000/
Viewing Replays
- Open the web app at
http://localhost:3000/ - Navigate to "Replay Viewer" in the menu
- Load a replay JSON file or enter a URL
Project Structure
ai-code-battle/
├── engine/ # Go game simulation library
│ ├── types.go # Core data types
│ ├── grid.go # Toroidal grid implementation
│ ├── game.go # Game state management
│ ├── turn.go # Turn execution phases
│ ├── replay.go # Replay recording
│ └── *_test.go # Test files
├── cmd/
│ ├── acb-local/ # CLI match runner
│ ├── acb-mapgen/ # Map generator
│ ├── acb-worker/ # Match execution worker
│ └── acb-indexer/ # Index builder for static files
├── web/ # Cloudflare Pages SPA
│ ├── src/
│ │ ├── pages/ # Page components
│ │ ├── replay-viewer.ts # Canvas replay renderer
│ │ └── app.ts # SPA entry point
│ └── public/ # Static assets
├── worker-api/ # Cloudflare Worker API
│ └── src/
│ ├── index.ts # Router + cron dispatcher
│ ├── jobs.ts # Job coordination
│ ├── bots.ts # Bot management
│ └── glicko2.ts # Rating system
├── bots/ # Strategy bot implementations
│ ├── random/ # Python - RandomBot
│ ├── gatherer/ # Go - GathererBot
│ ├── rusher/ # Rust - RusherBot
│ ├── guardian/ # PHP - GuardianBot
│ ├── swarm/ # TypeScript - SwarmBot
│ └── hunter/ # Java - HunterBot
└── docs/plan/ # Implementation plan
Strategy Bots
| Bot | Language | Strategy |
|---|---|---|
| RandomBot | Python | Random valid moves (baseline) |
| GathererBot | Go | Energy collection, avoid combat |
| RusherBot | Rust | Rush enemy cores aggressively |
| GuardianBot | PHP | Defend cores, cautious expansion |
| SwarmBot | TypeScript | Formation cohesion, group advance |
| HunterBot | Java | Target isolated enemies |
Deployment
See DEPLOYMENT.md for detailed deployment instructions.
Quick Deploy
# Start all strategy bots
docker-compose -f docker-compose.bots.yml up -d
# Start match workers
docker-compose -f docker-compose.workers.yml up -d
Testing
# Go engine tests
go test ./engine/... -v
# Worker API tests
cd worker-api && npm test
# Index builder tests
cd cmd/acb-indexer && npm test
Architecture
The platform uses a split architecture:
- Cloudflare (free tier): Static site, API endpoints, D1 database, R2 storage
- Rackspace Spot: Match workers, bot containers, index builder
See docs/plan/plan.md for the full implementation plan.
License
MIT