From b6f56f22fd9465cee335f584794bb641ccfffbdc Mon Sep 17 00:00:00 2001 From: Dejvino Date: Wed, 1 Jul 2026 23:15:22 +0200 Subject: [PATCH] Better turn coherence --- tools/engine.py | 4 +++- tools/engine_lib/validation.py | 5 ++++- tools/run.py | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/engine.py b/tools/engine.py index 5c14563..0a6a095 100644 --- a/tools/engine.py +++ b/tools/engine.py @@ -47,7 +47,7 @@ class GameEngine: model = lm.get("model", "ollama/llama3.1") if on_action: - on_action(f"LLM: {model} | temp={lm.get('temperature')}") + on_action("DM is preparing a response") if on_debug: on_debug("config", {"model": model, "temperature": lm.get("temperature"), "max_tokens": lm.get("max_tokens"), "strategy": "tools"}) @@ -131,6 +131,8 @@ class GameEngine: state_changes.append(tc) # Validate the generated turn + if on_action: + on_action("DM is validating the response") if player_action and book_log: valid, reason, action = validate_turn( player_action, diff --git a/tools/engine_lib/validation.py b/tools/engine_lib/validation.py index 29d827b..b8095c4 100644 --- a/tools/engine_lib/validation.py +++ b/tools/engine_lib/validation.py @@ -106,7 +106,8 @@ TURN_VALIDATION_PROMPT = """You are a strict RPG game master validating a genera 1. **Action Sense**: Did the player's request make sense given the character, inventory, and world state? 2. **Story Coherence**: Is the story evolution coherent, non-contradictory, and within the game world's logic? 3. **State Correctness**: Do the planned state changes match the narrative? Are they valid given current state? -4. **Log Entry**: Does the log entry accurately summarise the narrative in 1-2 short, dense sentences? Should be specific, factual, and immediately readable. +4. **Self-Contained Narrative**: The narrative must read clearly on its own — explicitly describe what the character did in response to the action. Do not skip the character's action and jump straight to consequences. Each turn must make sense without referencing the player action line. +5. **Log Entry**: Does the log entry accurately summarise the narrative in 1-2 short, dense sentences? Should be specific, factual, and immediately readable. ## Character (before changes) {character} @@ -143,6 +144,8 @@ Check all criteria. **Completeness** is critical — scan the narrative for ever - **NPC/location/thread changes** → must have `world_update` or `add_note` Missing tool calls = regenerate. Also check that: +- The narrative explicitly describes the character acting — not just the world reacting +- A reader should understand what happened without seeing the "Player Action" line above - Items removed were actually in inventory - Items added are reasonable and don't duplicate existing items - HP/cash changes follow logically from the narrative diff --git a/tools/run.py b/tools/run.py index d01703b..510b374 100755 --- a/tools/run.py +++ b/tools/run.py @@ -110,7 +110,7 @@ class ChaosTUI(App): self._spinner_frames = ["◴", "◷", "◶", "◵"] self._thinking_frame = 0 self._thinking_timer_handle = None - self._dm_action = "DM is weaving the narrative" + self._dm_action = "DM is preparing a response" self._roll_event = threading.Event() self._roll_result: str | None = None self._book_page = 0 @@ -283,7 +283,7 @@ class ChaosTUI(App): self.query_one("#debug-content", DebugPane).append(f"[{ts}] {text}") def _show_thinking(self) -> None: - self._dm_action = "DM is weaving the narrative" + self._dm_action = "DM is preparing a response" self._thinking_frame = 0 status = self.query_one("#play-status", Static) status.add_class("processing")