ai-code-battle/PROGRESS.md
jedarden 4f77980398 Complete Phase 3: TypeScript Canvas replay viewer
- Add web/ directory with TypeScript + Vite build tooling
- Implement ReplayViewer class with Canvas-based grid rendering
- Add play/pause, scrub, and speed controls with keyboard shortcuts
- Implement fog of war perspective toggle per player
- Add score overlay with player names, scores, and energy
- Support loading replays from local file or URL
- Add match info panel and event log display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 07:30:04 -04:00

5.6 KiB

AI Code Battle - Implementation Progress

Current Phase: Phase 3 - Replay Viewer

Status: COMPLETE

Phase 1 Completed

  • Go module initialization (github.com/aicodebattle/acb)
  • Project structure (engine/, cmd/acb-local/, cmd/acb-mapgen/)
  • Core types (engine/types.go)
  • Grid implementation (engine/grid.go) - Toroidal wrapping, distances, visibility
  • Game state (engine/game.go) - State management, fog of war
  • Turn execution (engine/turn.go) - Movement, combat, capture, energy, spawn
  • Replay writer (engine/replay.go) - Full replay JSON format
  • Match runner (engine/match.go) - Concurrent bot communication
  • Map generator (cmd/acb-mapgen/) - Rotational symmetry, connectivity validation
  • Unit tests - 32+ tests passing, determinism verified

Phase 2 Completed

  • HMAC Authentication (engine/auth.go)
    • Request signing: {match_id}.{turn}.{timestamp}.{sha256(body)}
    • Response signing: {match_id}.{turn}.{sha256(body)}
    • Timestamp tolerance (30s) for replay attack prevention
    • Secret generation (256-bit, hex-encoded)
  • HTTP Bot Client (engine/bot_http.go)
    • HTTPBot implementing BotInterface
    • Per-turn timeout (3s default)
    • Crash detection (10 consecutive failures)
    • Move validation (position ownership, direction validity)
    • Response signature verification
  • Integration Tests (engine/integration_test.go)
    • Full HTTP match between mock bots
    • HMAC authentication round-trip
    • Response signing verification
  • Strategy Bot Implementations (6 languages)
    • RandomBot (Python) - Random moves, rating floor
    • GathererBot (Go) - Energy-focused, combat avoidance
    • RusherBot (Rust) - Aggressive core rushing
    • GuardianBot (PHP) - Defensive core protection
    • SwarmBot (TypeScript) - Formation-based combat
    • HunterBot (Java) - Target isolation and hunting

Phase 3 Completed

  • Web project setup (web/)
    • TypeScript + Vite build tooling
    • Type definitions matching Go replay format
  • ReplayViewer class (web/src/replay-viewer.ts)
    • Canvas-based grid rendering
    • Bot, core, energy, wall visualization
    • Player color coding (6 distinct colors)
  • Playback controls
    • Play/pause toggle
    • Turn-by-step navigation (prev/next)
    • Turn scrubber slider
    • Speed control (20ms - 1000ms per turn)
    • Keyboard shortcuts (Space, arrows, Home/End)
  • Fog of War perspective toggle
    • Per-player visibility calculation
    • Vision radius from game config
  • Score overlay
    • Real-time scores per player
    • Energy held display
    • Player name with color indicator
  • Match info panel
    • Match ID, winner, turns, reason
  • Event log
    • Turn-by-turn event display
  • File/URL loading
    • Local file upload
    • Remote URL fetch

Exit Criteria Progress

Criterion Status
TypeScript Canvas-based replay viewer Complete
Play/pause, scrub, speed control Complete
Fog of war perspective toggle Complete
Score overlay Complete
Loads replay JSON from file or URL Complete

Next Phase: Phase 4 - Match Orchestration

Status: Ready to start

File Structure

ai-code-battle/
├── go.mod
├── engine/
│   ├── types.go        # Core data types
│   ├── grid.go         # Toroidal grid implementation
│   ├── game.go         # Game state management
│   ├── turn.go         # Turn execution phases
│   ├── replay.go       # Replay recording
│   ├── match.go        # Match runner
│   ├── bot_local.go    # Local bot interface
│   ├── bot_http.go     # HTTP bot client
│   ├── auth.go         # HMAC authentication
│   └── *_test.go       # Test files
├── cmd/
│   ├── acb-local/      # CLI match runner
│   └── acb-mapgen/     # Map generator
├── web/
│   ├── package.json    # npm dependencies
│   ├── tsconfig.json   # TypeScript config
│   ├── vite.config.ts  # Vite bundler config
│   ├── index.html      # Replay viewer page
│   └── src/
│       ├── types.ts        # Replay type definitions
│       ├── replay-viewer.ts # Canvas viewer class
│       └── main.ts         # UI controller
├── bots/
│   ├── random/         # Python - RandomBot
│   ├── gatherer/       # Go - GathererBot
│   ├── rusher/         # Rust - RusherBot
│   ├── guardian/       # PHP - GuardianBot
│   ├── swarm/          # TypeScript - SwarmBot
│   └── hunter/         # Java - HunterBot
└── docs/
    └── plan/
        └── plan.md     # Full implementation plan

Strategy Bot Summary

Bot Language Strategy Expected Rank
RandomBot Python Random valid moves 6th (floor)
GathererBot Go Energy collection, avoid combat 4th-5th
RusherBot Rust Rush enemy cores aggressively 4th-5th
GuardianBot PHP Defend cores, cautious expansion 3rd-4th
SwarmBot TypeScript Formation cohesion, group advance 1st-2nd
HunterBot Java Target isolated enemies 1st-2nd

Running Tests

# Go engine tests
go test ./engine/... -v

# Web build verification
cd web && npm run build

Building CLI Tools

go build ./cmd/acb-local
go build ./cmd/acb-mapgen

Running a Match

./acb-local -seed 42 -max-turns 100 -output replay.json -verbose

Viewing a Replay

cd web
npm run dev
# Open http://localhost:3000 and load replay.json