AI DND - Chinese Interactive Fiction Game
Chinese AI-driven interactive fiction game powered by DeepSeek API and LangGraph, featuring dynamic story generation and multiple ending systems
Tech Stack

AI DND - Chinese Interactive Fiction Game
📋 Project Overview
After playing offline DND (Dungeon and Dragons) campaigns with friends since last year, we recognized that DND represents an ideal scenario for GenAI integration: combining character choices, narrative creation, and DM guidance to deliver immersive interactive experiences where player decisions truly matter.
While similar products exist in the English-speaking market, the Chinese market lacked quality AI-driven DND games. We spent several weeks developing a Chinese version featuring a three-engine architecture (AI Engine, Game Engine, Story Engine), where AI dynamically generates storylines based on both predefined story outlines and real-time player choices. The system includes complete user management, achievement systems, save management, and multiple ending branches. Although it's still far from a complete commercial DND game, it has become a fully functional playable MVP.
🚀 Key Features
Core Implementation
- Dual Story-Driving System: AI generates narratives influenced by both predefined story outlines and real-time player choices, ensuring story coherence
- Complete User Authentication System: JWT token authentication, user registration/login, profile management, and game progress tracking
- Intelligent Choice Generation: Auto-generates four style choices (Good/Neutral/Evil/Funny) each round, plus support for custom player input
- Hidden Parameter Influence System: Invisible parameters like humanity, trust, power craving affect final ending calculations
- Achievement & Save System: Automatic ending achievement unlocks, multiple save points, and game progress persistence
Technical Highlights
- Three-Engine Architecture: AI Engine for content generation, Game Engine for state management, Story Engine for overall flow coordination
- Independent Story Generator Module: LangGraph-based multi-agent collaboration system for campaign generation, supporting creation, evaluation, revision, and style adjustment
- Intelligent Story Guidance: Dynamic progress calculation based on story_nodes configuration, ensuring narrative progression toward predefined nodes
- Three-Phase Ending Flow: pre-ending (last choice consequences) → awaiting-final (user confirmation) → final-ending (ultimate resolution)
- Mobile H5 Optimization: Vue.js 3 responsive design with card-based story display, supporting categorized presentation of environment/story/status changes
💻 Project Detail
Technical Architecture
Our system adopts a frontend-backend separation architecture:
Backend Core Engines:
- AI Engine: Responsible for calling DeepSeek API to generate story content, choice options, and state updates
- Game Engine: Manages game state saving, loading, and validation with save point system support
- Story Engine: Controls game flow, coordinates AI generation and state management, handles progress analysis
Data Flow Process:
- User choice input → Story Engine analyzes current progress and stage
- Determines current node position and narrative direction based on story_nodes configuration
- AI Engine generates new content based on story history, character state, and hidden parameters
- Game Engine applies state updates and saves progress
- Frontend receives response and updates UI, displaying new narrative and choice options
Story Generator:
- Multi-Agent collaboration system using LangGraph framework
- Creative Agent handles initial creation, Evaluation Agent performs quality assessment
- Revisor Agent modifies based on feedback, Style Agent adjusts language style
- Format Agent finalizes into database-required format
Frontend Technology Stack:
- Vue.js 3 + native CSS for mobile-optimized interface
- Card-based narrative display supporting categorized presentation of environment descriptions, story content, and status changes
- Real-time progress tracking and achievement system
Data Design
Game State Structure:
- character_stats: Character status (health, energy, skill list, item list)
- hidden_parameters: Hidden parameters (affecting ending calculations, invisible to players)
- story_timeline: Complete game history timeline
- story_progress: Progress information and stage management
Campaign Data Structure:
- story_nodes: Defines story nodes and expected choice counts, supports dynamic progress calculation
- possible_endings: Multiple ending configurations based on hidden parameter condition matching
- initial_setting: Opening scene environment descriptions and narrative text
🎮 Game Showcase
Game Interface Screenshots
Here are the actual running interfaces of the AI DND game:
Mobile-responsive game main interface showcasing card-based story display and state management
AI-generated story content with four-style choices, supporting categorized display of environment descriptions, story content, and status changes
Complete user system including achievement display, progress tracking, and profile management
Online Experience
🎯 Game URL: https://dnd.harveywork.com/
Note: This is a fully playable online version demonstrating the complete AI-driven interactive fiction experience
📊 Project Impact
This project explores the application possibilities of AI in interactive entertainment, validating the feasibility of the following technical solutions:
- Chinese AI Content Generation: Maintaining narrative coherence and character consistency in complex contexts
- Multi-Agent Collaboration: Structured content generation workflows through LangGraph implementation
- Mobile AI Gaming: Lightweight H5 game architecture requiring no complex client installation
The project code is open-source, aiming to provide reference implementations for the Chinese AI game development community. As an MVP, it demonstrates core functionalities of AI-driven interactive story games, laying the technical foundation for subsequent product development. The game is now live at https://dnd.harveywork.com/, validating both the practicality of the technical approach and the feasibility of the user experience.
🛠️ Technology Stack
AI & Machine Learning:
- DeepSeek API (LLM Service)
- LangGraph (Multi-Agent Collaboration Framework)
- Chat Completion (Dialogue Generation)
- JSON Schema Validation (Structured Output)
Backend Technologies:
- Python (Core Development Language)
- FastAPI (Web Framework)
- SQLAlchemy (ORM Framework)
- SQLite (Data Storage)
- Pydantic (Data Validation)
Frontend Technologies:
- Vue.js 3 (Frontend Framework)
- HTML5/CSS3 (Mobile Optimization)
- Axios (HTTP Client)
- Responsive Design (Mobile Device Adaptation)
Game Engine:
- State Management Engine (Game Progress Tracking)
- Save System (Progress Save/Load)
- Multiple Ending Algorithm (Based on Hidden Parameters)
- Timeline Management (Historical Event Tracking)
Development & Deployment:
- Docker (Containerized Deployment)
- JWT (User Authentication)
- Environment Configuration Management
- API Documentation Generation (FastAPI Docs)
This project demonstrates the practical application value of AI technology in Chinese interactive entertainment content creation, providing viable technical pathways and architectural references for building more complex AI-driven games.