[SOLVED] Gdx-AI Behavior Tree with conditional aborts?

Hi

This is an AI question using Gdx-AI behavior tree API. As I know some folks here are already using this API in their game. Thought I can ask for help here.

My question is how we can approach conditional aborts with Gdx-AI behavior tree?

This is an overview of what conditional aborts are. It’s from a Unity library called Behavior Designer:

@ia97lies afaik you are using Gdx-AI, maybe you have something to add? :slightly_smiling_face:

Regards

2 Likes

I always try to design my behavior trees with the standard features like parallel, sequence and selector. If I have to abort something I have sequence with a detection of a variable I can set and unset. In parallel I have the logic for the abort which sets or unsets that variable which kind of mimics an abort. Not sure if that’s what you where looking for.

There are as well some guards in it which might go in the direction you want maybe. I never used it.

And yes I use ig a lot not just for AI or NPCs. My latest usage was for a window-camer and projected-focus

2 Likes

Thanks @ia97lies

Dynamic guard seems to be what I was looking for. :slightly_smiling_face:

1 Like

@ia97lies are you dynamically switching tasks in the behavior tree?

For example, say a player can do these simple actions from the action bar:

sword attack, fist attack, and gun attack.

(suppose the above actions are not instant actions means that when triggered, the agent will automatically move into a proper distance from the enemy then start the action and the action might repeat itself a few times until the enemy dies, similar to the auto-combat in mobile RPGs)

Would you create a new task whenever an action is triggered and replace it with the currently running task in the behavior tree?

Interested to hear others opinions as well :slightly_smiling_face:

Hi, not sure if I understood correctly but every NPC or in my case as well weapon do have their own behavior tree instance. For example to model my weapon behavior I have to wait at some point until the player or NPC realeases the trigger and for that I have a WaitUntilSuccess wrapper task which stays in the state RUNNING until the trigger gets released task does succeed and then it returns SUCCEEDED. I guess in your case this is the attack until the opponent is down or can escape. Not sure if it makes sense to you what I’m saying and if I answered your question. Here I wrote a blog post about behaviour trees and there is this wait until success in action (code sample in the end) Behavior Trees for Weapons – artificials.ch
Btw behavior trees had a similar impact of the way I’m looking at problems like ECS it’s a great way to reduce complexity and improve flexibility.

1 Like

Thanks for your response and for the article.

Yeah, suppose a complex game in which player can have many actions to do in-game. From chopping trees to killing beasts, crafting items, farming seeds,…

It is very hard to design all this in a single giant behavior tree.

I was thinking of implementing each of non-instant actions with a separate Behavior Tree and run it whenever the player triggers the action.

So I was thinking of having a root behavior tree on the player which controls the execution of tasks and I can dynamically switch tasks.

Does it make sense?

I hope it’s clear now.

Oh yes I do this as well. Ever specialized NPC has his behavior and I do not have one big one. And yes you can have behaviors even in tasks. I actually have that as weapons have a behavior and NPC which uses have behaviors. So I do exactly that what you describ and have a good experience with that.

1 Like