Convert Figma logo to code with AI

Tencent logobehaviac

behaviac is a framework of the game AI development, and it also can be used as a rapid game prototype design tool. behaviac supports the behavior tree, finite state machine and hierarchical task network(BT, FSM, HTN)

2,895
801
2,895
98

Top Related Projects

2,859

1,225

Artificial Intelligence framework for games based on libGDX or not. Features: Steering Behaviors, Formation Motion, Pathfinding, Behavior Trees and Finite State Machines

Behavior Trees Library in C++. Batteries included.

Quick Overview

Behaviac is an open-source behavior tree library developed by Tencent. It provides a visual editor and runtime library for creating and executing behavior trees, which are commonly used in game AI and other decision-making systems. The library supports multiple programming languages and platforms, making it versatile for various projects.

Pros

  • Visual editor for easy behavior tree creation and modification
  • Supports multiple programming languages (C++, C#, Java) and platforms
  • Extensive documentation and examples available
  • Includes features like blackboards, decorators, and parallel nodes

Cons

  • Learning curve for those unfamiliar with behavior trees
  • Visual editor is Windows-only, limiting cross-platform development
  • Some users report occasional stability issues with the editor
  • Limited community support compared to some other AI frameworks

Code Examples

  1. Creating a simple behavior tree:
#include "behaviac/behaviac.h"

// Define a simple action
class SayHello : public behaviac::Action
{
    BEHAVIAC_DECLARE_DYNAMIC_TYPE("SayHello", behaviac::Action);

    virtual behaviac::EBTStatus execute(behaviac::Agent* pAgent)
    {
        printf("Hello, World!\n");
        return behaviac::BT_SUCCESS;
    }
};

// Create and run the behavior tree
behaviac::Workspace::GetInstance()->ExportMetas("../meta/");
behaviac::Workspace::GetInstance()->Load("../exported/SimpleBT");

behaviac::Agent* agent = behaviac::Agent::Create<behaviac::Agent>();
agent->btload("SimpleBT");
agent->btexec();
  1. Using a decorator:
// Define a decorator that limits execution count
class LimitDecorator : public behaviac::DecoratorNode
{
    BEHAVIAC_DECLARE_DYNAMIC_TYPE("LimitDecorator", behaviac::DecoratorNode);

    int m_limit;
    int m_count;

public:
    LimitDecorator() : m_limit(3), m_count(0) {}

    virtual bool Evaluate(behaviac::Agent* pAgent)
    {
        return m_count < m_limit;
    }

    virtual behaviac::EBTStatus Update(behaviac::Agent* pAgent, behaviac::EBTStatus childStatus)
    {
        m_count++;
        return childStatus;
    }
};
  1. Using a blackboard:
// Set and get values from the blackboard
behaviac::Agent* agent = behaviac::Agent::Create<behaviac::Agent>();
agent->SetVariable("health", 100);
int health = agent->GetVariable<int>("health");

Getting Started

  1. Clone the repository:

    git clone https://github.com/Tencent/behaviac.git
    
  2. Build the library and tools:

    cd behaviac
    mkdir build && cd build
    cmake ..
    make
    
  3. Include the library in your project:

    #include "behaviac/behaviac.h"
    
  4. Initialize behaviac in your main function:

    behaviac::Workspace::GetInstance()->ExportMetas("../meta/");
    behaviac::Workspace::GetInstance()->Load("../exported/YourBehaviorTree");
    
  5. Create an agent and run the behavior tree:

    behaviac::Agent* agent = behaviac::Agent::Create<behaviac::Agent>();
    agent->btload("YourBehaviorTree");
    agent->btexec();
    

Competitor Comparisons

2,859

Pros of PyBrain

  • Written in Python, making it more accessible for data scientists and researchers
  • Focuses on neural networks and reinforcement learning, offering specialized tools
  • Includes a variety of pre-implemented algorithms and network architectures

Cons of PyBrain

  • Less actively maintained, with fewer recent updates
  • Limited documentation and community support compared to more modern libraries
  • Primarily designed for research and experimentation, not production-ready systems

Code Comparison

PyBrain example (neural network creation):

from pybrain.tools.shortcuts import buildNetwork
from pybrain.structure import TanhLayer

net = buildNetwork(2, 3, 1, hiddenclass=TanhLayer)

behaviac example (behavior tree creation):

#include "behaviac/behaviac.h"

BehaviorTree* bt = BehaviorTree::CreateBehaviorTree("myBT");
bt->SetDomain("game");

While PyBrain focuses on neural networks and machine learning, behaviac is primarily used for behavior trees in game development and AI decision-making. PyBrain offers a higher-level abstraction for machine learning tasks, while behaviac provides more fine-grained control over AI behavior in real-time applications.

1,225

Artificial Intelligence framework for games based on libGDX or not. Features: Steering Behaviors, Formation Motion, Pathfinding, Behavior Trees and Finite State Machines

Pros of gdx-ai

  • Integrated with the popular libGDX game development framework
  • Supports a wider range of AI techniques, including pathfinding, steering behaviors, and state machines
  • More active community and frequent updates

Cons of gdx-ai

  • Less focused on behavior trees compared to behaviac
  • May have a steeper learning curve for developers not familiar with libGDX
  • Limited visual editing tools for AI design

Code Comparison

behaviac:

BEHAVIAC_BEGIN_PROPERTIES(CBTPlayer)
    BEHAVIAC_REGISTER_PROPERTY("HP", "Health Points")
    BEHAVIAC_REGISTER_METHOD(Move, "void Move()")
BEHAVIAC_END_PROPERTIES()

gdx-ai:

public class PlayerAgent extends Agent<Vector2> {
    public PlayerAgent(Steerable<Vector2> owner) {
        super(owner);
        this.setSteeringBehavior(new Seek<Vector2>(this, target));
    }
}

Both libraries offer ways to define agent behaviors, but behaviac focuses on behavior trees with a more declarative approach, while gdx-ai provides a broader set of AI tools with an object-oriented design.

Behavior Trees Library in C++. Batteries included.

Pros of BehaviorTree.CPP

  • Lightweight and efficient C++ implementation
  • Extensive documentation and examples
  • Active community and regular updates

Cons of BehaviorTree.CPP

  • Limited visual editing tools compared to behaviac
  • Fewer built-in decorators and composites
  • Steeper learning curve for beginners

Code Comparison

behaviac:

BEHAVIAC_BEGIN_PROPERTIES(CBTPlayer)
    BEHAVIAC_REGISTER_PROPERTY("HP", "Health Points")
    BEHAVIAC_REGISTER_METHOD(Move, "void Move()")
BEHAVIAC_END_PROPERTIES()

BehaviorTree.CPP:

static const char* xml_text = R"(
 <root main_tree_to_execute="MainTree">
     <BehaviorTree ID="MainTree">
        <Sequence name="root_sequence">
            <CheckBattery   name="check_battery"/>
            <OpenGripper    name="open_gripper"/>
        </Sequence>
     </BehaviorTree>
 </root>
)";

Both libraries offer powerful behavior tree implementations, but behaviac provides more extensive visual tools and a wider range of built-in nodes, while BehaviorTree.CPP focuses on a lightweight, efficient C++ implementation with better documentation and community support. The code examples showcase the different approaches to defining behavior trees, with behaviac using a property-based system and BehaviorTree.CPP utilizing XML for tree structure.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

License Release Version Updates PRs Welcome

访问http://www.behaviac.com/获取文档,教程,API,FAQ,源码,下载等一切相关资料

  • behaviac是游戏AI的开发框架组件,也是游戏原型的快速设计工具
  • 支持行为树BT,状态机FSM,HTN等多种范式
  • 方便的编辑,实时和离线调试
  • 支持全平台,适用于客户端和服务器,助力游戏快速迭代开发
  • 官方网站是文档,教程,API,FAQ,源码,下载等一切的入口
  • 您可以加入我们的QQ群433547396获得即时的帮助或者信息反馈。
  • BehaviacSetup*.exe是安装包,内含可执行的编辑器及示例。如需要自行构建,需要去官方网站或github behaviac下载或克隆源码,然后可以访问build获取构建帮助

Visist http://www.behaviac.com/ for documents, tutorials, FAQs and all other information

  • behaviac is a framework of the game AI development, and it also can be used as a rapid game prototype design tool

  • behaviac supports the behavior tree, finite state machine and hierarchical task network

  • Behaviors can be designed and debugged in the designer, exported and executed by the game

  • The designer can only run on the Windows platforms, The run time library is implemented with C++ and C#, and it supports all major platforms (Windows, Linux, Android, iOS, Unity etc.) and Unity.

  • The C++ version is suitable for the client and server side.

  • Website for documents, tutorials, API,FAQ,source code, downloads,etc.

  • BehaviacSetup*.exe is the setup package with the binary editor and demo executable. You can download/clone the source code from github behaviac