Swarm

What will happen to a large number of randomly moving objects if you let them follow only one rule: try to move in the same direction as your neighbors do. Soon, you will find these objects forms into groups and moving together, which is a type of swarm behavior.

Create a large number of turtles with random colors and moving in random directions. At each tick, update each turtles direction slightly toward the average direction of its neighbors. Also change the color of the turtle slightly toward the average color of its neighbors. When a turtle hits the boundary of the screen, let is bounce off to a random opposite direction.

Check out video animation of the swarm behavior.

Video of Swarm Behavior
Swarm Behavior with Python Turtle

Related Projects:

Related Post