Shadow Kingdom is an interactive text-based adventure game that uses AI to generate rich, atmospheric rooms and connections within thematically coherent regions. Players explore a mysterious fantasy kingdom where each area tells a cohesive story through connected spaces, from grand manor estates to ancient crypts and mystical gardens.
Built with Node.js and TypeScript, the game leverages Grok AI to create immersive experiences that adapt and expand as players explore. The sophisticated region-based generation system ensures that each area maintains thematic consistency while offering unexpected discoveries.
Thematically coherent areas (mansions, forests, caves, towns) with distance-based transitions. Each region maintains consistent atmosphere while offering unique exploration opportunities.
Rooms, descriptions, and connections dynamically created by Grok AI with regional context. Every space feels hand-crafted while being generated on-demand.
World expands automatically as you explore - new rooms generate in real-time without interrupting gameplay flow.
Navigate using cardinal directions ("north") or atmospheric descriptions ("through the crystal archway") for immersive exploration.
Save and load multiple game sessions with SQLite database. Your adventures persist between sessions with full world state preservation.
Explore region centers containing important content and NPCs. Each region has meaningful destinations and story elements to discover.
Programmatic command execution for automation and testing. Perfect for scripted interactions and external integrations.
Rooms maintain consistent layout after first visit, creating a believable world that players can mentally map and navigate reliably.
Shadow Kingdom is built with a sophisticated architecture that balances AI creativity with performance and reliability. The system uses region-based probability models to ensure thematic coherence while providing endless exploration possibilities.
• GameController: Main game logic and command processing
• RegionService: Region-based world generation and management
• GrokClient: AI integration for content generation
• SessionInterface: Programmatic command execution
• Database: SQLite database wrapper with comprehensive schema
• Games: Session management with metadata
• Regions: Thematic areas with types and descriptions
• Rooms: Generated spaces with AI content
• Connections: Bidirectional links with dual addressing
• Game State: Player position and session tracking
The game uses Grok AI strategically to generate contextual content that enhances immersion. The AI receives adjacent room descriptions and regional themes to create coherent, atmospheric spaces. Distance-based probability transitions ensure natural region changes while maintaining exploration variety. Fallback systems provide graceful degradation when AI generation fails.
Shadow Kingdom creates immersive text-based adventures through AI-generated content. Each exploration reveals atmospheric descriptions, thematic connections, and coherent world-building that adapts to player choices.
> look Grand Entrance Hall =================== You stand in a magnificent entrance hall that speaks of forgotten grandeur. Towering marble columns stretch up to a vaulted ceiling painted with faded celestial murals... Exits: through the ornate archway beneath celestial murals (north), through the glass doors that shimmer with moonlight (east), up the stone steps to the winding tower (west) > region Current Region: Shadow Kingdom Manor Type: mansion Description: A grand manor estate shrouded in mystery, filled with elegant halls, ancient libraries, and moonlit gardens where forgotten secrets await discovery. Distance from center: 0 Total rooms in region: 6 Center room: Grand Entrance Hall > go through the glass doors
Building Shadow Kingdom involved solving complex challenges in AI content generation, world state management, and creating believable procedural worlds. The project showcases advanced TypeScript patterns, database design, and AI integration techniques.
Implemented a sophisticated probability system where distance from region centers influences transition chances. The 15% base chance plus 12% per distance unit creates natural exploration patterns while maintaining thematic coherence.
Designed a comprehensive SQLite schema with automatic triggers for region center discovery and bidirectional connection management. The system efficiently handles complex spatial relationships and game state persistence.
Developed context-aware prompting strategies that provide AI with regional themes, adjacent room descriptions, and spatial constraints. This results in coherent, immersive content that feels hand-crafted.
Created a programmatic command interface that enables automation, testing, and external integrations while maintaining the full interactive experience. Perfect for scripted adventures and development workflows.