Commit graph

7 commits

Author SHA1 Message Date
jedarden
87e2298a0f fix(replay): ensure events array is always populated in turns
- Remove omitempty tag from Events field in ReplayTurn
- Create a proper slice copy of gs.Events in RecordTurn
- Prevents null events array in JSON output
- Fixes parsing errors in analysis scripts

Closes: bf-6amz0, bf-3l7tf
2026-05-26 21:12:12 -04:00
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
jedarden
8d15333f2b feat(wasm): implement RusherBot WASM with low-level interface per plan §11.2
- Rewrote wasm/bots/rusher/src/lib.rs with complete Rusher strategy:
  - BFS pathfinding to nearest enemy cores
  - Wall and enemy avoidance
  - Known enemy core tracking across turns
  - Minimal JSON parser for state/config
  - Custom bump allocator using __heap_base
- Updated Cargo.toml for no_std build with alloc crate
- Updated build.sh to use cargo directly (sandbox expects low-level exports)
- Output: 14KB WASM (much smaller than Go's 5MB due to no runtime)

The sandbox loader expects pointer-based WASM interface (allocate, init,
compute_moves, free_result) not wasm-bindgen's JavaScript bindings.
This implementation uses raw WASM exports compatible with createPointerBasedBridge.

Closes: bf-2d50
2026-05-25 17:41:49 -04:00
jedarden
6715c4b04b feat(wasm): add Go WASM engine build per plan §11.2, §13.1
- Create wasm/engine/ with main_wasm.go exporting loadState, step, runMatch,
  getReplay, getBots, getEnergy, getConfig, getState functions for browser
  sandbox use
- Add engine/wasm.go with Match type providing WASM-friendly interface
- Add wasm/engine/build.sh for GOOS=js GOARCH=wasm compilation
- Update wasm/Makefile to include engine target
- Successfully builds engine.wasm (~5.6 MB) with valid WASM magic number

The engine WASM enables production-accurate match execution in the browser
sandbox per plan §13.1. Build artifacts (.wasm files) are gitignored and
generated on-demand.

Closes: bf-1wew

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 17:31:25 -04:00
jedarden
3d8665ab49 fix(wasm): fix missing WASM bot builds per plan §11.2
- 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>
2026-05-25 17:07:55 -04:00
jedarden
1839f5e7d1 style: format Go files with gofmt
- cmd/acb-maps-loader/main.go
- wasm/bots/guardian/main.go
- wasm/bots/hunter/main.go
- wasm/bots/random/main.go
- web/package-lock.json (npm ci update)
2026-05-25 15:33:38 -04:00
jedarden
98276903e2 feat(wasm): add separate WASM bot builds for browser sandbox (plan §11.1)
Add wasm/bots/ directory with separate WASM builds for each bot:
- 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 (AssemblyScript → WASM): tight formations

Each bot exports the standard WASM interface:
- init(configJSON): initialize with game config
- compute_moves(stateJSON): return moves JSON
- free_result(ptr): no-op for Go/AS

Built WASM files output to wasm/dist/. Go WASM bots verified to build.

Closes: bf-2zi5

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 14:58:01 -04:00