SimpleAI
|
SimpleAI is a small and (hopefully) easy to use C++ library for behaviour tree based AI. It's main focus is about games - but of course it can be used for other things, too. The project is released under the MIT license and thus can be used for open source as well as commercial and closed source projects. If you use it, it would be nice to provide a link to the github page.
As a default set of conditions, nodes and filters that SimpleAI already comes with:
./autogen.sh
./configure
make
make install
cmake CMakeLists.txt
make
cd src/debug
qmake
make
cmake CMakeLists.txt -DSIMPLEAI_DEBUGGER=ON
make
SimpleAI comes with a small tool that is located in src/run. You can execute your own trees with:
./simpleai-run -file src/run/behaviours.lua
After you ran it, you can connect with the remote debugger and inspect the live state of every spawned AI entity.
As the name states, it should be easy to use and to integrate into your application. You have the ability to create new customized actions, override existing ones with your own implementations and so on.
To integrate the AI into your application, your entity class should implement or include the ICharacter interface. You only have to call the ICharacter::update() method to get the AI and the character updated. You can view the included simpleai-run
tool for getting an idea on how to do this.
Once this step is done, you can go on with creating new actions for your application. All you have to do for this is to extend ITask. The entity instance given to the ITask::doAction() method contains the ICharacter that you bound to your application entity.
After implementing these actions, all you have to do in order to use them with e.g. the existing LUATreeLoader is to add them to the registry. Just call AIRegistry::registerNodeFactory() on your AIRegistry instance and you are ready to write LUA scripts with it. Again, as a reference, just check out the example code. You can also create nodes, conditions, filter and steering methods via LUA directly. See LUAAIRegistry for more information about this.
Note the usage of a few macros that makes your life easier:
Now you only have to do:
The root node created by the load method should be given to your ICharacter implementation which holds an instance of the AI class. Each SimpleAI controlled entity in your world will have one of them.
The remote debugger can also render your custom map widget which allows you to show the characters in their "natural" environment instead of on a boring plane. You can choose which entities should be available for remote debugging. The included Server
class handles the serialization of the entities. You can create one instance of a server per application map you have. Once you add an entity to the server, it gets automatically serialized and is broadcasted to all connected clients. If no client is connected, nothing is serialized and thus the remote debugging has almost no performance influence.
The remote debugging can only be active for one Zone
. So every other zone is also not affected by the debugging overhead. Usually you would split a zone by logical units, like one map is one zone. But you can also split them up into logical units like boss ai, supporter ai, ... and so on.
Features so far:
Examples on how to customize the debugger
Copyright (C) 2015-2017 Martin Gerhardy marti n.ge rhard y@gm ail.c om
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: