ai-code-battle/PROGRESS.md
jedarden 890785c5c4 Complete Phase 1: add connectivity validation and determinism tests
- Add connectivity.go: BFS-based map connectivity validation with retry
- Update mapgen to use connectivity checking by default
- Add determinism_test.go: property-based tests for reproducibility
  - Same seed produces identical replays
  - Turn execution is deterministic
  - Grid operations are deterministic
  - Combat resolution is deterministic
  - Full 500-turn match validation
- All 32 tests pass
- Update PROGRESS.md: Phase 1 complete

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

4.1 KiB

AI Code Battle - Implementation Progress

Current Phase: Phase 1 - Core Engine

Status: COMPLETE

Completed

  • Go module initialization (github.com/aicodebattle/acb)
  • Project structure (engine/, cmd/acb-local/, cmd/acb-mapgen/)
  • Core types (engine/types.go)
    • Position, Tile, Direction, Bot, Core, EnergyNode, Player
    • Config with default values
    • MatchResult, VisibleState (fog-filtered state)
  • Grid implementation (engine/grid.go)
    • Toroidal wrapping
    • Distance calculations (squared for performance)
    • Visibility computation
    • Wall/obstacle handling
  • Game state (engine/game.go)
    • State management for bots, cores, energy, players
    • Bot spawning and killing
    • Fog of war filtering
  • Turn execution (engine/turn.go)
    • Movement phase with collision detection
    • Focus-fire combat resolution
    • Core capture mechanics
    • Energy collection (contested resources)
    • Bot spawning at active cores
    • Energy node ticking
    • Win condition checking (elimination, draw, dominance, turns)
  • Replay writer (engine/replay.go)
    • Full replay JSON format
    • Turn-by-turn state recording
  • Match runner (engine/match.go)
    • Concurrent bot communication
    • Per-turn timeout
    • Symmetric map generation
  • Local bot interface (engine/bot_local.go)
    • RandomBot, IdleBot implementations
  • CLI runner (cmd/acb-local/main.go)
    • Configurable parameters (seed, size, turns)
    • Replay output
  • Map generator (cmd/acb-mapgen/main.go)
    • Rotational symmetry (2/3/4/6 players)
    • Configurable density
  • Unit tests for core engine
    • Grid operations, wrapping, distances
    • Combat resolution (1v1, 2v1, formations)
    • Core capture
    • Energy collection
    • Spawning
    • Win conditions
  • Map generator connectivity validation (cmd/acb-mapgen/connectivity.go)
    • BFS-based connectivity check
    • Retry mechanism for connected map generation
  • Determinism tests (engine/determinism_test.go)
    • Same seed produces identical replays
    • Turn execution is deterministic
    • Grid operations are deterministic
    • Combat resolution is deterministic
    • Replay serialization round-trip
    • Full 500-turn match validation

Exit Criteria Progress

Criterion Status
Can run a complete 500-turn match locally Works
Produce a valid replay file Works
Comprehensive unit tests 32 tests passing

Next Phase: Phase 2 - HTTP Protocol & Strategy Bots

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
│   ├── grid_test.go    # Grid tests
│   └── turn_test.go    # Turn execution tests
├── cmd/
│   ├── acb-local/      # CLI match runner
│   │   └── main.go
│   └── acb-mapgen/     # Map generator
│       └── main.go
└── docs/
    └── plan/
        └── plan.md     # Full implementation plan

Key Design Decisions

  1. Position-based moves: Bots are identified by their current position in the move protocol (not bot IDs), which works better with fog of war.

  2. Squared distances: Using squared distances throughout (Distance2, Radius2) avoids expensive square root operations.

  3. Simultaneous resolution: Combat deaths are computed first, then applied, ensuring true simultaneous resolution.

  4. Symmetric map generation: Maps are generated by creating one sector and rotating for all players.

Running Tests

go test ./engine/... -v

Building CLI Tools

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

Example Usage

# Run a match
./acb-local -seed 42 -max-turns 100 -output replay.json -verbose

# Generate a map
./acb-mapgen -players 2 -rows 60 -cols 60 -output map.json