ai-code-battle/wasm/bots
jedarden 306b0d2c5f feat(wasm): implement SwarmBot AssemblyScript WASM with full strategy per plan §11.2
Implements complete SwarmBot formation-based combat strategy in AssemblyScript:
- JSON parsing for game config and state
- Tight cohesion (radius=3) movement with circular mean center-of-mass
- Enemy-seeking behavior with engagement bonuses
- Toroidal distance calculations

Builds to 27KB swarm.wasm (AssemblyScript produces compact binaries vs
Go's ~12MB). Build script now copies to dist/.

Closes: bf-2a7w

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 17:45:46 -04:00
..
gatherer feat(wasm): add separate WASM bot builds for browser sandbox (plan §11.1) 2026-05-25 14:58:01 -04:00
guardian style: format Go files with gofmt 2026-05-25 15:33:38 -04:00
hunter style: format Go files with gofmt 2026-05-25 15:33:38 -04:00
random style: format Go files with gofmt 2026-05-25 15:33:38 -04:00
rusher feat(wasm): implement RusherBot WASM with low-level interface per plan §11.2 2026-05-25 17:41:49 -04:00
swarm feat(wasm): implement SwarmBot AssemblyScript WASM with full strategy per plan §11.2 2026-05-25 17:45:46 -04:00
Makefile feat(wasm): add separate WASM bot builds for browser sandbox (plan §11.1) 2026-05-25 14:58:01 -04:00
README.md feat(wasm): add separate WASM bot builds for browser sandbox (plan §11.1) 2026-05-25 14:58:01 -04:00

WASM Bot Builds

This directory contains the WebAssembly builds for the browser sandbox. Each bot compiles to a separate WASM module with the standard interface.

Bot WASM Interface

Each WASM module exports three functions:

// Initialize the bot with game config
bot.init(configJSON: string): string // {ok: bool, error?: string}

// Compute moves for the current turn
bot.compute_moves(stateJSON: string): string // moves JSON array

// Free result (no-op for Go/AS, required for interface compatibility)
bot.free_result(ptr: number): void

Directory Structure

wasm/bots/
├── gatherer/     # Go → WASM (energy-focused, avoids combat)
├── random/       # Go → WASM (random moves)
├── guardian/     # Go → WASM (defends own cores)
├── hunter/       # Go → WASM (hunts nearest enemy)
├── rusher/       # Rust → WASM (attacks enemy cores)
└── swarm/        # TypeScript/AssemblyScript → WASM (tight formations)

Building

Build all bots:

cd wasm/bots
make all

Build individual bot:

cd wasm/bots/gatherer
./build.sh

Output directory: wasm/dist/

Bot Sizes (estimated)

Bot Language Size
gatherer Go → WASM ~12 MB
random Go → WASM ~10 MB
guardian Go → WASM ~12 MB
hunter Go → WASM ~12 MB
rusher Rust → WASM ~3 MB
swarm AssemblyScript → WASM ~5 MB

Plan Reference

This implements plan §11.1 lines 2566-2576 and plan §13.1 WASM sandbox.