Phase 7 Evolution: - Add live-export subcommand to acb-evolver for dashboard JSON generation - Export programs, stats, and generation log to live.json Phase 8 Enhanced Features: - Add WASM game engine build (cmd/acb-wasm/) with JS bindings - Add in-browser sandbox page with Monaco editor (web/src/pages/sandbox.ts) - Add win probability computation (web/src/win-probability.ts) - Add replay commentary generator (web/src/commentary.ts) - Add clip maker for GIF/MP4 export (web/src/pages/clip-maker.ts) - Add rivalry detection and pages (web/src/pages/rivalries.ts) - Add replay feedback system (web/src/pages/feedback.ts) - Add evolution dashboard page (web/src/pages/evolution.ts) Phase 9 Platform Depth: - Add predictions API (cmd/acb-api/predictions.go) - Add series management API (cmd/acb-api/series.go) - Add seasons API (cmd/acb-api/seasons.go) - Add narrative generator for rivalries (cmd/acb-indexer/src/narrative.ts) Engine Updates: - Add debug field to move response schema - Add match event timeline extraction - Add replay enrichment fields Web Updates: - Update app.html navigation for new pages - Add API client methods for predictions, series, seasons - Export engine types for browser use Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
//go:build js && wasm
|
||
|
||
// random.wasm – random-strategy bot implementing the ACB WASM bot interface.
|
||
//
|
||
// Exported JS object (global acbBot):
|
||
//
|
||
// acbBot.init(configJSON) – initialise; resets RNG seed
|
||
// acbBot.compute_moves(stateJSON) – returns JSON move array
|
||
package main
|
||
|
||
import (
|
||
"encoding/json"
|
||
"math/rand"
|
||
"syscall/js"
|
||
"time"
|
||
|
||
"github.com/aicodebattle/acb/engine"
|
||
)
|
||
|
||
var rng *rand.Rand
|
||
|
||
func jsInit(_ js.Value, args []js.Value) interface{} {
|
||
rng = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||
return map[string]interface{}{"ok": true}
|
||
}
|
||
|
||
func jsComputeMoves(_ js.Value, args []js.Value) interface{} {
|
||
if len(args) < 1 {
|
||
return jsErr("stateJSON required")
|
||
}
|
||
var state engine.VisibleState
|
||
if err := json.Unmarshal([]byte(args[0].String()), &state); err != nil {
|
||
return jsErr("parse: " + err.Error())
|
||
}
|
||
bot := engine.NewRandomBot(rng.Int63())
|
||
moves, _ := bot.GetMoves(&state)
|
||
b, _ := json.Marshal(moves)
|
||
return string(b)
|
||
}
|
||
|
||
func jsErr(msg string) map[string]interface{} {
|
||
return map[string]interface{}{"ok": false, "error": msg}
|
||
}
|
||
|
||
func main() {
|
||
done := make(chan struct{})
|
||
js.Global().Set("acbBot", js.ValueOf(map[string]interface{}{
|
||
"init": js.FuncOf(jsInit),
|
||
"compute_moves": js.FuncOf(jsComputeMoves),
|
||
}))
|
||
<-done
|
||
}
|