# Simulating units 'flooding' a door

This topic is 2037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Im working on a small Tower Defence kinda game with a little twist, all of the enemy units will be released at once and it's upto the player to constrict their numbers into tunnels.

Of course I started with all the easy parts like towers and stuff but now I have to write the logic for crowd management, and I am abit unsure if there are any good algorithms for this?

Quick example...

[attachment=15615:queue.png]

Here is 8 units trying to squeeze though a door which only allows one unit at a time.

I have already created a A* grid so I know where they are supposed to go, but it's the queue principle im struggling with.

Appretiate all the help.

##### Share on other sites
I am not sure what you mean by "a A* grid", but if you mean you have computed the distance map from each point to the destination (a.k.a. "value function"), you can just use simple steering behaviors for your units, so they stay away from each other but try to advance in the direction that makes the distance decrease. With a little bit of tweaking I bet you can make it look really nice.

If your map is more of a rigid grid, you can still do some discrete version of steering behaviors where a unit moves to the adjacent grid point that minimizes the distance, among the vacant ones.

All that sounds kind of obvious, so perhaps there is more to your question and I missed it. So feel free to ask about anything I haven't covered.

##### Share on other sites

Steering... exactly what I was looking for.

To clarify what I mean about the A* grid is that since the maps are dynamically changed I need to discover the best path to the target, so using A* to get a 'map' of the best path I can use steering to guide all the units along this route.

Really appretiate this guys, thanks a million.

##### Share on other sites

What a cool website. The live demos and concise descriptions illustrate better than a wall of text, IMO.

##### Share on other sites

Actually I use steering for my AI. Since it is a full 3D environment (outer space) A* isn't a viable solution. In my implementation a straight line is calculated to the target and the AI use 'feelers' to keep from crashing into objects. Eventually the AI will work their way around objects and get close enough to attack if thats their goal. The movement is nowhere near as precise as A* but is is a workable solution in the case of 3D star systems and 3D surface maps.

1. 1
2. 2
3. 3
Rutin
20
4. 4
khawk
14
5. 5

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013186
×