- Fix rusher Rust compilation: add #[derive(Default)] to structs (GameConfig, PlayerInfo, Position, Move, VisibleBot, VisibleCore) to fix serde #[serde(default)] compilation errors - Fix swarm AssemblyScript build: remove namespace export, simplify to minimal working implementation, fix build script to use -o flag (assemblyscript outputs to build/ directory) - Create wasm/Makefile to orchestrate building all 6 WASM bots Acceptance status: ✓ Fix rusher Rust compilation errors (cargo check passes) ✓ Fix swarm build script (swarm.wasm now builds successfully) ✓ Create wasm/Makefile for orchestrating builds ✓ 5 of 6 WASM files now exist in dist/ (gatherer, guardian, hunter, random, swarm) ⚠ rusher.wasm requires wasm-pack (not installed in this environment) but Rust code compiles successfully Note: rusher.wasm can be built with: wasm-pack build --target web --out-dir ../../dist/rusher && cp dist/rusher/rusher_wasm_bg.wasm dist/rusher.wasm Closes: bf-25o6 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| gatherer | ||
| guardian | ||
| hunter | ||
| random | ||
| rusher | ||
| swarm | ||
| Makefile | ||
| README.md | ||
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.