Better turn coherence

This commit is contained in:
Dejvino 2026-07-01 23:15:22 +02:00
parent b67017c02c
commit b6f56f22fd
3 changed files with 9 additions and 4 deletions

View File

@ -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,

View File

@ -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

View File

@ -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")