View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

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

# Simulating units 'flooding' a door

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Thanamos  Members

Posted 08 May 2013 - 06:04 AM

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...

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.

### #2Álvaro  Members

Posted 08 May 2013 - 08:11 AM

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.

Posted 09 May 2013 - 09:24 AM

http://www.red3d.com/cwr/steer/

Specifically...

http://www.red3d.com/cwr/steer/Doorway.html

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

### #4Thanamos  Members

Posted 10 May 2013 - 09:25 AM

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.

### #5Kryzon  Prime Members

Posted 12 May 2013 - 09:21 PM

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

### #6LancerSolurus  Members

Posted 12 May 2013 - 10:13 PM

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.

******************************************************************************************