A decision-making framework where actions are evaluated by considerations
A decision-making framework where actions are evaluated by considerations
NsSynapse is a Utility AI for Unreal Engine. An actor gets a brain component with a list of actions. Each action has considerations, and each consideration gives a score from 0 to 1. The brain multiplies the scores, picks the action with the highest result, and can run it. You make actions and considerations as Blueprint or C++ child classes.
NsSynapse does not find paths, sense the world, or run animations. The brain does not tick, so your game code decides when the agent thinks. It does not replace a Behavior Tree for long, ordered tasks.
UNsSynapseBrainComponent scores its action list and keeps the best action.UNsSynapseAction hold considerations and run ExecuteAction.UNsSynapseConsideration return a raw score from CalculateScore.ThinkAndReact does nothing while the brain is busy.Unreal Engine 5.7+
The module runs on Win64, Mac, and Linux.
NsSynapse folder into the Plugins folder of your project."NsSynapse" to the dependencies of your game module in its Build.cs.In Blueprint:
NsSynapseConsideration. Override Calculate Score and return a value from 0 to 1.NsSynapseAction. Override Execute Action. Add the consideration to Considerations.Think And React on the component when the agent must decide, for example from a timer.In C++:
#include "Classes/NsSynapseBrainComponent.h"
#include "Classes/NsSynapseConsideration.h"
UCLASS()
class ULowHealthConsideration : public UNsSynapseConsideration
{
GENERATED_BODY()
public:
virtual float CalculateScore_Implementation(AActor* const InOwner) const override
{
const AMyBot* const Bot = Cast<AMyBot>(InOwner);
return Bot != nullptr ? 1.f - Bot->GetHealthPercent() : 0.f;
}
};
// In AMyBot: Brain = CreateDefaultSubobject<UNsSynapseBrainComponent>(TEXT("Brain"));
Brain->ThinkAndReact();
| Step | Rule |
|---|---|
| Raw score | CalculateScore result, clamped to 0..1 |
| Curve | Consideration Curve maps the raw score. The brain clamps the result to 0..1. The default curve is a line from (0, 0) to (1, 1) |
| Make-up | With N considerations: Final = S + (1 - S) * (1 - 1/N) * S |
| Action score | The product of all Final values. An action with no considerations scores 1 |
| Choice | The highest score above 0 wins. On a tie, the first action in the list wins |
UNsSynapseBrainComponent – The actor component that scores actions and runs the best one.Think() – Scores Possible Actions, stores the best action, and returns it.ThinkAndReact() – Calls Think, then calls ExecuteAction on the best action. Does nothing while busy.ChooseAction(Actions) – Scores the given action classes and stores the best one.ScoreAction(Action) – Returns the combined score of one action.GetBestAction() – Returns the action from the last choice.SetBusy(bool) / IsBusy() – Set and read the busy flag.UNsSynapseAction::ExecuteAction(Actor) – BlueprintNativeEvent. Put the behavior here.UNsSynapseConsideration::CalculateScore(Actor) – BlueprintNativeEvent. Return the raw score.