Skip to main content

Procedural Game Engine powered by IntentShield and LogicShield (BSL 1.1)

Project description

# Sovereign Engine

The Zero-Trust Procedural Game Engine. Built securely on the IntentShield and LogicShield architectures.

Sovereign Engine allows game developers to seamlessly integrate LLMs (Large Language Models) into their games to generate procedural dialogue, dynamic quests, and complex NPC interactions while absolutely guaranteeing that the AI's output mathematically adheres to your game's rules.

Installation

pip install sovereign-engine

Features

  • Deterministic Validation: The LogicShield backend forces the LLM to output perfect JSON that maps exactly to your defined game state parameters.
  • Action Gatekeeper: A deeply integrated, ultra-fast IntentShield system intercepts the AI's intended actions, instantly rejecting anything that isn't functionally possible in your game.
  • Model Agnostic: Plug in ANY language model (Ollama, Gemini, Local Llama3, OpenAI) via a custom callback function.

Quick Start

from sovereign_engine.engine import ProceduralDialogueEngine

# The engine routes through OpenRouter automatically by default
engine = ProceduralDialogueEngine(api_key="sk-or-your-developer-key")

# Pass the player's current environment directly to the engine
scene = engine.generate_node(
    player_state={"level": 5, "inventory": ["Iron Sword", "Shield"]},
    recent_history=["You enter a dark cavern and hear a low growl."],
    player_action="I walk forward with my shield raised."
)

print(scene)

Connecting Custom LLMs (Ollama, Gemini, etc.)

You do not have to use OpenRouter. You can pass a custom Python callback function into llm_provider to use local open-source models (like Llama3 via Ollama) or other cloud providers exactly as you need to.

import requests
from sovereign_engine.engine import ProceduralDialogueEngine

def local_ollama_call(prompt: str) -> str:
    # Send the engine's prompt to your local un-censored model!
    res = requests.post(
        "http://localhost:11434/api/generate", 
        json={"model": "llama3", "prompt": prompt, "stream": False}
    )
    return res.json()["response"]

# Inject your local LLM into the engine logic!
engine = ProceduralDialogueEngine(llm_provider=local_ollama_call)

scene = engine.generate_node(...)

Customizing Rules (LogicShield) & Actions (IntentShield)

You can easily expand the engine to enforce your own custom mechanics mathematically, or allow new verbs for the AI to take (like CRAFT or STEAL).

from sovereign_engine.logicshield.rules import Rule

my_rules = [
    # Force the LLM to include a gold reward that is less than max_loot
    Rule.less_than("gold_dropped", "max_loot")
]

engine = ProceduralDialogueEngine(
    llm_provider=local_ollama_call, 
    custom_actions=["STEAL", "CRAFT", "PERSUADE"], 
    custom_rules=my_rules
)

License

This project is licensed under the Business Source License 1.1 (BSL 1.1). For production or commercial use, you must obtain a separate commercial license from SovereignShield.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sovereign_engine-1.0.4.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sovereign_engine-1.0.4-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file sovereign_engine-1.0.4.tar.gz.

File metadata

  • Download URL: sovereign_engine-1.0.4.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for sovereign_engine-1.0.4.tar.gz
Algorithm Hash digest
SHA256 098544e1ab5be38a75136d181a15dd8b078e7675ca19f286ebde5004e5638355
MD5 204458416b5b13532d7e0d0f14ef3921
BLAKE2b-256 28555279170b168a8762cd29cea4ca04d1627bb77c836558093d8bf89dc2f70b

See more details on using hashes here.

File details

Details for the file sovereign_engine-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sovereign_engine-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2fe6c17cb3767fe97d0dfc7c7729095cc1ef65fb7710ad8983b2a7fe91e71c5e
MD5 79d46ea382369f0666b2af1050e63b62
BLAKE2b-256 47b0885bfb50df984ff32a30e6519753b7135ded6b1672e30d4af709763691fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page