Gaming

DST-AICompanion

A cognitive AI companion for Don't Starve Together that cooperates with players using personality-driven decision-making, emotional reasoning, and speech interaction, built on the FAtiMA architecture for a Master's thesis on human-AI collaboration.

Lua C# FAtiMA Toolkit Behavior Trees OCEAN Model HTTP/JSON Don't Starve Together

In Plain English

This mod (a player-made addition to a video game) adds a robot character to the survival game Don't Starve Together that actually cooperates with you. It gathers resources, chops trees, fights enemies alongside you, crafts tools, and responds to voice commands. It was built as a Master's thesis project studying how different AI personalities change the way humans play together with AI in games.

Problem

Don't Starve Together is a cooperative survival game designed to be played with other humans, but finding a reliable partner who plays at the same pace and shares the same goals is not always feasible. The game's built-in AI is limited to hostile creatures and passive animals. There is no companion system that lets you play cooperatively with a computer-controlled partner. An earlier mod called FAtiMA-DST by Hineios demonstrated that it was technically possible to connect an external decision engine to the game via HTTP, but that project was abandoned as DST updated its engine, and the companion it produced was limited to basic actions without personality, speech, or adaptive behavior.

This project picks up where that abandoned framework left off and rebuilds nearly everything on top of it. The original mod could barely walk and pick things up. This fork adds a full personality system based on the OCEAN (Big Five) psychological model, a speech interaction system that lets the player issue verbal commands and receive contextual replies, goal-oriented behavior chains that give the companion long-term objectives, a perception system that tracks over a dozen entity properties across a 21-unit visibility radius, and a priority-based behavior tree that balances survival needs against personality-driven goals.

The academic dimension is what ties it all together. The project was built for a Master's thesis titled "Exploring Factors Influencing Human Behavior of AI Personality in a Virtual Collaboration Environment." The research question was whether different AI personality configurations (Adventurer, Camper, Supporter) measurably change how human players behave when collaborating with the AI. The mod includes a full data logging system that exports perception data to CSV files every second, enabling quantitative analysis of player-AI interaction patterns across different personality treatments.

Architecture

DST MOD (Lua - In-Game Body) PERCEPTION AND WORLD STATE FAtiMA SERVER (C# - Brain) PERSONALITY AND BEHAVIOR FAtiMA Brain (Lua) Behavior tree + action queue modmain.lua WX-78 spawn + brain init Action Handlers: PICK, CHOP, MINE, BUILD, ATTACK, EAT, GIVE Stuck Detection pos + target counters (15 tick) Utterance Classifier Follow, Attack, Give, Home Priority: Speech > Teleport > Follow > Travel > Combat > Trade Buffered Action Queuing Success/Fail Callbacks Vision (21-unit radius) FindEntities with tag filters Inventory Scanner Items, food, tools, slots Health / Hunger / Sanity Temperature, moisture Player Tracker Distance, resources, speech World State Watchers Season, phase, moon, rain Map Node Tracker Vision + entity scores Entity Properties: Choppable, Mineable, Pickable, Edible, Attackable, Equippable... CSV Data Logger (1s interval, perception telemetry for research) FAtiMA-Server.exe C# console on localhost:8080 Decision Engine Emotional reasoning + MCTS Emotional Appraisal OCC emotion model Autobiographic Memory Event recall + emotion tags Knowledge Base Beliefs about world state Social Importance Player relationship values Integrated Authoring Tool (.iat) + Role Play Character (.rpc) + EDM (.edm) FAtiMA scenario configuration files Well-Formed Names: Action(CHOP, -, -, -, -) | Speak(cs, ns, m, sty, 'text') OCEAN Personality Big Five: O, C, E, A, N (0-10) Personality Presets Adventurer / Camper / Supporter Goal System Conditional sub-goal chains Speech System 20+ commands + context replies Comme il Faut Social rules engine Scenario Loader Starter base chest config Goal Chains: Gather_resource (IsAbundance) > Build_weapon (HasSpear) > Go_travel MCTS Planning + Emotional Decision Making + Appraisal Rules HTTP POST perceptions HTTP GET decisions 0.5s interval traits
Scroll to explore diagram

Two-process architecture: the Lua mod inside DST acts as the agent's body (perception, actions, behavior tree), while the external FAtiMA C# server acts as the brain (emotional reasoning, personality, and decision-making), communicating over HTTP at half-second intervals.

Features

Personality-Driven Behavior

3 presets + full OCEAN tuning

The companion's personality is not cosmetic. It fundamentally changes how the AI plays the game. The Adventurer personality sets a goal chain of Gather_resource (until the IsAbundance flag is met), then Build_weapon (until the companion has a spear), then Go_travel to maximize a vision score computed from unique map nodes visited. The Camper gathers resources and prioritizes building tools and a firepit for base development. The Supporter simply follows and imitates whatever the player does, staying close and mirroring actions. Beneath these presets, the OCEAN Big Five model provides granular control: Openness affects exploration range, Conscientiousness influences resource-gathering thoroughness, Extraversion determines how closely the AI follows the player, Agreeableness adjusts cooperation thresholds, and Neuroticism controls danger avoidance. Each trait runs on a 0-10 scale and feeds directly into the FAtiMA decision engine's emotional appraisal rules.

Autonomous Survival Actions

7+ action types with buffered queuing

The AI companion can perform every essential survival action in Don't Starve Together. It PICKs and PICKUPs resources from the ground, CHOPs trees (automatically equipping an axe first), MINEs rocks, BUILDs tools and structures from crafting recipes, ATTACKs hostile creatures with cooperative combat behavior that includes dodge movement, EATs food when given by the player, and GIVEs items to the player on request. Each action uses DST's buffered action queuing system with success and failure callbacks that feed outcome data back to the FAtiMA emotional appraisal engine. If an action fails, the companion's emotional state shifts and future decisions adjust accordingly. A stuck-detection system monitors both position and target entity counters, and if 15 ticks pass with no progress, the brain automatically resets and picks a new action.

Speech Interaction System

20+ voice command patterns

Players can communicate with the companion through the game's chat system using natural language commands. An utterance classifier matches incoming text against keyword patterns: "come here" or "follow me" triggers the Follow behavior, "go away" sends the companion to retreat, "give me grass" or "give me logs" triggers resource sharing from the companion's inventory, "attack" directs it toward the player's current combat target, "go home" navigates back to the spawn portal, and "help" triggers proximity approach. The companion also generates spontaneous contextual remarks about the world, its current state, and its goals, with a configurable speech probability between 30% and 70%. The speech system runs on a 3-second interval and integrates with FAtiMA's Speak action type, which packages utterances in the Well-Formed Name format for the protocol.

Rich World Perception

Every 0.5 seconds, 21-unit radius

The perception system is the foundation that makes everything else work. Every half second, it scans all entities within a 21-unit radius using DST's FindEntities API and classifies each one across over a dozen boolean properties: Choppable, Mineable, Pickable, Edible, Attackable, Equippable, Cookable, Harvestable, and more. It builds a complete snapshot that includes the companion's vital stats (health, hunger, sanity, temperature, moisture), a full inventory listing, equipped items, the player's position and distance, 14 world-state variables (season, day/night phase, moon cycle, weather conditions), a vision score computed from the number of unique map nodes visited, and an entity score tracking unique prefab types discovered. This entire data structure gets serialized to JSON and POSTed to the FAtiMA server, where it becomes the basis for emotional appraisal and decision-making. The same data optionally streams to a CSV file for research analysis.

How It Works

01

Agent Spawning and Initialization

When a DST world loads, the modmain.lua entry point hooks into the game's post-initialization event. It locates the multiplayer portal (the spawn point where players enter the world), then spawns one or two WX-78 robot characters at the portal's position. The number of companions is configurable through the mod settings menu. Each spawned character receives a "FAtiMA-Brain" tag and has its default Wilson brain replaced with the custom FAtiMABrain class.

The FAtiMABrain constructor initializes the full perception pipeline: periodic tasks for vision scanning (0.5 seconds), decision polling (1.5 seconds), and speech generation (3 seconds). It sets up world-state watchers for season, day phase, and weather. It registers event listeners for action completion callbacks. And it builds the behavior tree that will evaluate priorities every game tick. The modmain also patches the sanity badge UI widget to become a clickable toggle that lets the player take manual control of the companion's brain, complete with a pulsing visual effect when the AI is active.

02

Perception Loop

Every 0.5 seconds, the perception system builds a comprehensive data table. The Entity() function iterates over all visible entities and extracts a structured representation: GUID, prefab name, stack quantity, and a full set of interaction flags (Collectable, Cookable, Edible, Equippable, Fuel, Choppable, Diggable, Mineable, Attackable, and more). Each flag is derived from DST component checks and tag queries, ensuring the AI knows exactly what it can do with each visible object.

Beyond entity scanning, the perception also tracks the companion's vital statistics, current inventory contents with per-item interaction properties, equipped items, distance to the human player, whether the player is within interaction range, the player's inventory state, and any incoming speech utterance that needs classification. The world-state layer monitors season, day/night phase, moon phase, temperature, rain, snow, and the day count. All of this data is packed into a single JSON payload and sent via HTTP POST to the FAtiMA server's perceptions endpoint. The same data feeds the optional CSV logger that writes one row per second for research analysis.

03

FAtiMA Cognitive Decision-Making

The FAtiMA server is a C# console application built on the FAtiMA Toolkit libraries. When it receives a perception payload, the data flows through several cognitive modules. The Emotional Appraisal module evaluates the new information against appraisal rules defined in the scenario configuration (.iat, .rpc, .edm files), generating or updating emotions based on the OCC model. The Knowledge Base updates its beliefs about the current world state. The Autobiographic Memory records significant events for later recall.

When the Lua mod polls the decide endpoint (every 1.5 seconds), the Emotional Decision Making module evaluates available actions against the character's current emotional state, personality traits (OCEAN values), active goals, and social importance values. The system can also use Monte Carlo Tree Search (MCTS) for planning sequences of actions. The selected action or speech response is packaged in FAtiMA's Well-Formed Name format and returned as JSON. For example, a chop decision returns as Action(CHOP, -, -, -, -) while a crafting decision returns as Action(BUILD, -, -, -, axe).

04

Behavior Tree Execution

Back in the Lua mod, the behavior tree evaluates in strict priority order every game tick. Speech commands take highest priority: if the player just said "follow me," that overrides everything. Next comes the teleport check: if the companion is more than 400 units from the player (or 800 from the world center), it teleports to maintain proximity. Then the follow behavior, which keeps the companion within a personality-adjusted distance of the player. Travel behavior activates for the Adventurer personality. Combat handles both offensive attacks and defensive flee behavior with a panic-on-fire check.

The FAtiMA-directed action layer sits below these safety priorities. When FAtiMA returns a decision like CHOP, the behavior tree locates the nearest choppable entity, verifies the companion has an axe (auto-equipping if available, or auto-crafting if materials are present), and queues the buffered action. Each action handler includes success and failure callbacks that post Action-End events back to the FAtiMA server, closing the perception-decision-action loop. If no FAtiMA action is pending, the companion defaults to wandering, which serves as both idle behavior and low-priority exploration.

05

Goal Progression and Research Logging

Each personality preset defines a chain of goals with explicit completion conditions. The Adventurer's chain is: Gather_resource (complete when IsAbundance flag is true, meaning sufficient basic resources are stockpiled), then Build_weapon (complete when HasSpear is true), then Go_travel (maximize vision score by visiting new map nodes). As each condition is met, the goal advances to the next stage, and the FAtiMA decision engine shifts its priorities accordingly. The Camper follows a similar chain focused on base building: gather, build tools (axe and pickaxe), then build a firepit. The Supporter has a single perpetual goal of imitating the player.

The research logging system runs alongside all of this. Every second, the CSV logger writes a row containing the complete perception data: every numerical stat, every boolean flag, the current goal, the vision score, the entity score, the player distance, and more. This produces a dense time series that can be analyzed to answer the thesis research question. By running experiments with different personality configurations and comparing the resulting CSV data, the researcher can quantify how the AI's personality affects player movement patterns, resource gathering rates, combat engagement frequency, and collaboration proximity.

Tech Stack

Game Mod

Lua (DST modding API, behavior trees, buffered actions, event listeners)

AI Server

C# console application (FAtiMA-Server.exe), .NET Framework, HTTP/JSON

Cognitive Framework

FAtiMA Toolkit (Emotional Appraisal, Decision Making, MCTS, Autobiographic Memory)

Personality Model

OCEAN / Big Five (Openness, Conscientiousness, Extraversion, Agreeableness, Neuroticism)

Communication

HTTP/JSON between DST Lua engine and external C# process at 0.5s intervals

Research

CSV data logging, perception telemetry at 1s intervals, graph visualization