Interactive and agent-api control gameplay#28
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the browser-side control architecture needed to support both human keyboard/touch gameplay and API-driven agent gameplay. The existing browser game is now driven through a shared maze-action contract, with separate
interactiveandagent-apicontrol modes layered on top of the same runtime, traversal, rendering, persistence, and scoring behavior.What Changed
Maze Control Modes
MazeActionControlinterface for browser control modes.interactivemode for human keyboard and touch input.agent-apimode for HTTP-driven maze traversal by configured agents.Agent API Runtime
Added an agent polling loop that sends the current maze state to configured agents.
Supports batched move predictions using the response shape:
{ "moves": ["MoveRight", "MoveDown"] }Replays submitted moves in order and stops on the first invalid move or when the destination is reached.
Applies score decay based on submitted predictions or fixed mistake decay for malformed responses.
Disables agents on network/HTTP/timeout failures without applying score decay.
Moves the game into
await-agentstate when no enabled agents are available.Agent Context Payload
MazeActionState.playerNameper traversal entry so multiple agents can share the same maze while retaining per-agent movement history.{ row, col }logical cell coordinates for agent-facing payloads.Traversal Cleanup
frontend/app/traversal.tsto centralize movement and coordinate logic.Persistence Updates
interactiveandagent-apistate do not collide.Rendering And UI Behavior
await-agentstatus rendering for agent-api mode.agents.htmlto initialize the agent-api control mode.index.htmlto initialize the interactive control mode.isAgentApiMode()andisInteractiveMode()for clearer status branching.Maze And Viewport Improvements
length * widthlogic.Configuration Cleanup
CONFIGinto nested sections for runtime, messages, controls, maze, generation, scoring, timing, viewport, storage, and agent API settings.Testing
Added and expanded frontend tests for:
Current frontend test coverage includes:
agent-context.test.tscontrol/agent-api.test.tscontrol/agent.test.tscontrol/interactive.test.tscontrol/session-actions.test.tstraversal.test.tsgame.test.ts,render.test.ts,storage.test.ts, and maze testsValidation
The following checks pass locally:
Frontend tests pass with
100tests across14test files.