[Engine Mod] Experimental addition to Behavior Tree: Utility Selector

After watching the recent Advanced AI stream, and also stumbling on this call to arms from zoombapup, I decided to have a first attempt at extending engine functionality.

I don’t have any behavior tree experience prior to UE4, so I still don’t have a clear understanding of how they are best structured. That said, it seemed to me that a way to easily introduce randomness and weighting into task selection was something that could be widely useful. I decided to fork the engine repo and poke around a little. I got a bit carried away (despite some of the hairiest code I’ve ever seen on the BT graph editor side of things) and a couple of days later have come up with the following.

BT Utility Selector - Engine fork repo
BT Utility Selector - Example project repo

There are more details in the readme in the forked repo, but basically it works as follows.

  • An extra composite node type, Utility.
  • Children of this node have a utility function attached. This provides the utility value for the child, through a constant, blackboard key or custom blueprint logic.
  • The Utility node will choose one child to execute - either using a proportional (weighted) selection method, or one which simply always selects the highest utility.

If anyone has any input on if/how they might use such a feature, how they’d expect it to work, or anything related really, please let me know. And if anyone is interested enough and able to merge in the changes (make sure to merge from bt_utility branch) to their local engine source and give it a test, even better.



The top link isn’t working btw?

I’m deep into marking and viva’s right now, but give it a few weeks and I’ll have a look.

As for use-cases. Have a look on the interweb for a guy called Kevin Dill. He’s got a number of papers out there about using Utility methods. He works for Lockheed Martin, so they’re a bit military, but he gives a good example in one of his papers on the type of decision you might want to make with Utility, or in his case dual-utility. Which might be a good start.

If you read Kevin’s paper, he might give you some ideas for different ways of using the Utility values as well (using highest from the top percentage of choices etc).

I think Utility is a pretty natural fit into BT’s because the decision logic can neatly fit in there. One other area I want to explore over summer is from Valve’s “two robots” demo from a few years back. Having a nice way to author dialogue, multi-agent interactions etc. BT’s are great as a model, but they don’t seem to be that natural for inexperienced users to author. I might do an quick implementation of our StoryBricks approach as an experiment too.

Good work though! more of that sort of thing I say!

BTW: I’m definitely going to be doing a Influence map toolkit too, because a number of my students worked on those and I feel bad for not having the time to do them a tutorial on it. Plus they’re easy and fun!

Thanks for the feedback, really appreciate it.

I should have said, the forked repo will only be viewable if you’re logged in to github and have your account connected with unreal engine. At least, in that case I’m pretty sure it should be viewable. Or are you able to view the original UE4 github repo, but not my fork? If so please let me know and I’ll look into it.

I’ve bookmarked a video that guy did recently on utility theory and will watch it soon. As for how to process the utility values, yep there’s obviously any number of ways to go about it, and the best choice will be situation dependent. The nice thing is, this is the kind of logic that can be customized really easily in the editor - select from a bunch of presets, or just throw something together in a blueprint graph.

Just did a quick search on influence maps, it looks like they have a fair bit of overlap with what I’m currently working on, more in terms of the implementation details than use case. So I’ll keep an eye out for that too.