I'm sure you've seen behavior like this either in real life or in videos. The amazing synchrony with which birds are able to flock turn and act like a single entity. For a long time this behavior was really mysterious to people. it seemed impossible this kind of thing could be achieved with a leader... or each bird having some global knowledge of the whole flock. Similarly, fish schooling has much of the same properties where the very intricate and synchronized behavior of the school as a whole seems to require a leader of some kind. Of course we now know that this kind of behavior is actually possible without any leader or global information on the part of individuals. That actually it emerges from relatively simple rules in which each individual interacts only with near neighbors. Well let's first ask the "Why?" question. Why do birds flock? Why do fish school? It turns out there are a number of possible answers. Here are some of the hypotheses. Predators will think that the flock or the school is is actually a single that is large and possibly threatening organism and will stay away. Or predators won't be able to target individuals in the flock or school. The flock or school will be more effective at catching prey that is by cooperative hunting than individuals would be alone. The flock or school will increase individuals aerodynamic or hydrodynamic efficiency sort of like a peloton in bicycling. These are just some of the hypotheses. There's many others. It's possible that all of them are correct. Now we can turn to the "How?" question. How is it that these flocks or schools can come to be without any leader and each individual in the group only has a small amount of information just interacting with its local neighbors? In the 1980's, a computer graphics person named Craig Reynolds, presented a very simple model of this phenomenon called the Boyd's model. His goal was really to develop realistic computer graphics of flocking or schooling behavior. He wrote a very famous paper called "Flocks, Herds and Schools, A Distributed Behavioral Model" which I have put a link to on the course materials page. In it he gives a simple model in which individuals obey three rules in order of relative importance. Collision avoidance, that is avoid collision with nearby flock mates. Velocity matching, attempt to match velocity with nearby flock mates. And flock centering, attempt to stay close to nearby flock mates. Reynolds and others who simulated this model found that these extremely simple rules produced a very surprising realism. You can see this in many simple graphic simulations of the model. Here's one. This is a schooling model using the Boyd's algorithm. You can see that these abstract or idealized fish... actually look convincingly like real schooling fish except for the shape of their bodies. So it's an impressive demonstration of complex behavior from simple rules. We're going to look in a little more detail at a NetLogo version of this model. It's in the models library in the biology section. And here's how it works. So we have a number of birds and similar to the Boyd's model, it's slightly different. But here's the idea. For each bird it obeys the following rules. If I'm too close to my nearest neighbor, then I'm going to separate from it. What that means is I'm going to turn 90 degrees from the nearest neighbor's heading or... some maximum number of degrees which is a parameter settable by the user. Otherwise, if I'm not too close to the nearest neighbor, I'm going to do two things. I'm going to align which turn the way I'm heading to make it the same as much as possible as the average heading of my neighbors. And I'm going to cohere which means I'm going to turn so that I'll move closer to my neighbors. OK. So let's look at that model. I've opened up NetLogo and then I go over to the file menu to the models library to biology and I find the flocking model. So open that and you see here I have a number of sliders which allow me to control parameters in the model. So I'm just going to do setup and go. So you can see the little birds moving along. I'm going to speed it up. They start heading randomly in random directions and moving at a constant speed. And as time goes by, they start to coalesce in flocks. And you can this better when they're moving faster. This isn't very realistic looking because it's not really mimicking the physics of flying but you can still see the flocking behavior. And notice that world wraps around at the edges here. So the way this works is, each bird starts out facing a random direction when we do setup and at each time step each bird finds its neighbors. Its neighbors are the other birds that within its vision radius which is is three patches away. Each bird looks at its nearest neighbor and if the nearest neighbor is less than the minimum separation which is here set to one patch the bird turns away. And the amount it turns away is define by this max separate turn which is here 1.5 degrees. That's the maximum it will turn. It will try and turn as far as possible within the maximum. If it doesn't have a nearest neighbor within that minimum separation it will do its align and cohere turns. Where it turns as far as possible to align with the average of its neighbors... and it will turn as far as possible to cohere, to move closer to its neighbors and that's the algorithm. For the quiz for this subunit, I'm going to give you some exercise to do with this model.