Skip to content

mudmini009/DualPath-Core-TTRPG-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

122 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏰 DualPath-Core

A Multi-Agent Hybrid TTRPG Engine | FIBO Senior Thesis (2026)

Project Status Ruleset Model


πŸŽ“ FIBO SENIOR THESIS (2026) - FINAL RELEASE & GRADUATION DEMO Next-Gen Agentic Orchestration for Tabletop RPGs

This project features a Multi-Agent Hybrid Architecture designed to solve the "AI Hallucination" problem in TTRPGs. By implementing a Two-Path Orchestrator, the system autonomously routes player intent between a Deterministic Python Rules Engine (for mechanical precision) and an LLM-based Creative Arbiter (for improvisational logic). Through a rigorous Multi-Agent Handshake, the engine ensures that all game state mutations are grounded in hard-coded logic while maintaining the narrative flexibility of Large Language Models.

πŸŽ“ Thesis Artifact Download Center

Document Type File Link Key Focus Area
πŸ“„ Thesis Report docs/ΰΈ­.ΰΉ‚ΰΈ‹ΰΉˆ-ΰΈ­.ΰΈ›ΰΈ­-AI DM-FinalSenior.pdf Full academic manuscript, methodology & diagrams
πŸ“Š Defense Slides docs/Thesis_Final.pdf Final Q&A presentation slide deck
πŸ–ΌοΈ Academic Poster docs/65340500046_Poster.pdf Senior project showcase poster

πŸ“Š Core Features

  • βš”οΈ Two-Path Architecture β€” Automatically routes player intent to either the rules engine (Path A) or creative LLM arbiter (Path B).
  • 🎲 Stateless Rules Engine β€” Pure Python logic calculates D&D 5e dice checks, AC, combat math, and ranges deterministically.
  • πŸ€– LLM Arbiter β€” Evaluates creative roleplay actions, determines DC, and returns symbolic status conditions (STUNNED, PRONE).
  • πŸƒ Tactical Zone Combat β€” Grid-less zone-based movement (NEAR, MID, FAR) with automatic distance restrictions.
  • πŸƒ Initiative Turn Queue β€” Dynamic round sequencing rolling d20 + PHYS for fair turn order.
  • 🧠 Contextual Short Memory β€” Efficient sliding-window deque limits LLM prompt context to the last 10 round states.
  • πŸ“œ Campaign Logging β€” Background logging of player actions and system mathematical check logs to campaign_log.txt.
  • ⚑ Dynamic Sequence Actions β€” Combines movement and combat in specified orders (e.g. "move NEAR and smite").
  • πŸŽ’ Inventory Engine β€” Dynamic auto-looting, disposable items, and strict consumable tracking.
  • πŸ—£οΈ Narrative Diplomacy β€” Talk out of encounters utilizing social checks and the PACIFIED state.
  • πŸ’‘ Developer Debug Mode β€” Diagnostic toggle exposing raw LLM outputs, AST structures, and dice rolls.

πŸ“œ Game Rules

For the complete mechanical breakdown of the FIBO Lite 5th Edition system, check out the official rulebook:


πŸ› οΈ How to Run

Prerequisites:

  • Python 3.10+
  • Gemini API Key (set in .env as GOOGLE_API_KEY)

Launch the Demo:

# Initialize environment (Example using Conda)
conda activate ai_dm_core

# Install dependencies
pip install -r requirements.txt

# Run the dedicated launcher
python main.py

πŸš€ Quick Start / Installation

  1. Clone the Repository

    git clone [repository_url]
    cd AI_Dungeon_Master
  2. Install Dependencies

    pip install -r requirements.txt
  3. Get a Free API Key

  4. Setup the Environment (Pick ONE method)

    • The Automatic Way: Just run the game! (python main.py). The system will detect that you are missing a key, pause the game, and prompt you to paste it in the terminal. It will then automatically create the .env file for you.
    • The Manual Way: Create a new file named .env in the root folder of this project and paste your key inside like this:
      GEMINI_API_KEY=your_key_here_xyz123
  5. Configure Settings (Optional)

    • You can tweak the engine's behavior without touching Python code!
    • Open data/settings.json to configure:
      • Memory Queue Size (max_history_events)
      • Default Difficulty Classes (default_dc)
      • AI Creativity (arbiter_temperature, narrator_temperature)
      • Target Fuzzy Matching strictness (fuzzy_match_cutoff).
    • Note: If you delete this file, the engine will safely regenerate it with default values.
  6. Run the Game

    python main.py

πŸ“‚ Project Structure

AI_Dungeon_Master/
β”œβ”€β”€ docs/                    # [THESIS] Graduation reports, presentation slides, posters, and system manuals
β”‚   β”œβ”€β”€ Thesis_Final.pdf         # Defense presentation slides
β”‚   β”œβ”€β”€ ΰΈ­.ΰΉ‚ΰΈ‹ΰΉˆ-ΰΈ­.ΰΈ›ΰΈ­-AI DM-FinalSenior.pdf # Final graduation thesis report
β”‚   └── 65340500046_Poster.pdf   # Project academic poster
β”œβ”€β”€ archive/                 # [HISTORY] Past iterations and research
β”‚   β”œβ”€β”€ phase2_demo/         # Old FIBO lab scripts and demo JSONs
β”‚   β”œβ”€β”€ references/          # Academic research papers and references
β”‚   └── old_docs/            # Past presentations and progress reports
β”œβ”€β”€ main.py                  # [ENTRY] Full game entry point and dedicated launcher
β”œβ”€β”€ LITE_5E_RULES.md         # [RULES] The formal "Lite 5e" rulebook for the AI and Player
β”œβ”€β”€ ARCHITECTURE.md          # [DOCS] High-level system design overview (proposed Two-Path engine)
β”œβ”€β”€ requirements.txt         # [DEPS] Project dependencies (frozen from conda env)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agents/              # [AGENTS] Specialized LLM agents
β”‚   β”‚   β”œβ”€β”€ base.py          # BaseLLMProvider – shared API setup & model init
β”‚   β”‚   β”œβ”€β”€ arbiter_agent.py # ArbiterAgent – creative action evaluation & side effects
β”‚   β”‚   β”œβ”€β”€ narrator_agent.py# NarratorAgent – descriptions & flavor text
β”‚   β”‚   β”œβ”€β”€ campaign_agent.py# CampaignAgent – recaps & prologue cold-opens
β”‚   β”‚   β”œβ”€β”€ character_agent.py# CharacterAgent – world lore & background setup
β”‚   β”‚   β”œβ”€β”€ quest_architect_agent.py # QuestArchitectAgent – high-level quest summary
β”‚   β”‚   └── quest_cartographer_agent.py # QuestCartographerAgent – map generation & 7-Layer Guardrails
β”‚   β”œβ”€β”€ engine/              # [ORCHESTRATOR] Pre-game flow & main loop
β”‚   β”‚   β”œβ”€β”€ startup.py       # Pre-game flow: character sheets, API key checks, prologue
β”‚   β”‚   └── game_loop.py     # Main loop orchestrating Explore/Combat transitions
β”‚   β”œβ”€β”€ ui/                  # [CLI] Presentation layer (HUD and menus)
β”‚   β”‚   β”œβ”€β”€ character_sheet.py # Character stats & world lore renderer
β”‚   β”‚   β”œβ”€β”€ dashboard.py     # ASCII target trackers & status bars
β”‚   β”‚   β”œβ”€β”€ menu.py          # Main, recap, and pause menus
β”‚   β”‚   β”œβ”€β”€ combat_ui.py     # Combat HUD and log renderer
β”‚   β”‚   └── exploration_ui.py# Exploration/Hub HUD with command hints & quest boards
β”‚   β”œβ”€β”€ router/              # [THE BRAIN] Intent Classification & Routing
β”‚   β”‚   β”œβ”€β”€ intent_router.py # Two-path orchestrator routing player input
β”‚   β”‚   β”œβ”€β”€ intents.py       # Intent execution (Smite constraints & moves check)
β”‚   β”‚   └── exploration_router.py # Regex/LLM hybrid router
β”‚   β”œβ”€β”€ logic/               # [CALCULATOR] Pure Python Mechanics
β”‚   β”‚   β”œβ”€β”€ rules_engine.py  # D&D 5e dice checks, AC, combat calculations
β”‚   β”‚   β”œβ”€β”€ combat_manager.py# Initiative queue manager
β”‚   β”‚   β”œβ”€β”€ enemy_ai.py      # Enemy target selection (lowest HP focus)
β”‚   β”‚   β”œβ”€β”€ enemy_factory.py # Skeleton & Flesh scaling algorithm
β”‚   β”‚   β”œβ”€β”€ dice_roller.py   # Base RNG rolls
β”‚   β”‚   β”œβ”€β”€ abilities.py     # Ability registry
β”‚   β”‚   └── time_manager.py  # Time flow & automatic rest healing logic
β”‚   β”œβ”€β”€ models/              # [STATE] Single Source of Truth
β”‚   β”‚   β”œβ”€β”€ character.py     # Character dataclass (stats, abilities, conditions)
β”‚   β”‚   β”œβ”€β”€ game_state.py    # GameState container
β”‚   β”‚   └── toon_converter.py# Bidirectional TOON parser
β”‚   └── services/            # [IO] External APIs & Save/Load Persistence
β”‚       β”œβ”€β”€ llm_service.py   # Backward-compatible agent facade
β”‚       β”œβ”€β”€ data_manager.py  # Campaign saving/loading system
β”‚       └── rag_service.py   # Context synthesis
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ active/              # Live session data (session state & continuous logs)
β”‚   β”‚   β”œβ”€β”€ campaign_active.json # Current active save file
β”‚   β”‚   β”œβ”€β”€ campaign_log.txt     # Irreversible campaign session history
β”‚   β”‚   └── world_lore.txt       # Active lore context
β”‚   β”œβ”€β”€ config/              # User-facing settings & database templates
β”‚   β”‚   β”œβ”€β”€ settings.json        # Dynamic engine parameters (max history, DC, etc.)
β”‚   β”‚   β”œβ”€β”€ settings_backup.json # Safe settings fallback
β”‚   β”‚   └── bestiary.json        # Enemy blueprint databases
β”‚   └── premade/             # Out-of-the-box template databases
β”‚       β”œβ”€β”€ characters/      # Precompiled class JSONs
β”‚       └── lore/            # Pre-written setting files
└── evaluation/              # [QA] Comprehensive validation suites
    β”œβ”€β”€ combat/              # Old combat simulation files
    β”‚   β”œβ”€β”€ evaluation_runner.py # Combat-only runner
    β”‚   └── scenario_suite.json  # 50 scenarios
    └── system_suite/        # Full System Q/A & comparative suite
        β”œβ”€β”€ comprehensive_runner.py # Comparative 90-scenario runner
        β”œβ”€β”€ generate_master_suite.py# Programmatic scenario generator
        β”œβ”€β”€ master_scenario_suite.json # Full 90-scenario master suite
        └── results/             # Proposed vs Baseline CSV summaries and trace logs

🧩 Architectural Philosophy

The system is built as a "Stateless Symbolic Machine" utilizing a Hybrid-Arbitrated Two-Path System to ensure 100% mechanical consistency while maintaining narrative freedom.

  1. Rule-First Decisioning (Path A): If an action matches a standard game mechanic (Attack, Move, Item), the AI is bypassed for the calculation. The Python engine handles the math deterministically.
  2. Symbolic Grounding (Path B): When the AI allows a creative action (e.g., "I pull the rug"), it must return a Symbolic Side Effect (e.g., target_condition: PRONE). The Python engine then applies this to the live model.
  3. TOON Serialization: Uses a custom compact format (Token-Oriented Object Notation) for game state to reduce LLM token usage by up to 50%, ensuring faster response times and lower costs.

(Note: Earlier extensive architectural drafts have been preserved in the archive/ folder).


β˜‘οΈ Development Progress

Note

The full architectural breakdown and progression log has grown significantly. Please see the dedicated FEATURE_TRACKER.md for a comprehensive list of all technical guardrails, agent architectures, and game mechanics implemented in the AI Dungeon Master.


πŸŽ“ Acknowledgments & References

This project is built upon the foundational research of AI-assisted narrative generation and LLM-based agent architecture. We would like to acknowledge the following papers for their inspiration on our hybrid system:

  • πŸ“„ JΓΈrgensen et al. (2024) – ChatRPG: A Multi-Agent "ReAct" Game Master
  • πŸ“„ Sakellaridis (2024) – LLM-Based Agent as Dungeon Master
  • πŸ“„ Song et al. (2024) – Tool-Assisted AI DM: Function Calling & External Tools

Note

Full academic PDFs can be found in the <samp>archive/references/</samp> directory.


πŸ“œ Citation

If you use the DualPath-Core architecture, code, or evaluation datasets in your academic research, please cite our upcoming work:

@misc{sutthimala2026dualpath,
  author       = {Suttimala, Pollapaat},
  title        = {{DualPath-Core: A Multi-Agent Hybrid TTRPG Engine}},
  year         = {2026},
  publisher    = {GitHub},
  journal      = {GitHub Repository},
  howpublished = {\url{https://github.com/mudmini009/DualPath-Core-TTRPG-engine}}
}

About

Multi-agent TTRPG engine using Two-Path Architecture to solve AI hallucinations. Combines a deterministic Python Rules Engine with LLM-based creative judgment. Verified with 100% Routing and 98% Grounding accuracy. Senior Thesis @ KMUTT FIBO.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages