Simulating a bait ball (flocking)
For example, the sharks would have a "desperateness" emotion that would increase over time, and would trigger an attack after a while. After an attack, it would go down to zero and the shark would start circling again...
Sounds cool though, do you have any screenshots?
Join us in Vienna for the nucl.ai Conference 2015, on July 20-22... Don't miss it!
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!"
Unless of course, you are looking for something simplistic as an EFFECT rather than trying to model the actual behavior. It sounds like you are doing the simulation, not the effect.
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!"
I don't have any screenshots at the moment because i'm on a different computer.
I think you're right about not modelling the fish to go into a ball but rely on the avoidance of the predators to do this for me.
It does however mean i have to get both the behaviours pretty much spot on to get the desired effect, lots of trial and error me thinks!
If it still fails after that i may just force the fish into a ball just to see what it would look right but you're right, IF, i am really more going for a simulation rather than just the effect.
Cheers.
Generally, I think in that situation the fish arent actively trying to form a ball, but in fact form a ball despite their efforts.
The fish will usually try to escape and move away from the ball, toward whatever cover / open water / whatever they use for their defense mechanism, but are actively herded into the ball by the predator. For the purposes of your algorithm, Id suggest that this is equal to having a flock destination that points wherever the predators' ring is weakest, with the general effect in nature is that they attempt to get to that weak point but the predators are too fast and close that gap, and the fish choose another weak point instead.
One question I have is, what exactly do you mean by "making the zones tighter"? Do you mean you are decreasing the area-of-effect for the repulsion effect, so that the fish group more tightly?
In nature, Id say that that isnt really what happens... rather the closeness is, again, in spite of their efforts rather than because of them. It is the predators pushing them so that the fish dont have enough room to stay out of each others' space.
Your basic algorithm sounds pretty good, to me... As you've said, it works well for general roaming.
My suggestion would be to leave that behaviour as unchanged as possible, but rework your predator repulsion zones.
eg - Try setting up a solid ring or sphere with a really strong repulsion (strong enough to 1: Force the fish into a confined space and partly overcome the fishes' own repulsion zones, and 2: overcome their destination turning and keep the fish from breaking out of the ring).
Then, simulate weak points by randomly setting a destination point outside of the ring, and changing that point when the fish get too close to the ring.
To do it with predators you would have roughly the same setup, but instead of a solid ring, the predators would be attempting to move in such a way as to create the best ring that they can, and the weak-points would occur naturally. Doing it with a solid ring first just makes it easier than having to tweak both the fish and predator zone strengths at the same time.
In order to model this, you would have to have each prey agent ignore the predator on the other side of the ball - negating that predator's repulsion zone therefore making it look like the vector through the ball is the safe way to go. How do you model that without a ton of LOS checks?
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!"
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!"
The way I see it, each fish is only influenced by what it can sense. Things that are closer and/or larger tend to be easier to see, while things a relatively short distance further away might barely be sensed or not sensed at all because of camoflage. Fish are also probablyt sensitive to the small currents created by the other fish around them, which could give them a good idea of where the school is going.
So...my influences on the steering would be:
1. Direction that closest neighbors in front of fish are swimming (fairly constant influence)
2. Direction that points towards closest neighbors (quickly becomes stronger as the distance to the neighbors increases)
3. Avoid collisions with neighbors in front by slowing down and possibly by also steering away from the school (quickly becomes stronger as the fish approaches the neighbor in front of it, this shouldn't be too important if the fish all swim at the same speed anyway)
4. Move towards goal (very weak, so it just affects the fish that don't have neighbors in front of them or any other influences)
5. Run away from predators
A simple way to simulate the predators might be to have them going in a circle of a fixed radius around the approximate center of the school. The influence of the predators on the fish, the speed at which predators circle, and the number of predators could be adjusted. In fact, a simple steering behavior for the predators could be just trying to stay on their goal position in a circle that is spinning around the fish.