Agent-as-Player scripting for Pockets gameplay — generate tests or live WebSocket sequences
Generate gameplay sequences where an automated agent plays Pockets: navigating grids, grabbing items, crafting recipes, exploring bags.
/agent-play [target] <goal>
Target parameter (optional, default: tui):
tui — Generate for the TUI client (Terminal.Gui). Default.godot — Generate for the Godot client.both — Generate for both clients.Examples:
/agent-play craft a Belt Pouch — TUI test (default)/agent-play godot navigate to forest and harvest/agent-play both verify all recipes craft successfullyAll three layers share Pockets.Core (GameState, GameSession, GameController) — gameplay logic is identical across clients. What differs is how input reaches the core and how output is verified.
tests/Pockets.Core.Tests/GameSession method calls — MoveCursor, ExecutePrimary, ExecuteGrab, etc.GameState properties (cell contents, hand, breadcrumbs, facility state)AgentPlayValidationTests.cstests/Pockets.App.Tests/TuiTestHarness wraps Terminal.Gui's FakeDriver for headless rendering. Inject keys via Application.Driver, read the 80×25 character buffer.FakeDriver is global/static — tests use [Collection("TUI")] to prevent concurrency.DebugWebSocketServer on port 9080. Send JSON commands, receive JSON state.{"action": "key", "key": "Primary"}
{"action": "click", "row": 0, "col": 2, "button": "Primary"}
{"action": "back"}
{"action": "tick"}
{"action": "state"}
{"action": "screenshot", "path": "/tmp/ss.png"}
{"handled": bool, "status": "...", "state": {...}}, or compare screenshots../run-godot.sh)| Goal | Layer |
|---|---|
| Verify game logic (crafting, navigation, items) | Core |
| Verify TUI rendering or key bindings | TUI |
| Verify Godot rendering or mouse/touch input | Godot |
| Full E2E: logic + visual | TUI and/or Godot |
When target is both, generate a Core domain test (covers logic) plus a WebSocket command sequence (covers Godot live).
Trigger: /agent-play craft a Belt Pouch
Generates an xUnit test that:
/data/ via ContentLoader.LoadFromDirectoryGameSession with TickMode.RogueFor TUI target, can additionally generate a TuiTestHarness-based test with buffer assertions.
Trigger: /agent-play godot live: grab rock and drop at (2,3)
Generates a sequence of WebSocket JSON commands for the running Godot game.
GameSession.Current state: cursor position, active bag contents, hand contents, breadcrumb depthGameSession methods (tests) or WebSocket JSON (Godot live)references/game-mechanics.md — GameKey enum, grid coords, facility lifecycle, tick modesreferences/agent-patterns.md — NavigateTo algorithm, grab/deliver pipeline, recipe cycling, code snippetsSee tests/Pockets.Core.Tests/Models/AgentPlayValidationTests.cs for the canonical example:
/data/NavigateTo, FindItemInGrid, GrabFromGrid, DeliverToSlot, GrabAndDeliver, SetFacilityRecipe, TickUntilCompletevar dataPath = GetDataPath(); // walks up to find Pockets.sln
var registry = ContentLoader.LoadFromDirectory(dataPath);
var recipes = registry.Recipes.Values.ToImmutableArray();
var facilityRecipeMap = registry.BuildFacilityRecipeMap();
// ... build state with facilities and materials ...
var session = GameSession.New(state, recipes, facilityRecipeMap, TickMode.Rogue);