Product College starts on September 18. Submit your application today. Apply now.

Wrapping up boids & flocking patterns

Wrapping up boids & flocking patterns

April 18, 2017
Expand

Project: Boids & Flocking Patterns in Swift 3

Nice job! You just implemented your own swarm intelligence for fish (also known as boid behavior)!

Final flocking fish

Now you have some time to play around with the weights and distances.

The weights we have work well enough but it does take some time for the fish to cluster into coherent "schools". Can you re-weight the values and make them school together faster?

More resources

In this tutorial we covered a few mathematical concepts and basic, "boid"-style artificial intelligence.

We covered:

  • Points in two-dimensional space
  • Vectors in two-dimensional space
  • The difference between speed and velocity
  • How simple rules (cohesion, separation, alignment) can create emergent, complex behavior

Some other boid-style things to check out

  • Batman Returns (1992) used boids for movement of bats and penguins
  • The Lord of the Rings franchise used MASSIVE for it's large fight scenes. It has since been in numerous movies and TV shows. If you see a large, computer generated crowd in a movie, it's probably orchestrated with MASSIVE. Check out their professional demo reel and this real time battle sequence. They've even combined what we learned in this project and in the cruise control project to simulate traffic.
  • Boid-style algorithms can even model opinions propagating through social networks! It is not limited to just movement. Any system of individual "agents" (fish in our case) that change their properties based on those around them can be simulated with boids. This article is a bit of a long read, but very interesting if you want to see how it's done.

Feedback

If you have feedback on this tutorial or find any mistakes, please open issues on the GitHub Repository.

Summer academy

An iOS Development Summer Course

Design, code and launch your own app. Locations across the USA and Asia

Find your location

Product College

A computer science college

Graduate into a successful career as a founder or software engineer.

Learn more