No description
Find a file
jedarden e88749b134 Add Traefik ingress, TLS certificate, and Argo CI/CD pipeline manifests
- Traefik IngressRoute for api.aicodebattle.com with CORS, security
  headers, and rate limiting (100 req/min)
- cert-manager Certificate (Let's Encrypt prod, ECDSA P-256)
- Argo Events webhook EventSource + Sensor (triggers on master push)
- Argo Workflows: parallel Kaniko builds for all 10 container images
  plus web SPA site build, with layer caching
- CI ServiceAccount + RBAC for workflow execution
- Registry credentials SealedSecret template

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 01:26:01 -04:00
.github/workflows Add GitHub Actions CI workflow for automated testing and builds 2026-03-24 10:54:43 -04:00
bots Complete Phase 2: HTTP protocol and 6 strategy bots 2026-03-24 07:00:38 -04:00
cmd Add Go API server (cmd/acb-api) with PostgreSQL, Valkey, and Glicko-2 2026-03-26 01:21:48 -04:00
deploy/k8s Add Traefik ingress, TLS certificate, and Argo CI/CD pipeline manifests 2026-03-26 01:26:01 -04:00
docs Restore hybrid architecture: Cloudflare Pages + R2 for web, K8s for compute 2026-03-24 23:24:22 -04:00
engine Fix sin/cos math bug and add cellular automata map generation 2026-03-26 01:10:46 -04:00
web Add Kubernetes manifests for ArgoCD GitOps deployment 2026-03-26 00:57:48 -04:00
worker-api Add .gitignore and package-lock.json files 2026-03-24 10:30:03 -04:00
.env.example Start Phase 6: Add deployment configuration and containers 2026-03-24 09:41:14 -04:00
.gitignore Add Prometheus metrics endpoint to match worker 2026-03-26 00:50:10 -04:00
DEPLOYMENT.md Add health monitoring endpoints for Phase 6 2026-03-24 10:08:11 -04:00
docker-compose.bots.yml Start Phase 6: Add deployment configuration and containers 2026-03-24 09:41:14 -04:00
docker-compose.workers.yml Start Phase 6: Add deployment configuration and containers 2026-03-24 09:41:14 -04:00
go.mod Add Go API server (cmd/acb-api) with PostgreSQL, Valkey, and Glicko-2 2026-03-26 01:21:48 -04:00
go.sum Add Go API server (cmd/acb-api) with PostgreSQL, Valkey, and Glicko-2 2026-03-26 01:21:48 -04:00
PROGRESS.md Add Traefik ingress, TLS certificate, and Argo CI/CD pipeline manifests 2026-03-26 01:26:01 -04:00
README.md Add README.md with project overview and quick start guide 2026-03-24 10:39:32 -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/app.html

Viewing Replays

  1. Open the web app at http://localhost:3000/app.html
  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