Weighted blending vs priority groups

Before I go on with the Path follow conundrum, I have a really small demo to show. These basically evolve as I try different techniques and test them. Now that I have a number of working steering behaviours to choose from, I have been trying out mixing techniques again.

To make it short, imagine we have 2 steering behaviours working on an agent: followpath and separation (this one simply accelerates the agent away from another agents if they should get too close). Let’s call these A and B.

Here is how weighted blending works:

  • each returns an acceleration as a vector with 3 components
  • each has a weight assigned to them
  • for example A has 1 and B has 2
  • we take their returned acceleration and multiply them with the weight
  • we add the results
  • if the length of the resulting vector is bigger than a set maximum value, we normalize the resulting vector and multiply it by the maximum value

And here’s how priority groups work:

  • we put B in priority group 1 and A in priority group 2
  • if priority group 1 returns an acceleration with a length bigger than a set threshold value, we use that acceleration
  • if not, we use the acceleration returned by priority group 2

It’s priority groups because you can put multiple behaviours in a group and have the weighted blend of their returned accelerations as the returned acceleration of the group. The idea is that you can make collision avoidance a more important behaviour for example. So whenever there is an obstacle that has to be avoided, the behaviour will take complete control to make sure it really is avoided.

However if you think about it, you can do a similar thing by assigning a very high weight value to collision avoidance compared to pathfollow. This seems to have the benefit, that you can change the importance of the 2 behaviours much easier during runtime.

So in this demo you can see a 3 scene presentation of mixing followpath with spherical avoidance. You can load a scene by pressing 1, 2 or 3 on your keyboard.

Scene 1 uses weighed blending with a weight of 1 assigned to both behaviours. Scene 2 shows priority avoidance assigned to priority group 1 and pathfollow to group 2. Scene 3 is weighted blending again with avoidance having a weight of 10 this time.

See the demo here.


Tags: , , , , , , , ,

2 responses to “Weighted blending vs priority groups”

  1. Takuan says :

    I’m doing something similar with my steering, inspired by the same “Artificial Intelligence for Games” book that I think I remember you mentioning earlier. Having that extra layer of “tweakability” seems to be pretty helpful in combining steering behaviors, without melting my brain trying to implement a full steering pipleline with decomposers etc.

    I like the way you think 🙂

    • onetinyleap says :

      Artificial Intelligence for Games has been my number one source and main inspiration too. While the steering pipeline works really impressively in the demo provided on the book’s website and is an exciting concept, it kinda seems like overkill and, as you said, a brain melting task to implement.

      I leave the higher level functionality like goal finding, and error handling to the decision-making component of the agent, using behaviour trees, or rather sub-trees that can be used in the complete behaviour tree of the agent. I actually relocated pathfinding call to that as well. It seems more logical and cleaner.

      It’s interesting though that we both find weighted blending a more attractive solution even though it’s kind of ranked as the least practical in the book.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: