Generic C# GOAP (Goal Oriented Action Planning) library with Unity3d examples
Generic C# GOAP (Goal Oriented Action Planning) library with Unity3d examples
ReGoap is a generic C# GOAP (Goal Oriented Action Planning) library with Unity and Godot adapters.
It gives you a planner that chooses a goal, builds a valid action sequence to satisfy it, and lets your runtime execute that sequence while reacting to world changes.
GOAP is a decision-making technique for agents (NPCs, workers, enemies, simulation entities) where behavior is generated from world facts instead of hardcoded behavior trees or giant switch statements.
In GOAP, you define:
hasOre = true, chestSwordCount = 3)SmeltIngot needs ore and produces ingot)chestSwordCount >= 10)At runtime, the planner searches for a valid chain of actions that transforms the current world state into the goal state.
Why this is useful:
ReGoap provides:
ReGoap/Core, ReGoap/Planner, ReGoap/Utilities)At a high level, each planning cycle is:
A key/value fact container describing world conditions.
Examples:
enemyVisible = trueweaponEquipped = falsechestOreCount = 2A behavior unit with:
Run logic: your actual gameplay/sim codeA desired target state plus priority.
The planner chooses among possible goals and attempts to build a valid plan for one.
The agent's current world knowledge.
This is the source-of-truth state the planner reads when generating plans.
A memory updater that writes observed world facts into memory (resource counts, visibility, occupancy, etc).
ReGoap supports comparator-based state matching through ReGoapCondition:
ReGoapCondition.Equal(value)ReGoapCondition.NotEqual(value)ReGoapCondition.GreaterOrEqual(value)ReGoapCondition.LessOrEqual(value)This is useful for count-based logic such as inventories, chest resources, cooldown thresholds, and score targets.
Plain values still use exact equality matching for backward compatibility.
Goal selection can be deterministic (highest priority first) or weighted-random (priority-biased random).
Settings in ReGoapPlannerSettings:
UseWeightedRandomGoalSelection (default false)WeightedRandomGoalPriorityPower (default 1f)WeightedRandomMinimumWeight (default 0.001f)WeightedRandomUseDeterministicSeed (default false)WeightedRandomSeed (default 0)Deterministic seed mode is helpful for reproducible tests/replays.
ReGoap/Core: interfaces, states, action/goal contractsReGoap/Planner: planner, nodes, settingsReGoap/Utilities: logging and utility helpersReGoap/Unity: Unity adapter + Unity examples/docsReGoap/Godot: Godot adapter + Godot FSMExample/docsReGoap/Unity/README.mdReGoap/Godot/README.mdPRs are welcome. Run relevant build/tests for changed engine/runtime areas before submitting.
No open issues yet, or sync has not completed.