Show HN: Neural Emotion Matrix for NPCs

Show HN (score: 12)
Found: September 29, 2025
ID: 1713

Description

Other
Show HN: Neural Emotion Matrix for NPCs Hey! I built this system to humanize NPCs by giving them emotions using Rust and ML.

The system provides emotion coordinates (based on Russell's circumplex model) from text input or actions, with persistent emotional memory per entity. Think NPCs that remember how they feel about specific players or events.

I pre-trained a DistilBERT model on ~1k video game dialogues (Skyrim, Cyberpunk, etc.) and plan to extract and evaluate 100k+ dialogues soon. However studio/team can manually add dialogues to enrich their own dataset.

The matrix doesn't generate dialogue, it only analyzes content. When you pass text or an action, it returns emotion coordinates on the valence (pleasant/unpleasant) and arousal(energetic/calm) scale. For example:

- [0.00, 0.00] = neutral

- [0.29, 0.80] = excited

- [-0.50, -0.30] = sad/tired

I made a quick visualizer here to help understand https://valence-arousal-visualizer.vercel.app/

The system helps select which dialogue/action to play based on emotional state:

- Player says something bad to NPC → system detects negative valence → game picks from "angry dialogue pool"

- NPC remembers past positive interactions → system returns positive valence → friendlier responses available

So, the devs still write the dialogues or choose the next actions, but the matrix helps manage NPC emotional states and memory dynamically.

Here's the project structure to better understand how it works:

- src/config: Helper utilities for NPC configuration setup

- src/module: The core engine with emotion prediction, memory storage, and entity management

- src/api: FFI layer with pub extern "C" to bridge our modules with C/C++ game engines and modding tools (Unity, Unreal, etc.)

To implement it, just call `build.sh`, it will create DLL files that you can use to call the matrix functions directly in C++/C/C#.

I'd love feedback on code quality and overall architecture.

Feel free to be honest about the good, the bad, and the ugly. PRs welcome if you want to contribute!

More from Show

Show HN: DocsRouter – The OpenRouter for OCR and Vision Models

Show HN: DocsRouter – The OpenRouter for OCR and Vision Models Most products that touch PDFs or images quietly rebuild the same thing: a hacked-together “router” that picks which OCR&#x2F;vision API to call, normalizes the responses, and prays the bill is sane at the end of the month.<p>DocsRouter is that layer as a product: one stable API that talks to multiple OCR engines and vision LLMs, lets you route per document based on cost&#x2F;quality&#x2F;latency, and gives you normalized outputs (text, tables, fields) so your app doesn’t care which provider was used.<p>It’s meant for teams doing serious stuff with documents: invoices&#x2F;receipts, contracts, payroll, medical&#x2F;admin forms, logistics docs, etc., who are either stuck on “the OCR we picked years ago” or are overwhelmed by the churn of new vision models.<p>Right now you get a REST API, simple SDKs (coming soon), a few pluggable backends (classic OCR + newer vision models), some basic routing policies, and a playground where you can upload a doc and compare outputs side by side.<p>I’d love feedback from HN on two things:<p>1- If you already juggle multiple OCR&#x2F;vision providers, what does your homegrown router look like, and what would you need to trust an external one?<p>2 - Would you prefer this or use the LLM&#x2F;OCR providers directly, with the possibility of changing the provider every so often?<p>Demo and docs are here: <a href="https:&#x2F;&#x2F;docsrouter.com" rel="nofollow">https:&#x2F;&#x2F;docsrouter.com</a>

Show HN: Diesel-guard – Lint Diesel migrations for unsafe PostgreSQL patterns

Show HN: Diesel-guard – Lint Diesel migrations for unsafe PostgreSQL patterns

Show HN: Apicat – A Lightweight Offline Postman Alternative

Show HN: Apicat – A Lightweight Offline Postman Alternative Apicat is the ultimate offline Postman alternative that stores your .http files locally. It’s Git-friendly, open-source, and highly compatible with Postman. Test APIs offline with this powerful free offline API client designed for developers who need a reliable local API testing tool.

Show HN: Cmux – Coding Agent Multiplexer

Show HN: Cmux – Coding Agent Multiplexer HN,<p>I&#x27;m stoked to share this product I&#x27;ve been working on non-stop for the past few weeks. It&#x27;s an immersive GUI experience for working with many coding agents in parallel. The UX should be familiar to Claude Code users, but we took advantage of the GUI nature to add in a bunch more.<p>cmux is early but certainly usable—almost all of our internal cmux development rolls through cmux itself. Please let me know your thoughts and feedback!

No other tools from this source yet.