A deterministic BDI/GOAP runtime for Unity. Replace bespoke NPC architecture with a battle-tested middleware kernel.
Warweaver is an architectural kernel, not a content asset. It enforces strict boundaries to ensure stability in large-scale production environments.
// 1. Schema Definition (Data-Oriented)
// Configuration is separate from execution.
var schema = new WorldSchema();
// Define Attributes (Quantized floats)
var greed = schema.CreateAttribute("Personality_Greed", 0f, 100f);
var reputation = schema.CreateAttribute("Reputation_Player", -100f, 100f);
var gold = schema.CreateAttribute("Resource_Gold", 0f, 9999f);
// Define Operators (The verbs of the system)
// Logic: "Scam Player" requires high Greed + low Reputation
var scamOp = schema.DefineOperator("Trade_Scam_Player")
.Requires(gold, Condition.LessThan(500f)) // Desperation
.AddScoreModifier(greed, 1.5f) // Greed multiplier
.AddScoreModifier(reputation, -2.0f); // Rep multiplier
// Register Archetype (Vectorized automatically)
schema.CreateArchetype("Merchant")
.AddAttribute(greed)
.AddAttribute(reputation)
.AddOperator(scamOp);
// 2. Signal Injection
// The host application drives the simulation via signals.
// Example: A famine event hits the district.
host.InjectSignal(
signalId: Signals.Event_Famine_Start,
position: CityCenter,
radius: 1000.0f,
intensity: 1.0f
);
// DETERMINISTIC RESOLUTION (Next Tick):
// 1. "Food_Security" attribute crashes for all Citizens.
// 2. "Share_Food" utility drops (Self-preservation).
// 3. "Steal_Food" utility spikes based on "Morality" attribute.
// 4. Riots emerge naturally from the utility evaluation.
//
// No scripted "If Famine Then Riot" logic required.
// 3. The Performance Budget
// Logic is strictly decoupled from Rendering.
void Update() {
// GATE-PERF-01: 10k Agents @ 30 TPS verified.
// Step the simulation (Fixed Timestep)
// Calculates cognition for the entire city.
_host.Step();
// Read the telemetry snapshot (Alloc-free struct)
// Safe to read from any thread.
while (_host.TelemetryStream.TryRead(out var frame)) {
// Render 10,000 transforms via GPU Instancing
// Simulation is 30tps. Rendering is 144fps.
_renderer.DrawInstanced(frame.Agents);
// Update economy UI
_ui.UpdateMarketGraph(frame.GlobalState);
}
}
// 4. Forensic Debugging
// Why did the Blacksmith refuse to sell me the sword?
var trace = host.GetReasoningTrace(agentId: 704, tick: 2401);
Debug.Log(trace.ToString());
/* OUTPUT LOG:
[Agent 704 "Blacksmith"] Tick 2401 Decision: "Refuse_Service"
------------------------------------------------
> Candidate: "Trade_Fair_Price"
- Base Score: 0.50
- MODIFIER [Reputation_Player=-40]: -0.80 (Player stole earlier)
- Final: 0.0 (Pruned)
> Candidate: "Refuse_Service"
- Base Score: 0.20
- MODIFIER [Personality_Stubborn=80]: +0.60
- MODIFIER [Memory_Player_Theft]: +1.50 (Salient Memory)
- Final: 2.30 (WINNER)
*/