 Hi, my name is Milo and I'm an intern at the San Francisco Public Library. Today, I will be presenting a STEM challenge video. In this video, I want to show you a simulation of Boyds. Boyds is a contraction of birdoid, or something that is bird-like. In other words, Boyds is an algorithm that is designed to recreate a pattern from life, which is how birds fly together in clumps. Let me show you a demo of what a flock of Boyds looks like, and then I'll try to explain how it works. Here we see a group of Boyds that start to form small clumps and then eventually group into one larger clump. It looks really complicated because there are a lot of moving little particles, but it's actually made of really just three simple rules. Separation, alignment, and cohesion. Let's break that down. Before we can explain those rules, I want to briefly explain vectors. This will become important in a moment. You can think of vectors like an arrow. I have an x-component and a y-component, and basically you can just point in a direction with some length, like this. A Boyd is described by two vectors, its position in x and y, and its velocity in x and y. The velocity is just how fast the Boyd is moving. So, at every instant, you add the Boyd's x-velocity to its x-position and its y-velocity to its y-position. Do this over and over and you get a Boyd that moves in a certain direction. Now, back to the rules. To demonstrate the first rule, let's start with two circles. The first rule is that Boyds try to separate from one another. This means that these two circles want to separate like this. For all Boyds within a certain radius, we take the distance between the Boyds, then set the length to 1 over the distance. So, for a distance of Boyds of 0.5, the length would be 2. We add that distance to the Boyd's velocity. The second rule is that Boyds try to align with each other. This means that two Boyds want to start moving in the same direction like this. The way this rule works is we just average the velocity of all Boyds in a certain radius. To do that, we take all their arrows, add the x-components up and divide by the number there are, add the y-components up and divide by the number there are. Then we add that average to our velocity by adding the x-components and the y-components separately. Finally, the last rule is that Boyds want to cohese or move closer to the center of a group of Boyds. To do this, we take the average of the distance to nearby Boyds within a certain radius. So, we do this in the same way as in Rule 2. You add up the distances to each of the nearby Boyds and divide by the number there are. When we combine these three rules, we get what is called emergent behavior. This is what you saw at the start of the video, where Boyds can slowly group up and fly together, or sometimes ungroup when they hit a wall. I hope you enjoyed watching the Boyds. Be sure to check out the rest of the STEM challenge yourselves videos by SFPL librarians and Yale interns.