Skip to content

Add dynamic seat-guidance layer to LLM following prompt#414

Merged
ejfn merged 2 commits into
mainfrom
ejfn/llm-dynamic-seat-guidance
Jun 1, 2026
Merged

Add dynamic seat-guidance layer to LLM following prompt#414
ejfn merged 2 commits into
mainfrom
ejfn/llm-dynamic-seat-guidance

Conversation

@ejfn
Copy link
Copy Markdown
Owner

@ejfn ejfn commented Jun 1, 2026

This PR implements a programmatic dynamic seat-guidance layer to the LLM following prompt and integrates it with the core engine's memory context.

Key Changes:

  1. Dynamic Seat Guidance (localBuildSeatGuidance):
    • Generates a highly specialized strategic directive for the LLM based on seat, teammate winning safety (SECURED/LIKELY/UNCERTAIN), points at stake, and suit void status.
    • Instructs the LLM to treat this section as its primary instruction, reducing reasoning complexity for smaller models.
  2. Single-Source Memory Context Integration:
    • Integrates engine's MemoryContext to retrieve player voids dynamically, eliminating the need to parse historical tricks on-the-fly.
    • Uses isComboUnbeatable from the engine to check if a teammate's currently winning card is an off-suit boss.
  3. Live Points Tracker (localFormatLiveOffSuitPoints):
    • Estimates outstanding points in each off-suit still in other players' hands or the hidden kitty, guiding the LLM's card selection.
  4. Prompt & Skill Documentation Update:
    • Refines STATIC_LLM_GAME_RULES for better consistency and instructs the LLM on reading the seat-guidance section.
    • Updates prompt-refinement/SKILL.md to version 1.3.0 documenting this architecture.

ejfn and others added 2 commits June 1, 2026 11:26
Inject a situation-specific "Guidance for this seat" bullet into the
following prompt, computed in code from the trick state so a small model
no longer has to retrieve-then-apply the static rules itself. This is the
surgical, per-seat layer the static system prompt couldn't be without
global blast radius.

- localBuildSeatGuidance: one applied bullet per (teammate-winning + safe /
  opponent-winning + points + trump-vs-offsuit / void / last-seat), naming
  concrete players and spelling out the beat-back inference.
- Memory-aware boss: reuse isComboUnbeatable so a K is treated as boss once
  both Aces are played; "boss" is now strictly off-suit (trump uses an
  "unbeatable top trump" notion instead — there is no boss in trump).
- #411.2 gate: when the player holds nothing that beats the current winner
  in-suit, guide to duck rather than dump a matching boss/point card.
- #413: in a trump trick a regular K/10 isn't beat-back-proof — don't pour
  a point card into a trick a later active rank/joker captures.
- Trick Win Security verdict extended: a trump trick where all remaining
  opponents are out of trump now reads as safe.
- "Points still live" off-suit readout (localFormatLiveOffSuitPoints):
  unseen point-card value per side suit as a reference (counts both deck
  copies; kitty treated as unseen).
- Static rules deduped against the guidance: §5.1 defers to the verdict,
  §9 trimmed to positional insight, §5.3 4th-player parenthetical dropped,
  boss-matching reframed as a heuristic.
- prompt-refinement skill (v1.3.0): documents the seat-guidance layer and
  the requirement that its decision table stay aligned with §5/§6/§9.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
buildLLMUserPrompt now builds the engine's GameContext once and reads
trick-winner analysis, per-player void memory, played-card memory, and
attacking status from it — the same source the rule-based AI uses.

- Remove detectSuitVoidsFromHistory (a second, independent void-detection
  algorithm that lived only in the LLM path and could drift from the
  memory system). Voids now project from MemoryContext.playerMemories
  (suitVoids + trumpVoid → the "Trump Group" string the prompt consumes),
  which also accounts for the in-progress trick.
- Winner/points/trump-lead facts read from trickWinnerAnalysis; isAttacking
  and attackingPoints from the context; unbeatable detection is fed
  memoryContext.playedCards instead of re-gathering trick cards.
- Off-suit boss detection is gated on the teammate winning (its only use),
  avoiding the isComboUnbeatable call when an opponent leads.

Verified equivalent: a remaining opponent confirmed void in the led suit
still flips a teammate's boss Ace to UNCERTAIN (ruff threat), and the
memory-boss / can't-beat seat guidance is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ejfn ejfn enabled auto-merge (squash) June 1, 2026 08:04
@ejfn ejfn merged commit 5b5d599 into main Jun 1, 2026
1 check passed
@ejfn ejfn deleted the ejfn/llm-dynamic-seat-guidance branch June 1, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant