Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Dealing with a large number of events in a BT system


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 Ender1618   Members   -  Reputation: 243

Like
0Likes
Like

Posted 18 April 2013 - 02:00 PM

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?


Edited by Ender1618, 18 April 2013 - 07:17 PM.


Sponsor:

#2 LorenzoGatti   Crossbones+   -  Reputation: 2734

Like
0Likes
Like

Posted 19 April 2013 - 01:27 AM

From your description, it seems that this large amount of events and rules is desired and working well, and the only trouble is with representing and editing a complex rule system. The first suggestion that comes to mind is better encapsulation, like "macros" that can be referenced multiple times without cluttering nodes with excessive numbers of children and abstractions (e.g. a "change feelings depending on gestures and gaze zones etc." black box, decoupled from acting upon the changed feelings) to limit node fan-out.
Produci, consuma, crepa

#3 LorenzoGatti   Crossbones+   -  Reputation: 2734

Like
0Likes
Like

Posted 19 April 2013 - 01:30 AM

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's the point of placing nodes in such unnatural places that they execute with a wrong context?
Produci, consuma, crepa

#4 Ender1618   Members   -  Reputation: 243

Like
0Likes
Like

Posted 19 April 2013 - 02:40 PM

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.



#5 ApochPiQ   Moderators   -  Reputation: 16001

Like
1Likes
Like

Posted 19 April 2013 - 04:00 PM

Maybe a BT isn't the most appropriate tool for your situation...

#6 IADaveMark   Moderators   -  Reputation: 2509

Like
0Likes
Like

Posted 19 April 2013 - 04:34 PM

Maybe a BT isn't the most appropriate tool for your situation...

 

Was thinking of going there as well.


Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#7 Ender1618   Members   -  Reputation: 243

Like
0Likes
Like

Posted 22 April 2013 - 09:17 AM

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?



#8 ApochPiQ   Moderators   -  Reputation: 16001

Like
0Likes
Like

Posted 22 April 2013 - 10:10 AM

Sunk cost fallacy. Degree of investment does not change suitability for a purpose.

#9 Ender1618   Members   -  Reputation: 243

Like
0Likes
Like

Posted 22 April 2013 - 02:07 PM

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.



#10 Álvaro   Crossbones+   -  Reputation: 13645

Like
2Likes
Like

Posted 22 April 2013 - 03:48 PM

I am a big fan of utility-based architectures. You list the available actions, compute a function that maps action to a real number and pick the action for which the number is highest. The real number you compute is an indication of how happy the agent is with the action (technically it should be the expected value of the agent's utility function). The actions of any rational agent can be expressed in this framework (for some definition of "rational" that I happen to like).

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.

#11 IADaveMark   Moderators   -  Reputation: 2509

Like
0Likes
Like

Posted 23 April 2013 - 01:41 PM

Some reference on utility systems... my lectures from GDC 2010 and 2012 (with Kevin Dill)

 

http://intrinsicalgorithm.com/IAonAI/2013/02/both-my-gdc-lectures-on-utility-theory-free-on-gdc-vault/


Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#12 wodinoneeye   Members   -  Reputation: 856

Like
1Likes
Like

Posted 24 April 2013 - 07:19 AM

Sounds like you need to break your AI logic into two parts :

 

1) a goal selection system that analyses the current situation and picks the highest priority goal.+ solution  (evaluation of this is often the most difficult to come up with equivalency metrics for situational factors)

 

2) an executor for that goal+solution which is specific to the solution - you could continue to use your Behavior Tree method here - just one 'tree' for each specific solution

 

Effectively you break up you one ginourmous tree to mutliple specific use trees  - with one run when its matching goal+solution is active  (this  gets rid of excess logic outside its own domain)

 

The (1) analysis + goal selection does not have to run each cycle, though you may need to do so when certain significant events happen (triggering a general reevaluation...)

 

If the same goal+solution is selected again it should be resumed (to restore the progress made)

 

Each BT should have 'cut' checks that would be reevaluated frequently to see if the current solution is still valid (situation hasnt changed) which on failing would push execution back to the goal selection (1) stage


Edited by wodinoneeye, 24 April 2013 - 07:32 AM.

--------------------------------------------Ratings are Opinion, not Fact




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS