Best practices for working with Utility theory & Behavior Trees

sdhains

New member
Hey!

I'm building some 'Sims-like' AI experiments with BD at the moment, and I'm trying to wrap my head around the best way to structure my trees when working with a Utility Selector. My project is going to be a fairly long-term undertaking, so would be great to get some feedback just to make sure I am on the right track.

So - What is the best way to work with many different objects that could fulfill the same needs? For example, if I was to augment the Utility Theory example (Decorator version) such that instead of one option for 'Work', there were many options more or less appealing depending on location, and efficiency. My best guess would be to create a custom Evaluator which has 2 curves, one for distance and one for effectiveness that would be assigned to each additional work action. Each new work location/action would be placed under the Utility Selector as 'top level choices', presuming that nesting of utility selectors is probably a bad idea.

Instead of simple 'Work', 'Eat', 'Sleep' evaluators under the Utility Selector, a more complex example might be something like 'WorkComputer', 'WorkDesk', 'SleepBed', 'SleepCouch', 'EatTakeout', 'EatKitchen' and so on. This would mean that as more options and variety for the Sim are added, the direct children of the Utility Selector keep expanding.

As a side note, I figure that if the behavior of any of these choices is more or less identical (Go to object, trigger animation) - I could use an external behavior tree to avoid repeating too much logic.

The other thing that I am curious about, is how I might be able to insert logic into the behavior tree when a new object is included in the scene. Say my Sim purchases a new Television; how would I inject the TV's behavior tree into the Sims?


Thanks!

Sam
 
Last edited:
You could have a high level Utility Selector that chooses between work, sleep, eat, etc. If the selector has decided that the character should sleep the behavior tree can select if the character should go to a bed, couch, or floor depending on your own condition, such as a distance check or a random number. This will make it the most extensible in that you wouldn't need to create a new utility curve for each specific sleeping object.

The other thing that I am curious about, is how I might be able to insert logic into the behavior tree when a new object is included in the scene. Say my Sim purchases a new Television; how would I inject the TV's behavior tree into the Sims?
One way would be to create a custom task that always gets the list of valid objects in the game, and then returns that list to another set of tasks which perform the action on it. This will prevent you from having to create a new set of tasks for each specific object and objects can be added/removed as the game goes on.
 
Top