Hyperbolic Boids

Alignment:
Cohesion:
Separation:



In learning Nick Barry's hyperbolic geometry javascript library, I put together a rough boid simulation. There are twenty agents (boids) on the canvas above, trying to mimic the flocking behavior of birds or the schooling behavior of fish. Each agent tries to manage three properties: alignment, cohesion, and separation. Alignment: each agent ties to align its direction with its neighbors (so the flock heads in the same direction). Cohesion: each agent tries to head towards the center of its neighbors (so the flock stays together). Separation: each agent tries to not crash into its neighbors. You can adjust the strength of these properties with the sliders above.

Unless the direction of an agent is changing (which it usually is), the agent will move along a hyperbolic geodesic. If it reaches and edge of the octogon, it reappears on the edge opposite it. The result is that the boids exist on a genus-2 surface endowed with a hyperbolic metric. There are a couple issues with this implementation: agents should see their neighbors "through" the edges (and they should not know an edge exists at all), but this doesn't happen. Also, the program randomly crashes sometimes :)