BehaviourTree-dlabs
1.0.0
dotnet add package BehaviourTree-dlabs --version 1.0.0
NuGet\Install-Package BehaviourTree-dlabs -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BehaviourTree-dlabs" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BehaviourTree-dlabs" Version="1.0.0" />
<PackageReference Include="BehaviourTree-dlabs" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BehaviourTree-dlabs --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BehaviourTree-dlabs, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BehaviourTree-dlabs@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BehaviourTree-dlabs&version=1.0.0
#tool nuget:?package=BehaviourTree-dlabs&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BehaviourTree
This is a fork of https://github.com/Eraclys/BehaviourTree The goal was to build it for .NET8 For now, the demo project doesn't build. I have some time I'll migrate it also
Installation
Install-Package BehaviourTree
Demo
https://www.youtube.com/watch?v=OeVo2l-O0vU
Features
- Generic context
- Extensible
- Fluent Builder
- Basic node types included
- Tree visualizer (Coming soon)
Usage (FluentBuilder)
var behaviourTree = FluentBuilder.Create<MyContext>()
.Sequence("root")
.Do("walk to door", WalkToDoorFunc)
.Selector("open door sequence")
.Do("open door", OpenDoorFunc)
.Sequence("locked door sequence")
.Do("unlock door", UnlockDoorFunc)
.Do("open door", OpenDoorFunc)
.End()
.Do("smash door", SmashDoorFunc)
.End()
.Do("walk through door", WalkThroughDoorFunc)
.Do("close door", CloseDoorFunc)
.End()
.Build();
Node Types
Leaves
Action
builder.Do("my-action", context => BehaviourStatus.Succeeded)
Wait
builder.Wait("my-wait", 3000) // 3 seconds
Condition
builder.Condition("my-condition", context => true)
Composites
Sequence
builder.Sequence("my-sequence")
.Do("action1", context => BehaviourStatus.Succeeded)
.Do("action2", context => BehaviourStatus.Succeeded)
.Do("action3", context => BehaviourStatus.Succeeded)
...
.End()
Selector
builder.Selector("my-selector")
.Do("action1", context => BehaviourStatus.Failed)
.Do("action2", context => BehaviourStatus.Succeeded)
.Do("action3", context => BehaviourStatus.Succeeded)
...
.End()
RandomSequence
builder.RandomSequence("my-random-sequence")
.Do("action1", context => BehaviourStatus.Succeeded)
.Do("action2", context => BehaviourStatus.Succeeded)
.Do("action3", context => BehaviourStatus.Succeeded)
...
.End()
RandomSelector
builder.RandomSelector("my-random-selector")
.Do("action1", context => BehaviourStatus.Failed)
.Do("action2", context => BehaviourStatus.Succeeded)
.Do("action3", context => BehaviourStatus.Succeeded)
...
.End()
PrioritySequence
builder.PrioritySequence("my-priority-sequence")
.Do("action1", context => BehaviourStatus.Succeeded)
.Do("action2", context => BehaviourStatus.Succeeded)
.Do("action3", context => BehaviourStatus.Succeeded)
...
.End()
PrioritySelector
builder.PrioritySelector("my-priority-selector")
.Do("action1", context => BehaviourStatus.Failed)
.Do("action2", context => BehaviourStatus.Succeeded)
.Do("action3", context => BehaviourStatus.Succeeded)
...
.End()
SimpleParallel
public enum SimpleParallelPolicy
{
BothMustSucceed,
OnlyOneMustSucceed
}
var policy = SimpleParallelPolicy.BothMustSucceed;
builder.SimpleParallel("my-parallel", policy)
.Do("action1", context => BehaviourStatus.Running)
.Do("action2", context => BehaviourStatus.Running)
.End()
Decorators
Cooldown
builder.Cooldown("my-cooldown", 4000) // 4 seconds
.Do("action1", context => BehaviourStatus.Failed)
.End()
Failer
builder.AlwaysFail("my-failer")
.Do("action1", context => BehaviourStatus.Succeeded)
.End()
Succeeder
builder.AlwaysSucceed("my-succeeder")
.Do("action1", context => BehaviourStatus.Failed)
.End()
Inverter
builder.Invert("my-inverter")
.Do("action1", context => BehaviourStatus.Failed)
.End()
RateLimiter (Cache)
builder.LimitCallRate("my-rate-limiter", 1000) // 1 second
.Do("action1", context => BehaviourStatus.Failed)
.End()
Repeat
builder.Repeat("my-repeater", 5)
.Do("action1", context => BehaviourStatus.Failed)
.End()
TimeLimit
builder.TimeLimit("my-time-limit", 5000) // has 5 seconds to complete or will fail
.Do("action1", context => BehaviourStatus.Running)
.End()
UntilSuccess
builder.UntilSuccess("my-until-success")
.Do("action1", context => BehaviourStatus.Failed)
.End()
UntilFailed
builder.UntilFailed("my-until-failed")
.Do("action1", context => BehaviourStatus.Succeeded)
.End()
Random
builder.Random("my-random", 0.6) // will call child 60% of the time
.Do("action1", context => BehaviourStatus.Succeeded)
.End()
SubTree
builder.SubTree("my-sub-tree", otherBehaviourTree)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 203 | 10/15/2025 |
First package following the fork