I finally decided I knew enough to start implementing my own. I’ll go into more detail in future posts, but I’m happy with how things are coming along so far. Once I had the basic building blocks in place, it was pretty easy to cobble together a test behavior that does the following:
If the flag is available, go to it, pick it up, and bring it back home (and drop it). If someone else has the flag, try to kill them.
Once you’ve got the building blocks in place, you basically have a “language” through which you can build behavior. Kind of neat to see it coming together.
I quickly realized that assembling these trees in code was way to complicated though. After toying around with various options for UI, I settled on a small Winforms app in which I manually bind the UI to the behavior tree hierarchy. There is a little bit of tedious UI work to get this up and running, but I decided it was a more prudent option at this point than learning about WPF databinding.
The result is what you see in the linked photo (that screenshot is the behavior for the AI I described above). I’m able to add/remove/re-arrange the nodes, set parameters on them, and save this out to an XML file which can be deserialized by the game.
I haven’t done this yet, but it should be straightforward to have the game “hot load” the AI as I make changes in the editor.
Now *all* I need to do is write the AI, and fix all the design issues I haven’t forseen.
I need to think about/implement:
- target selection
- behavior vtables to aid in the re-use of certain subtrees