unfurl

Synapse

A decision-making framework where actions are evaluated by considerations

A decision-making framework where actions are evaluated by considerations

👀 Summary

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.

📦 Features

⚙️ Requirements

Unreal Engine 5.7+

The module runs on Win64, Mac, and Linux.

🛠️ Installation

  1. Clone or download this repository.
  2. Copy the NsSynapse folder into the Plugins folder of your project.
  3. For C++, add "NsSynapse" to the dependencies of your game module in its Build.cs.
  4. Generate the project files and enable the plugin.

🚀 Getting Started

In Blueprint:

  1. Make a child Blueprint of NsSynapseConsideration. Override Calculate Score and return a value from 0 to 1.
  2. Make a child Blueprint of NsSynapseAction. Override Execute Action. Add the consideration to Considerations.
  3. Add the Ns Synapse Brain component to your AI actor.
  4. Add the action class to Possible Actions on the component.
  5. Call 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();

🧮 How a Score Is Made

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

🔧 API

🚧 Limits

📚 Documentation


Contact