Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

What does it mean for a group of units to reach a point?

4: Adsense
  • You cannot reply to this topic
7 replies to this topic

#1 Asik   Members   

171
Like
0Likes
Like

Posted 16 May 2017 - 10:06 AM

In an RTS you can select a group of units and tell them to go to a point on the map. Obviously not every unit can actually go to that point since they occupy space.

One easy but not entirely general way is to define a group formation, interpret the destination as the middle of that formation and send each unit to a position within that formation. Some games work almost entirely like this, e.g. Age of Empires 2.

Forcing units to always have a formation is restrictive though, and sometimes it's impossible to get in the right formation due to obstacles and other units. So we need a fallback strategy. In other words a unit must have a definition of what it means to have "reached" the destination, even though it may not be possible to reach the exact destination point and it may not be possible to occupy a pre-defined position within a formation. Age of Empires 2 doesn't handle this well; units go to the "nearest" legal position even though that may cause them to clip with other units.

I've looked a lot at what Starcraft 2 does when you select a group that's too spread to keep formation (or just click in the middle of the space it occupies). Units seem to all converge towards the destination point, but then some push the others to some extent and some let themselves be pushed and the result is unpredictable, although acceptable in general. It is assumed players can just keep clicking the same point if they want units to try and group more closely. It's really hard to tell what the exact rules are though.

There seems to be a lot of literature about group movement but not much about how the pathfinding actually terminates. Any good references or insight?


Edited by Asik, 16 May 2017 - 12:22 PM.


#2 Alberth   Members   

9165
Like
0Likes
Like

Posted 16 May 2017 - 11:01 AM

Never studied this topic, but my first reaction is "it very much depends on what the game author considers good enough".

On second thought, I would say is no agreement about it, in fact, I'd see it as part of the game. Suppose you program roman soldiers against peasants and farmers. I think these two kinds of armies would arrive in totally different fashion. Roman soldiers are highly organized, and would arrive in formation. Peasants and farmers are just a bunch of random guys that never fought in their life, I'd expect them to just arrive near the place where they are supposed to arrive, in some random way. If they would arrive in formation, and the roman soldiers would arrive in disorder, it would totally ruin the atmosphere, I think!


Edited by Alberth, 16 May 2017 - 11:01 AM.


#3 frob   Moderators   

44324
Like
0Likes
Like

Posted 16 May 2017 - 11:19 AM

It means whatever you implement it to mean.

The method I've usually seen is that characters attempt to reach the goal, and they will stop if they are unable to reach the goal after multiple reroute attempts.  This can also help if the character becomes blocked while traveling across the map. If for some reason the character becomes blocked, perhaps someone builds walls around them, then they stop.  If they approach the destination and there is a group of other units in the way, they also stop.  In both cases they may attempt to reroute for a few seconds, but if they repeatedly cannot reach their goal they stop.

If your objects can push each other out of the way, you might want all of them to push each other out of the way until all of them reach the destination.  It can lead to crowding, but can work. You will have the same issues of stopping if the unit becomes blocked and rerouting fails, so it is more work even though it seems similar at first.

I have seen games where formations travel together, and when you choose a destination each unit picks a navigation target relative to where they are standing; a unit standing {x+3, y-4} from the original center should target a point {x+3, y-4} from the selected destination.  However, it still needs similar logic about being blocked, putting it right back to the first solution above.


Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.


#4 IADaveMark   Moderators   

3670
Like
1Likes
Like

Posted 16 May 2017 - 02:29 PM

You might want to check out the first person in this presentation from GDC. It's James Anhalt of Blizzard talking about some of the stuff he did with SC2.

 

http://www.gdcvault.com/play/1014514/AI-Navigation-It-s-Not


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!"

#5 Life Is Good   Members   

173
Like
0Likes
Like

Posted 17 May 2017 - 01:56 AM

That's actually one of the prime situations of Continuum Crowds !
In CC, the space is discretized into a Grid, hence a goal can't be a single point in space afterall.
Mostly, each Group's goal doesn't contain a single, but rather multiple cells.
In Addition, CC defines it's Grid cells with special attributes. One of those is the density at that specific cell. Every person of a group contributes density to the cell it currently occupies as well as to the surrounding cells.
So, people will tend to avoid each other, due to too high densities at specific cells.

#6 Asik   Members   

171
Like
0Likes
Like

Posted 17 May 2017 - 10:21 AM

That's actually one of the prime situations of Continuum Crowds !
In CC, the space is discretized into a Grid, hence a goal can't be a single point in space afterall.
Mostly, each Group's goal doesn't contain a single, but rather multiple cells.

So instead of defining a destination point, you define a destination zone? That opens up some more questions. Determining in advance the shape of the zone, taking into account static obstacles within it and the number of units going there; deciding which unit goes where inside the zone, preferably as close as possible to the center... I'm not sure it's a good idea to try to compute these things in advance. I think a system where each unit tries to get to the destination, pushing idle units out of the way (SC2-style) will adapt to obstacles dynamically and occupy close-to-optimal space without having to compute it explicitly, however the rules governing who pushes who could be complex. Obviously if every unit has to reach the point before stopping, they'll be shuffling for a very long time in case of large groups. How does the unit decide it's made a good enough effort if it can't exactly reach the point, when does it stop trying?


Edited by Asik, 17 May 2017 - 10:23 AM.


#7 IADaveMark   Moderators   

3670
Like
1Likes
Like

Posted 17 May 2017 - 10:53 AM

Another way of doing it is to still determine a destination point (most games are done in some sort of fine XY) but give them a radius at which it is OK to say "close enough". If you are selecting a group to move to the same point, you could, for example, count the number of units in the group and come up with a radius inside which they can assume they have arrived. That would have the side-effect of everyone clustering on the "near" side of the point, however. Using standard flocking algos, though, you could have a moderate attractor to the destination point, but something that could be overridden by the "separation" vector of flocking. That does 2 things: first, you would stop if there is someone between you and the point (or on the point). Second, as more people arrive, they will slightly push each other along until there is a natural equilibrium of folks that are "close to the point but separated from each other".


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!"

#8 Alberth   Members   

9165
Like
1Likes
Like

Posted 17 May 2017 - 11:05 AM

@Asik:

Instead of trying to copy behavior of $random game, I'd suggest you start at the other side, what do you want to happen?

Then design an algorithm that achieves that, at least for most practical cases that happen in your game.

 

To me, the problem looks sufficiently complicated that you will never achieve 100% perfect. Unless you write a scientific paper or do a PhD, I think that's not a problem.