Read this in other languages: English, Русский.
Living NPCs, procedural content, dynamic mechanics — all driven by AI, right during gameplay.
Engineered for both rapid integration by beginners and complex systemic design by industry veterans, CoreAI scales with your ambition. Build everything from intelligent dialogue assistants and deeply autonomous NPCs to the ultimate frontier of game development: living worlds with adaptive mechanics that evolve in real-time!
Imagine a game that adapts not just with numbers, but with logic and situations: different threats, different pacing, different world "character". CoreAI makes this a reality.
🚀 PROVEN ON SMALL MODELS: All CoreAI PlayMode tests are fully verified and pass flawlessly on Qwen3.5-4B (running locally, with "Think" reasoning mode disabled). This proves you don't need expensive server APIs! CoreAI's robust orchestration and strict prompt engineering allow you to build incredibly smart, dynamic games with highly intelligent NPCs running entirely on consumer hardware.
Version: v0.16.0 | PlayMode Scene Tools & Vision Support
var merchant = new AgentBuilder("Blacksmith")
.WithSystemPrompt("You are a blacksmith. Sell weapons and remember purchases.")
.WithTool(new InventoryLlmTool(myInventory)) // Knows their stock
.WithMemory() // Remembers buyers
.Build();
merchant.ApplyToPolicy(CoreAIAgent.Policy);
// Call the agent — one line, zero boilerplate:
merchant.Ask("Show me your swords");
// Or with a callback:
merchant.Ask("Show me your swords", onDone: () => Debug.Log("Done!"));3 Agent Modes: 🛒 ToolsAndChat · 🤖 ToolsOnly · 💬 ChatOnly
Now CoreAI allows Lua scripts (like dynamically parsed world logic) to execute as asynchronous coroutines inside Unity:
-- Runs securely across multiple frames relying on Unity's Time
local start_time = time_now()
while time_now() - start_time < 2.0 do
coroutine.yield()
endAutomatically maps APIs like time_delta(), time_scale(), and hooks securely via an internal InstructionLimitDebugger budget that yields processing back to Unity so you can run heavy computations forever without freezes!---
AI doesn't just generate text — it calls code for real actions:
| Tool | What it does | Who uses it |
|---|---|---|
| 🌍 WorldCommandTool | Spawns, moves, modifies objects in the world | Creator AI |
| ⚡ Action/Event Tool | Calls any C# method or triggers an Event | All Agents |
| 🧠 MemoryTool | Saves/reads memory between sessions | All Agents |
| 📜 LuaTool | Executes Lua scripts | Programmer AI |
| 🎒 InventoryTool | Gets NPC inventory | Merchant AI |
| ⚙️ GameConfigTool | Reads/modifies game configs | Creator AI |
| 🎭 SceneLlmTool | Read and change hierarchy/transform in PlayMode | All Agents |
| 📸 CameraLlmTool | Captures screenshots (Base64 JPEG) for Vision | All Agents |
Create your own:
public class WeatherLlmTool : ILlmTool
{
public string Name => "get_weather";
public string Description => "Get current weather.";
public IEnumerable<AIFunction> CreateAIFunctions()
{
yield return AIFunctionFactory.Create(
async ct => await _provider.GetWeatherAsync(ct), "get_weather", "Get weather.");
}
}Player: "Craft a weapon from Iron and Fire Crystal"
↓
CoreMechanicAI: "Iron + Fire Crystal → Flame Sword, damage 45"
↓
Programmer AI: execute_lua → create_item("Flame Sword", "weapon", 75)
add_special_effect("fire_damage: 15")
↓
✨ Player receives a unique item!
| Memory | ChatHistory | |
|---|---|---|
| Storage | JSON file on disk | In LLMAgent (RAM) |
| Duration | Between sessions | Current conversation |
| For what | Facts, purchases, quests | Conversation context |
Small models (Qwen3.5-2B) sometimes forget the format. CoreAI automatically gives 3 retries + checks fenced Lua blocks immediately.
| Model | Size | Tool Calling | When to use |
|---|---|---|---|
| Qwen3.5-4B | 4B | ✅ Great | Recommended for local GGUF |
| Qwen3.5-35B (MoE) API | 35B/3A | ✅ Excellent | Ideal via API — fast & accurate |
| Gemma 4 26B (via LM Studio) | 26B | ✅ Excellent | Great via HTTP API |
| LM Studio / OpenAI API | Any | ✅ Excellent | External models via HTTP — best choice |
| Qwen3.5-2B | 2B | Works, but sometimes makes mistakes | |
| Qwen3.5-0.8B | 0.8B | Most tests pass, struggles with multi-step |
💡 Recommendation: Qwen3.5-4B locally or Qwen3.5-35B (MoE) via API
MoE models (Mixture of Experts) activate only 3B parameters per inference — fast as 4B, accurate as 35B.
All CoreAI PlayMode tests have been verified on real LLM backends. Results:
| Test Category | 0.8B | 2B | 4B+ |
|---|---|---|---|
| Memory Tool (write/append/clear) | ✅ Pass | ✅ Pass | ✅ Pass |
| Custom Agents (tool calling) | ✅ Pass | ✅ Pass | ✅ Pass |
| World Commands (list/play/spawn) | ✅ Pass | ✅ Pass | ✅ Pass |
| Execute Lua (single tool) | ✅ Pass | ✅ Pass | ✅ Pass |
| Multi-Agent Workflow (Creator→Mechanic→Programmer) | ✅ Pass | ✅ Pass | |
| Crafting Memory (multi-step: memory + lua) | ✅ Pass | ||
| Chat History (persistent context) | ❌ Too small | ✅ Pass | |
| Player Chat (NPC dialogue) | ✅ Pass | ✅ Pass | ✅ Pass |
🏆 Qwen3.5-4B passes ALL tests. This is the recommended minimum for production use.
📊 Qwen3.5-0.8B passes most tests — impressive for its size! Struggles only with complex multi-step tool calling chains.
📈 2B is a solid middle ground — occasional mistakes in multi-step scenarios, but mostly reliable.
The repository consists of two packages:
| Package | What's inside | Dependencies |
|---|---|---|
| com.nexoider.coreai | Portable core — pure C# without Unity | VContainer, MoonSharp |
| com.nexoider.coreaiunity | Unity layer — DI, LLM, MEAI, MessagePipe, tests | Depends on coreai |
┌─────────────────────────────────────────────────────────────┐
│ Player / Game │
└──────────────────────┬──────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ AiOrchestrator │
│ • Priority queue • Retry logic • Tool calling │
└──────────────────────┬──────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ LLM Client │
│ • LLMUnity (local GGUF) • OpenAI HTTP • Stub │
└──────────────────────┬──────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ AI Agents │
│ 🛒 Merchant 📜 Programmer 🎨 Creator 📊 Analyzer │
│ 🗡️ CoreMechanic 💬 PlayerChat + Your custom ones! │
└──────────────────────┬──────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Tools (ILlmTool) │
│ 🧠 Memory 📜 Lua 🎒 Inventory ⚙️ GameConfig + Yours! │
└──────────────────────┬──────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ Game World │
│ • Lua Sandbox (MoonSharp) • MessagePipe • DI (VContainer)│
└─────────────────────────────────────────────────────────────┘
Method: Unity Editor → Window → Package Manager → + → Add package from git URL…
URL to copy:
https://github.com/NeoXider/CoreAI.git?path=Assets/CoreAI
Use the same Add package from git URL… method with this URL:
https://github.com/NeoXider/CoreAI.git?path=Assets/CoreAiUnity
Once installed, open and play the demo scene:
Assets/CoreAiUnity/Scenes/_mainCoreAI.unity
var storyteller = new AgentBuilder("Storyteller")
.WithSystemPrompt("You are a campfire storyteller. Share tales about the world.")
.WithMemory()
.WithChatHistory()
.WithMode(AgentMode.ChatOnly)
.Build();📖 Full setup guide with LLM configuration: QUICK_START.md
🏗️ Agent Builder reference + ready recipes: AGENT_BUILDER.md
| Document | What's inside |
|---|---|
| 📖 CoreAI README | General overview + AgentBuilder |
| 🏗️ AGENT_BUILDER.md | Agent builder guide + ChatHistory |
| 🔧 TOOL_CALL_SPEC.md | Tool calling specification |
| 🛒 CHAT_TOOL_CALLING.md | Merchant NPC with inventory |
| 🧠 MemorySystem.md | Agent memory system |
| 🗺️ DEVELOPER_GUIDE.md | Code map, architecture |
| 🤖 AI_AGENT_ROLES.md | Agent roles and prompts |
| ⚙️ COREAI_SETTINGS.md | CoreAISettingsAsset + tool calling |
| 🛠️ MEAI_TOOL_CALLING.md | MEAI pipeline architecture |
| 📋 CHANGELOG.md | Version history |
Unity → Window → General → Test Runner
├── EditMode — 215+ tests (fast, no LLM)
│ ├── CoreAISettingsAssetEditModeTests (7)
│ ├── AgentBuilderChatHistoryEditModeTests (7)
│ ├── OfflineLlmClientEditModeTests (5)
│ ├── MeaiLlmClientEditModeTests (4)
│ └── ... (other tests)
└── PlayMode — 12+ tests (with real LLM)
- Singleplayer: Same pipeline, AI works locally
- Multiplayer: AI logic on host, clients receive agreed outcomes
One template — for both solo campaign and coop.
Author: Neoxider
Ecosystem: NeoxiderTools
License: PolyForm Noncommercial 1.0.0 (commercial use — separate license)
Contact: neoxider@gmail.com | GitHub Issues
🎮 CoreAI — Make your game smarter. One agent at a time.
