So I'm working with my BehaviorTree implementation as part of my Sim AI (FPS like Sim, but alot of social interaction).
I keep coming to the issue where I am at a particular node of my BT (say part of the idle subtree), but at that point there are a large number of things the player can do that an observing AI agent(s) needs to respond to (gaze zones, (non)aggressive postures, picking up various object in the scene, shooting at, dropped a grenade, all the things you can can say, gestures, and many more).
Another instance where this type of thing happens is player to NPC dialogs.
This need to respond to a large number of things (at any time), quickly really complicates the BT (at least the way im constructing it). Also my BT visual editor becomes a mess that is dificult to navigate and understand. With BTs I was trying to avoid the mess that happens with a visual HFSM editor.
How do people usually deal with this in a BT framework? Lots and lots of monitor nodes high up in the tree (or a high up active selector with MANY children)? Also if a monitor picks up a specific event, that event needs to be handled with respect to previous context (where you were in the tree before the event), how is that usually accomplished?
Is it a common practice for the BT to have a more DAG like structure, where nodes lower in the tree have children that are higher up in the tree (multiple parents for that node), potentially causing cyclical references? Dialogs seem to potentially need something like this.
Thanks for any advice?
Dealing with a large number of events in a BT system
What's the point of placing nodes in such unnatural places that they execute with a wrong context?How do people usually deal with this in a BT framework? Lots and lots of monitor nodes high up in the tree (or a high up active selector with MANY children)? Also if a monitor picks up a specific event, that event needs to be handled with respect to previous context (where you were in the tree before the event), how is that usually accomplished?
What I meant by nodes executing with respect to the right context is if for example, I placed many monitor nodes (or an activeselector with condition controlled subtrees) higher up in the tree (would only have to that once) that would respond to all the events that I could be looking for.
One of those monitors might fire, while I am lower in the tree somewhere, but that monitor at a higher level wouldn't know where i was in the tree previously (at least the way I implemented my monitor/activeselector), and just switch out to the tree under the monitor, loosing the context of what was going on.
If every node in the tree that would be considered a special context for an event, were to have the all the monitors duplicated there, that would be ALOT of monitors.
I must be thinking about this in the wrong way.
Maybe a BT isn't the most appropriate tool for your situation...
Was thinking of going there as well.
Already have alot invested in my BT system, works well for many things the AI does. I guess I need to try to see how I can adapt/extend/wrap it for encompassing my new need.
Anyone have an opinion on that?
Apoch, I believe I understand your point.
Its not so much a matter of time investment of building up my current framework (although emotionally i guess it irrationally factors in), its that the method (BT) is working for me in a myriad of ways that HFSMs failed me or over complicated things.
The goal is that the AI is almost completely data driven, and there is visual tool, that a semi-layman can use for authoring. I have worked with HFSMs (with a visual tool) this way and found it could be pretty awkward expressing things (that I care aboutfor my AI) that are easy to express in BT.
The many context event problem. may be one of those problems expressed in a BT would be just as cumbersome or even worse. Square peg, round hole.
Every method has its pros and cons. I need to consider other methodology maybe for this type of problem. I just would like to try to continue using BT for most things and another method for this issue. Yet mixing things is often harder than it seems.
Thanks for the input.
For a video game, you can probably get away with your utility function being just a sum of terms that indicate features that make an action desirable or undesirable. In some situations there is a natural scale for measuring utility (e.g., dollars), but sometimes it is tricky to balance terms that are very different in nature. Most of the terms in the utility function can simply be one-variable functions: One for health, one for health of my allies, one for health of my target (if I have one), one for how much money I have, one for obeying an order... The exact shape of those functions could be data driven.
It might take a bit of work to get used to expressing behavior as maximization instead of more direct commands, but I have had very good experiences with these systems. In particular, they are easy to tweak when agents are not behaving as desired (especially if you build some dumping mechanism for debugging), and they prioritize desires extremely well in unusual circumstances (so they don't try to finish their coffee when someone walks into the room with a gun, because the satisfaction of having coffee is dwarfed by the desire to be safe).
I expect it would be relatively easy to integrate BTs and utility-based decisions, for instance by having some action-selection node in the BT that evaluates a utility function to decide which plan to take. I have no experience with these mixed systems, and I prefer to keep things uniform. But if you are heavily invested in BTs, you might want to consider this option.