No description
Find a file
jedarden 4b7d81db45 feat(index-builder): bundle warm-set replays as static Pages assets
Per bead bf-3e60: instead of copying B2->R2 (warm cache), bundle warm-set
replays, thumbnails, cards, and evolution live.json directly into the Pages
deploy directory as static assets (dist/data/). This serves replays same-origin,
eliminating R2 dependency and 404 errors.

Changes:
- Add B2Client interface for testable B2 operations
- Add bundleWarmReplays(): copies replays/*.json.gz from B2 to dist/data/replays/
- Add bundleWarmThumbnails(): copies thumbnails/*.png from B2 to dist/data/thumbnails/
- Add bundleWarmCards(): copies cards/*.png from B2 to dist/data/cards/
- Add bundleEvolutionLive(): copies evolution/live.json from B2 to dist/data/evolution/
- Replace promoteRecentReplaysForCycle() with bundleWarmAssetsForCycle()
- Remove R2 pruning logic from main loop (no longer needed)
- Add unit tests for all bundling functions with mock B2 client

Replays are served gzipped (as-is from B2) to keep deploy size under Pages'
25MB file limit. Frontend will gunzip client-side (separate bead bf-5cwi).

All tests pass (go test ./...).

Closes: bf-3e60
2026-05-26 07:35:48 -04:00
.github/workflows chore(ci): disable GitHub Actions — CI/CD is handled by Argo Workflows 2026-04-21 08:43:22 -04:00
.wrangler/cache feat(worker): add map engagement score tracking and verify win_prob in replays 2026-05-03 23:21:57 -04:00
bots feat(bots): make SwarmBot and RusherBot actively seek combat 2026-05-26 03:20:11 -04:00
cmd feat(index-builder): bundle warm-set replays as static Pages assets 2026-05-26 07:35:48 -04:00
docs docs(plan): update attack radius and zone parameters to match implementation 2026-05-25 13:31:10 -04:00
engine feat(engine): initialize 40% of energy nodes with energy at match start 2026-05-26 03:15:03 -04:00
manifests K8s deployments and ExternalSecrets for extended bot fleet 2026-05-22 14:58:41 -04:00
maps feat(maps): add seed map library for initial deployment (plan §3.8) 2026-05-25 08:42:12 -04:00
metrics feat(acb-enrichment): implement AI replay enrichment service 2026-05-04 02:22:28 -04:00
migrations feat(maps): add seed maps for initial library (plan §3.8) 2026-05-25 08:18:49 -04:00
notes docs: verify bf-67io - SQL migration file already exists 2026-05-22 16:17:33 -04:00
ratelimit feat(api): implement POST /api/request-enrichment endpoint 2026-05-04 02:58:11 -04:00
scripts style: format generate-maps-index.go with gofmt 2026-05-25 18:59:24 -04:00
starters fix(starter-kits): complete incomplete refactoring and fix build errors 2026-05-25 22:40:37 -04:00
wasm feat(wasm): implement SwarmBot AssemblyScript WASM with full strategy per plan §11.2 2026-05-25 17:45:46 -04:00
web test(web): add Director Mode unit tests per §16.10 2026-05-25 23:16:42 -04:00
.env.example docs: Update deployment guide for K8s + B2 architecture 2026-03-29 11:24:06 -04:00
.gitignore chore: add generated maps directory to gitignore 2026-05-25 21:39:20 -04:00
.needle-predispatch-sha chore: update needle predispatch sha 2026-05-22 16:04:10 -04:00
acb-map-evolver style: apply gofmt alignment fixes across codebase 2026-05-24 10:40:33 -04:00
arena.test fix(types): add missing ReplayPlayer import and type annotation for transcript feature 2026-04-22 18:20:56 -04:00
DEPLOYMENT.md feat(scripts): add R2 bucket setup script with custom domain config 2026-04-06 06:42:53 -04:00
DEPLOYMENT_STEPS.md docs: add deployment completion instructions 2026-04-08 16:55:20 -04:00
docker-compose.bots.yml feat(deploy): register 10 Phase 13 expansion bots in docker-compose.bots.yml 2026-04-22 17:55:56 -04:00
docker-compose.workers.yml Start Phase 6: Add deployment configuration and containers 2026-03-24 09:41:14 -04:00
fix-iad-acb-openbao.sh feat(worker): add map engagement score tracking and verify win_prob in replays 2026-05-03 23:21:57 -04:00
fix-iad-acb-r2-credentials.sh feat(worker): add map engagement score tracking and verify win_prob in replays 2026-05-03 23:21:57 -04:00
go.mod fix(worker): upgrade aws-sdk-go-v2 to fix B2 upload error 2026-04-28 22:56:47 -04:00
go.sum fix(worker): upgrade aws-sdk-go-v2 to fix B2 upload error 2026-04-28 22:56:47 -04:00
IAD-ACB-OPENBAO-FIX.md feat(worker): add map engagement score tracking and verify win_prob in replays 2026-05-03 23:21:57 -04:00
IAD-ACB-R2-CREDENTIALS-FIX.md feat(worker): add map engagement score tracking and verify win_prob in replays 2026-05-03 23:21:57 -04:00
Makefile feat(cmd): add acb-maps-loader to load map library into database 2026-05-25 14:50:38 -04:00
MATCH_LIST_TEST_RESULTS.md test(web): verify match list page renders cards with real matches 2026-04-25 11:42:47 -04:00
MATCH_LIST_VERIFICATION_SUMMARY.md test(web): verify match list page renders cards with real matches 2026-04-25 11:58:02 -04:00
PROGRESS.md docs(progress): verify all Phase 12 gap items already implemented 2026-04-23 06:49:24 -04:00
R2_ACCESS_KEY_SOURCE.md docs: add R2 access key source investigation summary 2026-04-29 10:26:00 -04:00
README.md refactor(web): promote app.html to index.html as homepage 2026-04-25 08:51:52 -04:00
REPLAY_VIEWER_TEST_RESULTS.md test(web): verify match list page renders cards with real matches 2026-04-25 11:42:47 -04:00
REPLAY_VIEWER_VERIFICATION_SUMMARY.md test(web): verify match list page renders cards with real matches 2026-04-25 11:58:02 -04:00
test-replay.json feat(web): add embeddable replay widget route (plan §13.4) 2026-05-25 08:21:44 -04:00
test_routes.sh test(web): add SPA route smoke test script and results 2026-05-24 21:57:49 -04:00
wrangler.toml feat(ci): configure Cloudflare Pages build output directory 2026-04-08 17:07:37 -04:00

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

  1. Open the web app at http://localhost:3000/
  2. Navigate to "Replay Viewer" in the menu
  3. 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