[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,68 +2,187 @@
|
||||
id: wiki-2026-0508-procedural-narrative-generation
|
||||
title: Procedural Narrative Generation
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-PRON-001]
|
||||
aliases: [PNG, Story Generation, Computational Narrative, Drama Management]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.94
|
||||
tags: [auto-reinforced, narrative-design, interactive-storytelling, pcg, ai-writing]
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [narrative, generative-ai, games, llm-applications]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: Python / TypeScript
|
||||
framework: LLM (Claude/GPT) + planner / state machine
|
||||
---
|
||||
|
||||
# [[Procedural Narrative Generation|Procedural Narrative Generation]]
|
||||
# Procedural Narrative Generation
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "살아 움직이는 이야기의 공장: 고정된 시나리오 대신 유저의 선택과 상황적 변수를 조합하여, 매번 새로운 서사적 경험을 만들어내는 동적 스토리텔링 시스템."
|
||||
## 매 한 줄
|
||||
> **"매 algorithmic story authoring — symbolic planners 부터 LLM-driven emergent narrative 까지"**. 1970s TaleSpin / 1990s drama managers (Façade) 의 lineage; 2019 AI Dungeon 으로 LLM era 시작, 2024-2026 currently agent-based simulation (Smallville, Voyager, Genesis) 에서 narrative emerges from LLM agents interacting in worlds. Hybrid 가 winning: LLM creativity + symbolic constraints.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
절차적 서사 생성(Procedural Narrative Generation)은 알고리즘과 AI를 활용하여 게임이나 인터랙티브 미디어의 줄거리를 실시간으로 생성하는 기술입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **생성 메커니즘**:
|
||||
* **Grammar-based**: 트레이서리(Tracery)와 같은 문법 엔진을 사용하여 문장 구조를 조합하여 텍스트 생성.
|
||||
* **Simulation-based (Dwarf Fortress 방식)**: 수많은 NPC들의 욕구와 행동이 충돌하며 자연스럽게 역사와 사건이 창발되도록 함.
|
||||
* **LLM-driven**: 대규모 언어 모델을 활용하여 맥락과 감정이 실린 풍부한 대사 및 플롯 전개 생성.
|
||||
2. **핵심 도전 과제**:
|
||||
* **Narrative Paradox**: 생성된 이야기의 '자유도'와 서사적 '완성도/감동' 사이의 균형을 맞추는 일.
|
||||
* **Consistency**: 긴 호흡의 이야기에서 앞뒤 설정이 충돌하지 않게 유지하는 논리적 일관성.
|
||||
3. **가치**:
|
||||
* 유저마다 독특한 자신만의 이야기를 갖게 하여 게임의 다시하기 가치(Replayability) 극대화.
|
||||
### 매 paradigm timeline
|
||||
- **Story grammars (1970s-80s)**: Propp's morphology, Rumelhart, TaleSpin (Meehan 1977).
|
||||
- **Planning-based (1990s-2010s)**: STRIPS planners author plot (IPOCL, MEXICA).
|
||||
- **Drama management (2000s)**: Façade (Mateas & Stern 2005) reactive narrative.
|
||||
- **Neural (2017-2020)**: GPT-2/3 generated stories, Plug-and-Play LMs.
|
||||
- **AI Dungeon era (2019-)**: open-ended LLM-driven IF.
|
||||
- **Agent simulation (2023-2026)**: Park's Smallville, Voyager, Genesis world model — believable agents whose interactions form narrative.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 "알고리즘이 쓴 이야기는 영혼이 없다"는 비판이 강했으나, 최근 인지 과학적 스토리 텔링 기법(Story Skeletons)을 AI에 입히며 인간 작가의 보조를 넘어 공동 집필 수준으로 발전함.
|
||||
- **정책 변화(RL Update)**: AI가 도덕적으로 부적절하거나 혐오적인 서사를 생성하지 않도록 '서사적 안전 가이드라인(Safe Storytelling Policy)'을 모델의 사후 처리 레이어에 의무적으로 적용하는 정책이 마련됨.
|
||||
### 매 challenges
|
||||
1. **Coherence**: long-range plot consistency (LLMs forget).
|
||||
2. **Causality**: events must causally connect.
|
||||
3. **Character agency**: characters with goals/personalities, not just templates.
|
||||
4. **Author's vs character's intent**: meta-level narrative goals vs in-world goals.
|
||||
5. **Tellability**: not every simulation is a good story.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Procedural Rhetoric, Foundational Models, [[Psychology & Behavior|Psychology & Behavior]], [[Game Design Theory|Game Design Theory]]
|
||||
- **Modern Tech/Tools**: GPT-4 (Roleplay), Tracery, Inform 7, OpenAI Sora (visual narrative).
|
||||
---
|
||||
### 매 modern hybrid stack
|
||||
- **World model**: structured state (locations, items, NPCs, relationships).
|
||||
- **LLM as narrator**: takes state + recent events → next beat.
|
||||
- **Symbolic planner**: enforces causal constraints, beats arc.
|
||||
- **Memory / retrieval**: vector DB of past events for consistency.
|
||||
- **Drama manager**: monitors arc (rising/falling tension), nudges plot.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### LLM beat generator with state
|
||||
```python
|
||||
def generate_beat(state, history, beat_target):
|
||||
prompt = f"""You are a narrator. Current state:
|
||||
Characters: {state.characters}
|
||||
Location: {state.location}
|
||||
Inventory: {state.inventory}
|
||||
Recent events: {history[-5:]}
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
Beat target: {beat_target} # e.g., "rising tension", "reveal villain"
|
||||
Generate the next narrative beat (2-3 sentences) and any state changes as JSON."""
|
||||
resp = claude.messages.create(
|
||||
model="claude-opus-4-7",
|
||||
max_tokens=400,
|
||||
messages=[{"role": "user", "content": prompt}],
|
||||
)
|
||||
return parse(resp.content[0].text)
|
||||
```
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Story-arc drama manager (Freytag)
|
||||
```python
|
||||
ARC = ["exposition", "rising_action", "climax", "falling_action", "resolution"]
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
class DramaManager:
|
||||
def __init__(self, n_beats=20):
|
||||
# Map beat index to arc stage
|
||||
self.targets = ([ARC[0]] * 3 + [ARC[1]] * 8 + [ARC[2]] * 2
|
||||
+ [ARC[3]] * 4 + [ARC[4]] * 3)
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
def next_target(self, beat_idx, tension_so_far):
|
||||
target = self.targets[beat_idx]
|
||||
if target == "rising_action" and tension_so_far < 0.3:
|
||||
return "rising_action_inject_conflict"
|
||||
return target
|
||||
```
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
### Goal-based character agent
|
||||
```python
|
||||
class CharacterAgent:
|
||||
def __init__(self, name, traits, goals):
|
||||
self.name, self.traits, self.goals = name, traits, goals
|
||||
self.memory = [] # recent observations
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
def choose_action(self, world_state):
|
||||
# LLM call: given personality + memory + state, pick action
|
||||
prompt = f"""You are {self.name}. Traits: {self.traits}.
|
||||
Active goals: {self.goals}.
|
||||
Recent: {self.memory[-10:]}.
|
||||
World: {world_state}.
|
||||
What do you do next? Output: action(target, args)."""
|
||||
return llm(prompt)
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### Causal consistency check
|
||||
```python
|
||||
def verify_beat(beat, state):
|
||||
"""Reject beats that violate world rules."""
|
||||
issues = []
|
||||
for change in beat.state_changes:
|
||||
if change.kind == "use_item" and change.item not in state.inventory:
|
||||
issues.append(f"{change.item} not in inventory")
|
||||
if change.kind == "location" and change.to not in state.adjacent_locs:
|
||||
issues.append(f"non-adjacent move {state.location}->{change.to}")
|
||||
return issues # caller re-prompts on issues
|
||||
```
|
||||
|
||||
### Memory-augmented retrieval (Smallville-style)
|
||||
```python
|
||||
def retrieve_relevant(query, memory_db, k=5):
|
||||
"""Score = recency + importance + relevance (cosine)."""
|
||||
now = time.time()
|
||||
scored = []
|
||||
for m in memory_db:
|
||||
recency = 0.99 ** ((now - m.t) / 3600)
|
||||
relevance = cosine(embed(query), m.embedding)
|
||||
score = recency + m.importance + relevance
|
||||
scored.append((score, m))
|
||||
return [m for _, m in sorted(scored, reverse=True)[:k]]
|
||||
```
|
||||
|
||||
### Branching narrative (interactive fiction)
|
||||
```python
|
||||
def turn(state, player_input):
|
||||
candidates = generate_n_continuations(state, player_input, n=3)
|
||||
chosen = drama_manager.pick(candidates, state.arc_position)
|
||||
state = apply(state, chosen)
|
||||
state.history.append(chosen)
|
||||
return state, chosen.text
|
||||
```
|
||||
|
||||
### Constrained generation w/ JSON schema
|
||||
```python
|
||||
schema = {"type": "object", "properties": {
|
||||
"narration": {"type": "string"},
|
||||
"state_changes": {"type": "array", "items": {...}},
|
||||
"tension_delta": {"type": "number", "minimum": -1, "maximum": 1},
|
||||
}, "required": ["narration", "state_changes"]}
|
||||
# Use response_format=json_schema with Claude / GPT-5
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Short interactive story | Pure LLM w/ state in prompt |
|
||||
| Long campaign (RPG) | LLM + structured world DB + retrieval |
|
||||
| Strong authorial intent | Planner + LLM surface text |
|
||||
| Emergent simulation | Agent-based (Smallville pattern) |
|
||||
| Branching narrative game | Drama manager + tree-of-beats |
|
||||
|
||||
**기본값**: LLM beat-generator + structured world state + drama manager + retrieval memory.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Computational-Narrative]] · [[Generative-AI]] · [[Game-AI]]
|
||||
- 변형: [[Interactive-Fiction]] · [[Drama-Management]] · [[Story-Grammars]]
|
||||
- 응용: [[AI-Dungeon]] · [[NPC-Dialogue]] · [[Generative-Agents]] · [[Tabletop-RPG-AI]]
|
||||
- Adjacent: [[Large-Language-Models]] · [[Planning]] · [[World-Models]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: games (RPG, IF), creative writing tools, simulation, training data for narrative tasks.
|
||||
**언제 X**: factual reporting, deterministic content (ads/legal), regulated medical/legal narration.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Pure LLM, no state**: forgets at chapter 3, introduces dead characters.
|
||||
- **Planner-only, no LLM**: prose feels mechanical.
|
||||
- **No drama curve**: flat tension → boring.
|
||||
- **Unbounded creativity**: LLM invents items/locations with no consistency check.
|
||||
- **Single-shot 100k-token story**: better as iterative beats with state.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Park et al 2023 Generative Agents UIST, Mateas & Stern 2005, Riedl & Bulitko 2013 survey).
|
||||
- 신뢰도 A (theory) / B (rapidly evolving practice).
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full PNG history + 2026 hybrid LLM/agent stack |
|
||||
|
||||
Reference in New Issue
Block a user