The Problem with AI-Generated Stories
I used Claude API to auto-generate an interactive story for Pride and Prejudice. It created a massive story with 43 nodes, but there was a problem.
It only had 3 endings.
The core feature of What If Classics is tracking reader choices to analyze their MBTI personality type. But with only 3 endings, you can’t properly distinguish between 16 MBTI types.
The bigger issue was the story structure. It used “convergent branching” where different paths merged back together. No matter what choices readers made, they’d end up on the same path.
Choice A ──┐
├──→ Common Path ──→ Ending
Choice B ──┘
In this structure, reader choices don’t really matter.
Why Did This Happen?
I reviewed the AI prompt. I asked for “minimum 8 endings” but got only 3.
Root cause analysis:
- Prompt wasn’t specific enough - “minimum 8” was vague
- Missing structural constraints - Didn’t explicitly specify “non-convergent branching”
- Weak validation - Only checked ending count, not structure
The Fix
I completely rewrote the prompt:
prompt += """
CRITICAL REQUIREMENTS (non-negotiable):
- **MINIMUM 12 unique endings (target: 12-16)** - This is NON-NEGOTIABLE
CRITICAL BRANCHING STRUCTURE:
- **NO PATH CONVERGENCE**: Once paths diverge, they must NEVER merge back
- **ACT 3 MUST BRANCH**: Final act (last 30%) should have 3-4 choice points
- **TREE STRUCTURE**: Think of it as a tree that only branches outward
"""
And added stronger validation logic:
if num_endings < 8:
issues.append(f"❌ CRITICAL: Only {num_endings} endings (MINIMUM: 8, target: 12-16)")
elif num_endings < 12:
warnings.append(f"Only {num_endings} endings (target: 12-16)")
The New Pride and Prejudice Story
Results with the improved generator:
Before:
- 43 nodes, 3 endings
- Convergent branching
- MBTI analysis impossible
After:
- 29 nodes, 12 endings
- Non-convergent tree structure
- Each ending includes descriptions for all 16 MBTI types
Four major branching points, each with 3 endings for a total of 12 unique conclusions:
Start
├─ Path A (Emotional Response)
│ ├─ Ending A1: Growth & Independence
│ ├─ Ending A2: Remorse & Reconciliation
│ └─ Ending A3: Active Redemption
│
├─ Path B (Analytical Observation)
│ ├─ Ending B1: Intellectual Equals
│ ├─ Ending B2: Scholarly Independence
│ └─ Ending B3: Understanding to Love
│
├─ Path C (Internal Conflict)
│ └─ ... (3 endings)
│
└─ Path D (Skeptical Inquiry)
└─ ... (3 endings)
AI Content Generation Pipeline
I built a system that automatically generates complete story packs:
Step 1: Style Guide Generation
- Uses Gemini 2.5 Flash to generate period-appropriate visual style images
- Pride and Prejudice uses English Regency period style
Step 2: Character Reference Generation
- Creates portraits for main characters (Elizabeth, Darcy, Jane, Wickham)
- Each character 2-2.2MB with consistent appearance
Step 3: Scene Illustration Generation
- Auto-generates 17 scene images
- References style guide and character portraits for consistency
- Each image ~2.3MB
Step 4: Markdown File Generation
- Auto-generates 29 markdown files (one per node)
- Ending nodes include MBTI personality reveal UI
Total Time: ~23 minutes
- Style guide: 2 minutes
- 4 characters: 5 minutes
- 17 scenes: 15 minutes
- 29 markdown files: 1 minute
Technical Challenges and Solutions
Spent a lot of time on Windows encoding issues. Korean Windows defaults to cp949 encoding, while JSON and Python scripts use UTF-8.
Had to explicitly specify UTF-8 for all file I/O:
# Fix console output encoding
if sys.platform == 'win32':
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
# Fix file read/write encoding
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
Fixed this across 5 Python scripts.
Key Learnings
1. Be specific with AI prompts “Minimum 12, target 12-16, non-negotiable” works much better than “minimum 8”
2. Define structural constraints explicitly Specifying “no path convergence, tree structure” is more important than asking for a “good story”
3. Validation is as important as generation Without automated validation logic, humans have to manually find problems in AI output
4. Visual consistency through references Using style guides and character references keeps all 17 images visually cohesive
Next Steps
The Pride and Prejudice story pack is now ready for deployment.
I’ll use the improved generator to create more classic literature adaptations:
- 1984 - The weight of dystopian choices
- The Great Gatsby - Social choices in the 1920s
- Metamorphosis - Existential dilemmas
To be continued…