Conflicts between steering behaviors

Started by
12 comments, last by Kylotan 16 years, 3 months ago
Again, solve the actual problem you are trying to emulate. When we all say "let's meet over at the lamp post", we don't mean "all 25 of us need to be touching the lamp post." We are quite content to go stand within a certain reasonable distance of the lamp post until others show up. If we need to make room for people arriving, we do. If not, we just hang out near the lamp post. The actual lamp post itself is not a magical object - it is an abstract area that is defined by the lamp post for the sake of communicating the idea of "over there".

So, to emulate this...

If you know how many units are going to be at the arrival point, you can calculate an acceptable radius from the actual distinct point. The more units going there, the bigger the radius. Once a given unit is inside that radius, you turn off the arrival behavior and leave on the separation one. That way, peeps will "make room" for new arrivals to some extent.

The only tricky math will be at design time coming up with an algorithm to determine an acceptable radius based on the desired separation distances between agents. You want to make it big enough so they don't have to really jostle each other to all fit, but small enough so that it is obvious they are supposed to be meeting up there.

The only change you need to make to your code is to incorporate the radius calculation - which doesn't even really NEED to be dynamic. If it's not dynamic, then it can be a fixed value in the code. The only line change would be a simple if statement that checks the distance to the arrival point... "Am I close enough?" leads to "Do I add the arrival vector or not?"

The point is... sometimes we get so fixed on discrete, perfect solutions, that we lose sight of what sort of behavior we are actually trying to accomplish. In your example, you stated:
Quote:I have a group of units which I'd like to order to a specific position.
You knew that by "specific position" you didn't mean that they should all stand on top of each other - that's why you were incorporating separation behaviors. However, as you proceeded, you were still locked onto the concept of the "arrival behavior" which, once you get to a certain point, becomes all but meaningless. It's much like the legendary runners paradox... where you cover half the distance, then half the remaining distance, then half the remaining distance... such that you never arrive. The paradox only holds if you assume that time is slowing down for you as well to the point where time is all but frozen. In this case, your false premise was holding onto the idea that your agents were desperate to reach that given point - despite the fact that they knew they couldn't all stand on it. At some point, the specific target point becomes irrelevant so therefore so does the arrival behavior.

The best solution for that is to put yourself in the place of your agent for a moment. In this case, if you would envision approaching the lamp post that was already crowded with people and saying "well, here's the meeting place - this is close enough." That statement, of course, is analogous to getting inside the acceptable radius. The next statement would be "it wouldn't look real good if I were to go and snuggle up to dude over there - I should keep my distance a little from each person." There's your separation behavior... still in effect.

In short, you were making your behavior model the logic of your math rather than making the logic of the math model your behavior.


Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
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!"

Advertisement
I think a good formula for the radius would be the circle whos area is 1.5 * averageUnitArea * numUnits. 1.5 allows for adjustments.

You might want to read Craig Reynolds paper again, because it doesn't sound like you implemented correctly. From what I understand, you are directly moving the agent's screen position to avoid crowding. Although the paper does mention this method, the entire idea of steering behaviors is that the agents are merely controlling their orientation and velocity, never directly altering thier x/y/z position. Please read on.

To get smooth movement you mustn't be hard-coding collision responses (ie, collision detected, move agent back 4 units). That should ideally never happen. What you want to do is simply rotate the agents facing vector away from the other agents vector. So if two agents collide (or have overlapping visibility radius) then multiply each agents vector velocity by the others vector multiplied by some constant (such as the current movement speed). Doing it like this will allow quick response for fast agents and ease back as they slow down. Also, if you are using the arrive behavior, the agents should be slowing down anyway, so their influence should be scaled down.

A quick solution would be to do as others have said and have the target position be an area like a circle, and have the agents pick random positions within that radius. You never want to have a large group of objects all arriving at the same location as you are bound to get collision issues. You can also chain agents together (have each ones target position linked to the previous agent) such that you will have a straight congo-line formation. Doing a few chains like this will make it look like there are different squads or factions all moving to the same area.
Quote:Original post by cyberpnk
To get smooth movement you mustn't be hard-coding collision responses (ie, collision detected, move agent back 4 units). That should ideally never happen.


Unfortunately that could still result from a typical implementation of steering if:
- the separation effect somehow has a non-zero threshold at the edges, or
- the updates are so infrequent that the discrete differences in forces between frames become large.

This topic is closed to new replies.

Advertisement