PromptBuilder
in package
Builds the model's *user* turn — a compact, deterministic digest of one {@see AgentObservation} plus the carry-over context ({@see AutoPlayer} feeds last turn's decision, its outcome, the recent-history window, the combine bookkeeping and any forced loop-break objective).
The system turn (strategy) is Playbook::systemPrompt(); the two are assembled in AgentBrain::decide(). Split out of AgentBrain so the ~300 lines of string assembly here stay clear of the decision/parse logic.
Pure formatting — no game transport, no side effects. The one collaborator is Ladder::suggestion(), whose pick is surfaced as the "SUGGESTED next action" line to anchor a weak model.
Tags
Table of Contents
Methods
- build() : string
- Compact, deterministic digest of an observation for the model's user turn.
- compactArgs() : string
- Compact `{"k":v,...}` rendering for the recent-turns line — short enough to list eight of them without bloating the prompt.
- pairs() : string
- rows() : string
Methods
build()
Compact, deterministic digest of an observation for the model's user turn.
public
static build(AgentObservation $observation[, array{verb: string, args: array, reason: string, tick: ?int}|null $lastDecision = null ]) : string
Surfaces every field the Playbook decision ladder needs — score, holdings, economy/social boards, threats, the expansion board — while staying terse.
Parameters
- $observation : AgentObservation
- $lastDecision : array{verb: string, args: array, reason: string, tick: ?int}|null = null
-
The previous turn, if known.
Return values
stringcompactArgs()
Compact `{"k":v,...}` rendering for the recent-turns line — short enough to list eight of them without bloating the prompt.
private
static compactArgs(array<string, mixed> $args) : string
Parameters
- $args : array<string, mixed>
Return values
stringpairs()
private
static pairs(array<string, mixed> $map, int $limit) : string
Parameters
- $map : array<string, mixed>
- $limit : int
Return values
stringrows()
private
static rows(array<int, mixed> $rows, int $limit, callable(array<string|int, mixed>): string $format) : string
Parameters
- $rows : array<int, mixed>
- $limit : int
- $format : callable(array<string|int, mixed>): string