I’m not sure how much the predators are getting schooled but the prey are using nature’s age old defense mechanism of safety in numbers. So here is a refactored version of a flocking/schooling behavioral model that I had posted on chiti-graf.net.
Also I had a request recently to provide the source code via GitHub. You can now access the source code via the following link.
Basically my code is based on Ben’s code with a predator thrown in to pursue the prey. I was inspired by watching sharks swim through a school of fish as shown the images below. I added the avoidance behavior to the prey’s Boids behavior model. The predator just has a “chase prey” behavior with a basic tendency to stay on the screen, from which the prey also inherit that same behavior.
Update: It took me some time to get around to this but I finally updated the code for the flocking behavior models. Previously the avoidance function was not working very well. I spent some time and did some major refactoring, cleaning up the code a bit and fixing the avoidance function. I’m fairly happy with the results now.