3D Rigid Body Flocking and Roshambo Predator-Prey System
Class | Instructor | Date | Language | Ta'ed | Code |
---|---|---|---|---|---|
CS 7492 Simulation of Biological Systems | Greg Turk | Spring 2015 | GLSL/Java/Processing | No | Github Repo |
For my flocking simulator, I implemented rigid bodies (mesh boats, in particular) that would maintain a sense of "up" regardless of the direction they were moving (in torroidal 3D space - flying boats), with an arbitrary "up" being chosen when pointing directly down. The boats would animate their motion, with a pre-loaded set of rowing animations that would play back at a speed proportional to how fast any particular boat is moving.
I implemented 3 different types of boat flocks, with each having a different range of speeds, "armor", hunger timer, spawn timer, etc, where all of these quantities were modifiable via the UI on the left. Each flock was assigned one of the remaining two as a food source, and the other flock fed upon them. (Like Roshambo, or Rock-Paper-Scissors). It was surprisingly easy to find configurations of parameters where an equilibrium state could be maintained, although ideally I would like to find the best range of parameters using some kind of randomized optimization like CMA.
This was the first time I had ever used multi-threading in Java (which proved surprisingly trivial to implement) and I was able to have a pretty smooth simulation with nearly 5,000 animating boats on my laptop
Below are some videos of the system in action (with links if the videos don't play automatically) :
3 Boid Flocks hunting each other - Red Hunts Black, Black Hunts White, White Hunts Red. Click-drag has the flocks rush toward the mouse location (in 3D). Note the torroidal boundary on every face of the cube - it was a fun challenge to maintain flock coherrence across the boundary without slowing the simulation down too much. 1, 2, 3, 4, 5, 6 |