Simulating units 'flooding' a door

Started by
4 comments, last by LancerSolurus 10 years, 11 months ago

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.

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

Use steering instead of pathfinding.

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

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.

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

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.

******************************************************************************************
Youtube Channel

This topic is closed to new replies.

Advertisement