Self-play / ML hooks: a steppable match API
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- javascript, typescript
- Domain
- api, backend, game-dev, machine-learning
Research direction
Start in server/src/types/environment.ts and trace tick(), drainBotWork(), and the runLoop pause guard; then review the /restart, /pause, and /speed routes in server/src/api/arena.ts and step_arena peers in server/src/api/mcp.ts. The issue names test/simulationIntegration.test.ts, test/api.test.ts, and test/mcp.test.ts for coverage. Done means bounded manual stepping returns arena state while respecting ownership, rate limits, and the live-loop guard.
Written by the indexing model from the issue text.
Description
A headless, steppable match API (run-N-ticks, read state) so people can train bots with reinforcement learning. The hard prerequisites already exist — a deterministic simulation, seeded RNG, and unbounded "max" speed — so what remains is an explicit step/read-state control (today you approximate it with set_arena_speed "max" + arena_status).
Effort: L
Migrated from ENHANCEMENTS.md (§4 Developer experience).
Implementation notes
Priority: medium — High-value for a niche (RL/tooling) audience, purely additive host-side API with no impact on core UX or stability for the primary browser-game user base.
Purpose
Lets an external RL/training loop drive a match tick-by-tick and read exact state after each step, instead of polling an unbounded run_match/SSE stream on wall-clock timers — turning the existing deterministic sim into a real training environment (gym-style step()), which is pure upside for stability since it adds no new bot-facing surface.
Implementation approach
- Add a public
Environment.step(n)inserver/src/types/environment.tsthat calls the existing privatetick()(used today only byrunLoop)ntimes synchronously in a loop, awaitingdrainBotWork()each time — reusetick()/drainBotWork()as-is, don't fork the physics. - Guard against racing the self-scheduling
runLoop: only allowstep()when!this.looping(mirrors theresume()guard at environment.ts:537), erroring otherwise so REST/MCP callers mustpausefirst, matchingrunMatchToDecision's pause/resume dance inserver/src/api/mcp.ts. - Cap ticks per call (an
Environment.MAX_DRAIN_ROUNDS-style constant) to bound compute per request. - REST: new
POST /steproute inserver/src/api/arena.tsregistered via the existingdual()helper (alongside/restart,/pause,/speed), gatedrequireOwner, under the compute rate limiter (middleware/rateLimit.ts). Response body:buildArenaStatus(util/arenaStatus.ts) so state is read in the same round-trip — no SSE needed for a training loop. - MCP: new
step_arenatool inserver/src/api/mcp.tsbesiderun_match/run_tournament, using the sameownedArenaresolution and returningarena_status/match_summary-shaped output. - No
compiler.ts/ bot-facing API changes — this is host-side orchestration, not something bots call. - UI: no required change (headless callers bypass SSE), but note
Environment.tick()still emits'tick'events, so if a spectator has the arena open viaui/src/util/arenaReducer.tswhile an external stepper drives it, ticks appear normally — nothing insimulate.tsneeds to change since it only interpolates between server ticks.
Key details to plan
- No DB/service changes: speed/seed/step are in-memory-only
Environmentfields already (see #142 re: no migrations). - Determinism relies on existing seeded PRNG (
setSeed/util/random.ts) — step API should document that reproducibility needs seed+step count, not wall time. - Security: bound
nand rate-limit like other compute-heavy MCP tools; reuserequireOwner/ownedArenaownership checks, no new sandbox exposure. - Testing: extend
test/simulationIntegration.test.ts's manual-tick pattern (tick/setClockfromtest/simEnv.ts) forEnvironment.step; add REST cases totest/api.test.ts(ownership/rate-limit/400s) and MCP cases totest/mcp.test.tsalongside existingrun_matchtests. - Depends loosely on #142 (DB migrations) only if step state is ever persisted (it shouldn't be). Effort L is realistic — main risk is get the
looping/pause interaction right so headless stepping can't double-run against a liverunLoop.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 11h 21m
- Merged PRs (30d)
- 21
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LeeAdcock/robocodeJs.com
-
enhancement priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LeeAdcock/robocodeJs.com#254 ·
Maintainers usually reply within 1 day
-
good first issue priority: low tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
LeeAdcock/robocodeJs.com#146 ·
Maintainers usually reply within 1 day
-
PR #319's 4xx health-rule change never took effect — env-level ConfigDocument shadows .ebextensionsOpenbug priority: medium tech-debt
Difficulty 4/5 Half a day Newbie friendliness 12/100
LeeAdcock/robocodeJs.com#410 ·
Maintainers usually reply within 1 day
-
priority: high tech-debt
Difficulty 3/5 Half a day Newbie friendliness 25/100
LeeAdcock/robocodeJs.com#409 · 2 comments ·
Maintainers usually reply within 1 day
-
priority: high tech-debt
Difficulty 4/5 1-2 days Newbie friendliness 8/100
LeeAdcock/robocodeJs.com#407 ·
Maintainers usually reply within 1 day
All issues in LeeAdcock/robocodeJs.com
Similar issues
-
bug ui-dashboard
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 91/100
caelestia-dots/caelestia#534 · 1 comment ·
Maintainers usually reply within 1 day
-
area: scripts bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tdk-landscape/tdk-cli-core#2706 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bobadilla-tech/biasmarket.com#402 ·
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
javvadivijayprasad/sel2pw#28 ·