I have continued with the arraylist example called flocking.
I add health, age of boid, and a pecking order. Then, i can add predators. To amuse myself during a plague, i have been adding lifelike avoidance and hunting behaviors.
Like others have done, i have started a square wave oscillator, and tied it to the fraction of the prey species that are currently avoiding a predator.
Now, i am trying to go 3d. I had to give up on the nice directional arrow shape, and start with spheres. My spherical boids now have billiard ball collisions with others. They do not wrap but act like a boid gas confined in a clear box.
My new idea is to tune up the way that the spheres bounce off of one another to speed up the animation of the separation behavior, while leaving it very lifelike.
For now, i quickly sum all of the locations of the prey, to find the center of mass, and also find the average velocity of every sphere. Then i apply those cohesion and alighnment changes to the velocity in a single function.
Again, i am skipping the complicated check for collision risks, in favor of a simpler elastic collision with any sphere that is under 2 radii away.
I may be dreaming, but i am hoping that i can learn how to fly in the 3d sim. Vr is the obvious venue . I do not know how to link to code yet, but would be proud to share the simple code for the 2d and 3d sims.
I would even welcome help or participation in the project.