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.
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- 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
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Issues
- ๐ฌ General Discussion: GitHub Discussions
- ๐ Documentation: docs.supernpc.ai
Community
- Discord: Join our community
- Twitter/X: @supernpc
- GitHub: Super NPC Organization
Commercial Support
For enterprise support, custom integrations, or priority assistance:
- Email: contact@supernpc.ai (coming soon)
- GitHub Sponsors: Support ongoing development
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec801d9eecf27374a8c7dec963a9424b66043a9c142c05f21dd1ca2bab64a150
|
|
| MD5 |
10943a07bb02f759f2dcf3beb49870b0
|
|
| BLAKE2b-256 |
3c57e6e6e939baff8c6ede84373f1abc95ce62ea99563feccc7aed7153240fa3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b1ce8611bdf734a0da88c2296f860f181e6d64eafe337d39bbec050da1327ef
|
|
| MD5 |
40c8353e75f4aefba27707b664f044c2
|
|
| BLAKE2b-256 |
0c7a42855f7134113c87732478ab7cd9cb0317935a7e2df78413abaa342e4882
|