Project Infinity is a sophisticated, procedural world-generation engine and AI agent architecture. It transforms a general-purpose Large Language Model (LLM) into a specialized Game Master by combining a codified agent protocol with an external mechanical authority, ensuring a consistent, fair, and deep RPG experience.
Depending on your setup, you can experience the world through two different levels of mechanical authority.
This mode utilizes an external Model Context Protocol (MCP) server to act as the absolute authority for game mechanics. By offloading logic to a dedicated server, it eliminates "LLM luck" and hallucinations regarding stats and dice rolls.
The MCP Advantage:
- Verified Dice: All rolls are performed externally and returned to the AI.
- State Authority: Player progress is tracked in a real-time SQLite database, preventing "memory drift."
- Fairness: Every mechanical result is mathematically accurate and transparent.
Requirements:
- Python 3.8+
- Ollama installed and running.
- Supported models:
gemma4:31b-cloudorqwen3.5:cloud.
Quick Start:
- Install dependencies:
pip install -r requirements.txt
- Launch the game:
python3 play.py
- Select your model and world file (
.wwf).
Play with any capable LLM (Gemini, ChatGPT, Mistral) by manually providing the "Lock" and the "Key."
The Process:
- The Lock: Copy and paste the entire contents of
GameMaster.mdinto your AI chat. - The Key: Provide a world file from the
output/directory (e.g.,electronistu_weave.wwf).
The Trade-off: Since standard chat interfaces cannot communicate with the MCP server, the Game Master uses an internal deterministic formula (LCG) and chat history to manage state. This experience is more prone to memory drift and is less transparent than the MCP-powered automated path.
Project Infinity ensures game consistency through a trio of authoritative systems.
To ensure fairness, the engine splits mechanical outcomes into two distinct layers:
- Complexity Checks (The d20): Uses
perform_checkto determine binary success or failure against a Difficulty Class (DC). - Magnitude & Damage (The Multi-Dice): Uses
roll_diceto determine the impact of an action using various die sizes (d4, d6, d8, d10, d12) for damage, healing, and quantity. - Verification: All rolls MUST be output in a transparent formula:
{notation}: {total} ({rolls} + {mod}).
To solve the problem of LLM "forgetfulness," the engine implements a dynamic state-tracking system:
- The
.playerSidecar: Each world (.wwf) is paired with a JSON file containing the character's current state. - In-Memory SQLite Engine: Upon boot, the MCP server initializes a queryable database from the player file.
- Real-Time Synchronization: The Game Master updates the database via MCP tools immediately as HP, XP, or inventory changes occur in the narrative.
The engine uses a schema-driven, positional array format (Graph RAG) to store world lore. This ensures factual consistency across geography, politics, and NPCs while significantly reducing token usage compared to standard text descriptions.
Tired of generic settings? Use the World Forge to create a world tailored to your character.
Run the forge:
python3 main.pyThe Forge guides you through character creation and procedurally generates a unique knowledge graph (.wwf file) in the output/ directory, which serves as the single source of truth for your specific adventure.
For the most immersive and consistent experience:
- Temperature 0: Set your LLM's Temperature to 0. This is critical for maximum rule adherence and consistency.
- Model Selection: Larger models generally produce richer narratives and better adhere to the complex MCP protocols.
Core Dependencies:
mcp: Model Context Protocol for external tool integration.ollama: Local LLM orchestration.rich: High-fidelity Terminal User Interface (TUI).pydantic: Data validation and settings management.numpy: Procedural generation logic.pyyaml: Protocol and schema configuration.
Infrastructure:
- Python 3
- SQLite (In-memory engine)
- Graph RAG architecture
