Skip to main content

AI-Powered NPCs for Games - Local LLM NPCs with memory and emotions

Project description

Super NPC

AI-Powered NPCs for Games - Local LLM NPCs with Memory and Emotions

Super NPC is a universal AI NPC system for games. Add intelligent, emotional NPCs with persistent memory to any game with just a few lines of code. Runs entirely locally using your player's hardware.

โœจ Features

  • ๐Ÿง  Persistent Memory: NPCs remember conversations, events, and relationships across game sessions
  • ๐Ÿ˜Š Emotional Intelligence: NPCs have dynamic emotions that affect their behavior and responses
  • ๐Ÿ‘ฅ Personality System: Big Five personality traits make each NPC unique
  • ๐Ÿค Relationship Tracking: NPCs build trust/familiarity with players over time
  • ๐Ÿ’ฌ Natural Dialogue: LLM-powered conversations (Ollama, OpenAI, Anthropic)
  • ๐Ÿ”„ Universal Integration: REST API, Python library, Unity/Godot plugins
  • ๐Ÿ’พ State Persistence: JSON serialization for saving/loading NPC states
  • ๐Ÿš€ Performance Optimized: Handles 100+ concurrent NPCs efficiently

๐Ÿš€ Quick Start

Python Library

from supernpc import NPCAgent

# Create an intelligent NPC
npc = NPCAgent(
    name="Elara",
    role="blacksmith",
    personality="friendly",
    backstory=["I've forged weapons for 20 years"]
)

# Chat with the NPC
response = npc.chat("Player", "Do you have any swords for sale?")
print(f"Elara: {response}")

# NPC remembers and emotions change
npc.save_state("elara.json")

REST API Server

# Install and run
pip install supernpc[server]
supernpc-server --port 8080 --model qwen2.5:1.5b

# Any game can integrate
curl -X POST http://localhost:8080/chat \
  -d '{"npc_id": "merchant", "player": "hero", "message": "What do you sell?"}'

๐ŸŽฎ Engine Integrations

Unity (C#)

using SuperNPC.Unity;

NPCAgent npc = new NPCAgent("Guard");
string response = npc.Chat("Player", "Can I enter the castle?");

Godot (GDScript)

extends SuperNPC

func _ready():
    npc_id = "villager"
    personality = "curious"

func _on_player_interact(message):
    var response = chat("Player", message)
    show_dialogue(response)

๐Ÿ“ฆ Installation

pip install supernpc

# For development
git clone https://github.com/supernpc/npcs
cd supernpc-sdk
pip install -e .

๐Ÿ—๏ธ Architecture

supernpc/
โ”œโ”€โ”€ agent.py          # Main NPCAgent class
โ”œโ”€โ”€ memory.py         # Memory storage & retrieval
โ”œโ”€โ”€ emotions.py       # Emotional state management
โ”œโ”€โ”€ personality.py    # Big Five personality traits
โ”œโ”€โ”€ relationships.py  # Trust & familiarity tracking
โ”œโ”€โ”€ dialogue.py       # LLM integration (Ollama/OpenAI/Anthropic)
โ””โ”€โ”€ __init__.py       # Package exports

๐Ÿค– LLM Support

  • Ollama (Local): qwen2.5:1.5b, llama2:7b, etc.
  • OpenAI: GPT-4, GPT-3.5-turbo
  • Anthropic: Claude models
  • Custom: Extend for any API

๐Ÿ“Š Example NPC States

{
  "name": "Elara",
  "role": "blacksmith",
  "emotions": {"happiness": 0.7, "anger": 0.1},
  "memories": [
    {"content": "Player bought a sword", "importance": 0.6},
    {"content": "Player asked about apprentice", "importance": 0.8}
  ],
  "relationships": {
    "Player": {"trust": 0.75, "familiarity": 0.9}
  }
}

๐ŸŽฏ Use Cases

  • RPGs: Shopkeepers who remember your purchases
  • Adventure Games: NPCs with emotional arcs
  • MMOs: Persistent NPC relationships across sessions
  • Visual Novels: Dynamic character development
  • Simulation Games: AI characters with realistic social behavior

๐Ÿ”ง API Reference

NPCAgent

class NPCAgent:
    def __init__(self, name, role="villager", personality=None, backstory=None)
    def chat(self, player_name, message) -> str
    def get_status(self, player_name) -> dict
    def save_state(self, filepath)
    def load_state(self, filepath)

Memory System

memory_store = MemoryStore(max_memories=100)
memory_store.add(Memory("Player helped me", importance=0.8))
relevant = memory_store.retrieve("help", limit=5)

๐Ÿค Contributing

We welcome contributions! See our Contributing Guide.

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Submit a pull request

๐Ÿ“„ License

MIT License - see LICENSE file.

๐ŸŒŸ Roadmap

  • Unity Asset Store package
  • Godot Asset Library plugin
  • Docker container with pre-configured models
  • Voice synthesis integration
  • Multi-language support
  • WebSocket real-time dialogue
  • Mobile game optimizations

๐Ÿ“ž Contact & Support

Get Help

Community

Commercial Support

For enterprise support, custom integrations, or priority assistance:


Made with โค๏ธ for game developers who want smarter NPCs

๐Ÿ“Š Current Status

โœ… Completed (Phase 1)

  • Extract core AI from Pygame dependencies
  • Create standalone supernpc package
  • Add multiple LLM backend support (Ollama, OpenAI, Anthropic)
  • JSON state serialization for any game
  • Python library API
  • REST API server implementation
  • Comprehensive test suite

๐Ÿšง In Progress (Phase 2)

  • Unity C# bindings
  • Godot GDScript integration
  • Docker containerization
  • Performance optimization for 100+ NPCs

๐Ÿ“‹ Roadmap (Phase 3+)

  • WebSocket real-time dialogue
  • Voice synthesis integration
  • Multi-language support
  • Unity Asset Store package
  • Godot Asset Library plugin

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

supernpc-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

supernpc-0.1.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file supernpc-0.1.0.tar.gz.

File metadata

  • Download URL: supernpc-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for supernpc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec801d9eecf27374a8c7dec963a9424b66043a9c142c05f21dd1ca2bab64a150
MD5 10943a07bb02f759f2dcf3beb49870b0
BLAKE2b-256 3c57e6e6e939baff8c6ede84373f1abc95ce62ea99563feccc7aed7153240fa3

See more details on using hashes here.

File details

Details for the file supernpc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: supernpc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for supernpc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b1ce8611bdf734a0da88c2296f860f181e6d64eafe337d39bbec050da1327ef
MD5 40c8353e75f4aefba27707b664f044c2
BLAKE2b-256 0c7a42855f7134113c87732478ab7cd9cb0317935a7e2df78413abaa342e4882

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