Game Development Community

Herding/Flocking rules

by James Daniel · in Technical Issues · 02/03/2005 (8:19 am) · 18 replies

I'm implementing both flocking and herding AI in the AIPlayer and I'm still not getting the effects I'm looking for. I've come to the conclusion that I don't have the correct set of rules to extend classic flocking. My flocking is based off of "AI for Game Developers", chapter 4, and the three rules given, Cohesion, Alignment, and Separation) are working as expected.

I added a rule, isolation, which has the bot move when it has zero neighbors within its Field of view. Everything works fine if all of the bots are moving but I never see the drifting of herds. I'm looking for ideas on how to get this effect?

#1
02/03/2005 (9:32 am)
Why not have a queen bee? Difference being:

1. Cohesion: Drones are twice as attracted to the queen bee compared to others.
2. Alignment: Queen bee doesn't give a hoot about alignment
3. Seperation: Queen bee has double the urge to seperate from others.

That should lead to a pretty mobile swarm. Probably need to tweak the values to get your desired rate of ummm.... migration
#2
02/03/2005 (2:53 pm)
www.red3d.com/cwr/steer/
This is a nice website for steering behaviors (such as flocking). Its recommendation is similar to Eugene's. A key difference is that the main priority of a drone is to stay out of the queen's way. Otherwise you get the same problem as in ZAP where the bots have a tendency to hold their leader against a wall.
#3
02/03/2005 (3:06 pm)
A queen bee is a good idea.

i found that if you implement collision prediction & avoid future collisions instead of avoiding imminent collisions, alignment & separation just happen as a result.

here's my simple 2D implementation, with a queen bee:
elenzil.com/orion/progs/flock/Flock1.exe
#4
02/04/2005 (8:15 am)
Queen bee is a good idea, for sheep bots. For cow bots, who don't follow a leader nearly as much as sheep, we still need a rule or rules that cause the herd to drift.

Here are some questions I've been looking for answers to:

When should, or what causes, a herd start to drift.?
How to have only a small number of bots to drift at one time?

Currently my thoughts are leading me towards some kind of aplication of fuzzy logic when I can come up with some rules to apply.
#5
02/04/2005 (8:58 am)
There's no reason that the queen bee has to be visible. It could be an invisible leader object that will provide the same effect on the flock, but the flock won't appear to be following a specific cow.
#6
02/18/2005 (9:31 am)
Thought I'd let you all know that I've got the Flocking (herding) working. I'm now working on a resource posting that should be submitted RSN.

Eugene Goh: The queen bee, or 'herd matron', was the answer to my problem. It did need some work so that the other herd members would act correctly. The three major new rules are 1) Move when the HM moves. 2) Stay with in the Min/Max separation limits. 3) Keep the positional relationship with HM ( this can have a small fluctuation when moving).
#7
02/18/2005 (9:46 am)
Nice. I'm doing something similar in my game. Can't wait to see your resource.
#8
02/18/2005 (1:20 pm)
Omg there are too many forums on this site. I just found this one, cos I have gotten to the AI section of my design document. Maybe I am just easily impressed, but that Flock.exe is awesome Orion. ;)

Ian
#9
09/26/2005 (12:41 pm)
I agree, it does indeed rule! Ive just been playin with it for about 1/2 hour. Im going to need some sort of herding AI for the animals in my game. The queen bee tactic seems to work really well.

Max
#10
09/26/2005 (12:51 pm)
FAST FLOCKING!

Some flocking algorithms are n-squared algorithms. I've found that the flocks look just as dynamic if each agent that you add the the flock only follows the agent in front of him in line. As long as they are given impluses due to being far or close to their leader, and the agent in the front of the line follows the herd-mother, you can create flocks that look just as good as n-squared flocks. This is the algorithm I used in Medal of Honor: Breakthrough for bird flocks.

I don't know what you are currently using, but you may want to think about a scheme like this for large flocks. Of course, you may already be doing this!
#11
09/26/2005 (12:55 pm)
Huh. Your little demo is cool. Looks like you are only having each follow one, which is good.
#12
09/26/2005 (1:59 pm)
Neat demo. Unfortunately the zoom doesn't seem to work. I'd liked to have been able to see more of the map at once. Oh well.
#13
09/29/2005 (9:33 am)
It worked on mine, just scroll down with the mouse button.

By the way i thought of something to add to the simulation which might help it. Why not keep changing the queen bee for another drone after a random amount of time. This would make it move even more like a herd and not just "follow the leader" style. It would work well in a slow moving herd, but im not so sure about a faster flock. Anyway its just an idea.

Max
#14
02/17/2006 (10:27 am)
Try here, or do a search in resources on the word Flocking

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7240

Jim
#15
02/17/2006 (10:33 pm)
Does anyone know if you can use fxSwarm for larger objects besides bees,
I would like to swarm butterflys.

I can't compile the mod cause I don't have a lic yet.

But how good does fxSwarm work ?

Thanks,
#16
03/02/2006 (11:11 pm)
@Areal

fxSwarm can be used as a base. I did a this and got good results. Here is a shot of the result ingame, here I have a hen and her chicks. The hen move around the place within a defined area, pecking the ground as she goes. The chicks are following the hen in a chaotic way, doing their own business but never letting the hen go too far before following. The result is very nice. This work in multiplayer as well.

www.wcaf.com/public_pics/chicken_shot.jpg
fxSwarm for insect is ok but it need optimisation, if it's optimised you can get swarms with upto 5000 with minimal fps reduction, normal fxSwarm kill your cpu with 500.
#17
04/23/2006 (6:42 pm)
Claude-Alain, if it possible,how you get fxswarm to work with the chicken. That cool chicken model. Did you create it.
#18
05/18/2006 (3:33 am)
As said, it's used as a base I mainly resused part of the fxSwarm flocking algorithm but my version of fxSwarm is quite different to the original fxSwarm and is becoming a central ai object to handle all kind of animals with different behaviour. Don't ask for the code or for releasing it as a ressource, the whole is far from being finished and I have not too much time to develop it further right now.

If you like to do something similar fxSwarm is a good starting point but need significant change to handle sim object instead of drawing sprites.