DiceTales

DiceTales Enhanced AI Memory System

Overview

The DiceTales AI memory system ensures the AI Dungeon Master remembers and references:

Architecture

Memory Manager (memoryManager.js)

A dedicated memory management system that tracks and organizes important game information:

Enhanced AI System (ai.js)

The AI system integrates seamlessly with the Memory Manager:

  1. Memory Integration: Automatic integration with MemoryManager for context building
  2. Context Building: Enhanced prompts that include comprehensive memory data
  3. Automatic Tracking: AI response parsing to extract and store important information
  4. Skill Detection: Analysis of player actions to detect skill usage automatically
  5. Campaign Continuity: Maintains story consistency across sessions

Game State Integration (gameState.js)

Memory data is stored in the game state system for persistence:

Key Features

1. Persistent Character Memory

The AI now remembers:

2. Dynamic NPC Relationships

Enhanced relationship tracking includes:

3. World State Continuity

The system maintains:

4. Intelligent Context Building

AI prompts now include:

Implementation Details

Memory Context Building

The buildMemoryContext() method creates comprehensive context for AI:

// Recent decisions with consequences
🧠 RECENT DECISIONS: Agreed to help the village, Chose stealth over combat

// Key relationships affecting current story
👥 KEY RELATIONSHIPS: Elder Marcus (friendly), Captain Thorne (suspicious)

// Important discoveries that shape the narrative
🔍 IMPORTANT DISCOVERIES: Ancient rune stone, Hidden passage beneath tavern

// Frequently used skills showing character development
🎯 FREQUENTLY USED SKILLS: Stealth (8/10), Investigation (6/8)

// Current equipment affecting capabilities
⚔️ EQUIPPED: Longbow, Leather Armor, Cloak of Elvenkind

Automatic Information Extraction

The AI system automatically parses responses to extract:

Memory Management

The system includes intelligent cleanup:

2. Dynamic NPC Relationships

3. Location and World Consistency

4. Quest and Decision Tracking

5. Skill and Character Development

Implementation Details

Memory Context Building

The buildMemoryContext() function creates comprehensive context for the AI by combining:

// Recent decisions and their consequences
🧠 RECENT DECISIONS: [player choices]

// Key NPC relationships
👥 KEY RELATIONSHIPS: [NPC names and relationships]

// Important discoveries
🔍 IMPORTANT DISCOVERIES: [significant findings]

// Frequently used skills
🎯 FREQUENTLY USED SKILLS: [skill usage statistics]

// Active plot threads
📖 ACTIVE PLOT THREADS: [ongoing storylines]

// Character abilities and equipment
💪 CLASS ABILITIES: [character abilities]
🎒 INVENTORY: [current items]
⚔️ EQUIPPED: [equipped gear]

Automatic Information Extraction

The AI system automatically extracts information from responses using pattern matching:

Memory Management

The system includes:

Usage

For Players

The memory system works automatically in the background. Players will notice:

For Developers

Access memory functions through:

// Test memory system
window.testMemory();

// Access memory manager
memoryManager.recordDecision(decision, consequence);
memoryManager.updateRelationship(npcName, relationship);
memoryManager.recordDiscovery(discovery, type, significance);

// Get memory summary for AI context
const summary = memoryManager.getMemorySummary();

Configuration

Memory Limits

Automatic Cleanup

The system automatically cleans up old memories to prevent bloat while preserving important information based on significance levels.

Benefits

  1. Consistent Storytelling: AI maintains continuity across sessions
  2. Character Development: Realistic character growth and skill progression
  3. Immersive Experience: NPCs remember interactions and relationships
  4. Dynamic World: World state persists and evolves with player actions
  5. Strategic Depth: Past decisions have lasting consequences
  6. Personalized Narrative: Stories adapt to character abilities and choices

Testing

Use the built-in test functions to verify memory system functionality:

// Test AI memory integration
window.testMemory();

// Test AI response system
window.testAI();

// Test full action processing
window.testPlayerAction("examine the ancient tome");

The enhanced memory system ensures that every adventure in DiceTales builds upon previous experiences, creating rich, interconnected narratives that respond intelligently to player choices and character development.