 Hello, modelers. Let's look at a slightly more advanced model, this time a two-dimensional cellular automata. You may recall in our one-dimensional model, we had a single square or grid space, i.e., our cell, and that cell had neighbors immediately to its right and immediately to its left. But that long row or string of neighbors basically only worked in one direction or one dimension to the right and to the left. Well, now we're going to make the model a bit more complex by considering neighbors that are below and above our cell. And if we want to make it even more complex, we can also consider the neighbors in each of the diagonal directions, up and to the right, up and to the left, down and to the left, and down and to the right. In a model like this, however, we won't be able to represent successive states by laying a row of cells on top of another row of cells, but instead we'll have to represent successive states by creating entirely new grids. For example, the grid here on the left might represent our initial conditions, whereas the grid on the right will represent our conditions after one iteration or after one application of the rules. So now that we've established what an agent is, let's go ahead and establish what the states for the agent might be. For this model, there will be two states. It'll once again be a binary model with two states. And the first state we will describe, we will go ahead and call the filled-in state of a box as being on. And to indicate the off state, we'll put a little dot in the middle of the box to help distinguish it from being an empty unknown grid, but it'll basically be an empty box or off. Now that we've established our possible states, each cell will need to be assigned a state for the beginning of the simulation. So we'll have to give each state a condition of being either on or off, and these will represent the initial conditions for my entire system. We'll keep the initial conditions relatively simple here. Now in this model, each cell has eight possible neighbors, plus itself, to be concerned about. So that would be two, with two states, the ninth power for nine possible things that have different states, which is 512 possibilities of different states for each cell to look at. And if we were going to come up with possible rules for all of those 512 combinations, that would be two to the 512, which very quickly becomes a very big number, 1.34 times 10 to the 154th power. Yeah, we're not going to look at that particular version of this model. Instead, we're going to consider a more simplified rule set, where instead of considering all the possible combinations of every single neighbor, we're instead going to look at a count of how many neighbors each cell has that are either on or off, and not really caring about which ones are on or which ones are off. For example, in this particular case for the cell in the middle, you'll notice that it has two neighbors that are currently in the on position filled in, and it has 1, 2, 3, 4, 5, 6 neighbors that are off, and then it also has its own state to be concerned about, whether that state is on or off. Because we are counting neighbors, though, we are also going to have to be careful and think about how we're going to handle cells that are on the boundary. For example, let's consider this green cell right here. It's up against the boundary. It doesn't appear to have any neighbors on the left-hand side, although it does have neighbors above and below and to the right. So how are we going to handle its count of neighbors? Well, we could just ignore the fact that it has no neighbors on the left, or we could also do as we did before and assume that it does have neighbors, but that those neighbors are on the opposite side of the grid, that the sides of the grid, for example, this left-hand side, is attached to the right-hand side of the grid. In this case, this would have a neighbor immediately to the left, which is on the far right side of the grid, but if you want to go up and to the left, you end up with the one that's up above that, and if you go down and to the left, you go to the right-hand side of the grid, then grab the neighbor that is there. This gets to be even a bit more complex when you consider the grid boxes that are in the corners. For example, let's look at this grid box highlighting in yellow in the upper left-hand side. Well, it has three neighbors that are immediately visible on the grid. However, where are its remaining five neighbors? Well, if we go directly up off the top of the screen, that should lead us up off the bottom of the screen. If we consider the top and the bottom connected to each other, the neighbor that's above it is actually the neighbor on the far bottom of the screen. The neighbor that is up and to the right ends up being to the right, but down at the bottom of the screen. The neighbor that is immediately left, if we remember, left is attached to the right side of the screen, so that's the one on the far right, and the neighbor that is down and to the left ends up being way over in the right hand of the screen, but still down. And the last one we need here is what about the neighbor that's up and to the left, up off the corner of the screen? Well, that will be the neighbor that's all the way down in the lower right side of the screen. And that's how we can connect these, if we would like every single one of ourselves to have a full group of eight neighbors. This set of boundary conditions are what we call toroidal boundary conditions. T-O-R-O-I-D-A-L. Why are they called toroidal? Well, it's because the shape that's made is called a torus. A torus being basically a fancy name for the shape of a donut. Well, how exactly do you get a torus from this? Well, think about it this way. Take a piece of paper, go ahead and take a big piece of paper, maybe an 8x10 piece of paper, and if you take that piece of paper and you attach one edge to the other edge, in order to do that to make those two edges work together, you'll have to create a long cylinder that looks a little bit like a tube that you might find in a toilet paper roll. If you attach those two edges together, you end up with a long, thin roll. Well, that's attached to the sides, but what if you then have to attach the top to the bottom? Well, if you do that, you have to take this loop here and attach it around to the bottom. In order to do that, you're going to have to pull and stretch, and doing so, you'll eventually create something that looks a little bit like a donut. Now, if you're trying to do it with a piece of paper that can't stretch very well, it's going to not really look that much like a donut. But ultimately, the only way you can create that sort of shape in three dimensions, to take the two-dimensional shape and make it attached on both top and bottom, and right to left, is to create it in this three-dimensional shape of a torus. So now we've defined what our agent is. It's a cell that has eight neighbors. We've defined the states for our agent, either on or off, and that it cares about the states of its neighbors. We've talked about our boundary conditions, that we're going to have these toroidal boundary conditions, where the right side is attached to the left side, and the top is attached to the bottom. And we've also established a set of initial conditions with some of our cells being initially on, and some of our cells being initially off. What we haven't yet established is a set of rules for how to go from our initial condition to the next state. What are the rules that we are going to apply to iterate to watch how this cellular automata changes? Well, it turns out this particular model and the rule we are going to use have been studied pretty extensively and given a title called the Game of Life. We'll talk about why it's called the Game of Life in a little while, but let's go ahead and take a look at the rules for the Game of Life. First of all, it's researched extensively and given a name by somebody by the name of Conway. There's a link there that we will use in a little bit to go and observe this game. But here's the rules. Our agents, individual grid boxes in two dimensions with eight neighbors, and here the neighbors are given north, northeast, east, southeast sort of map directions. Boxes on the edge of the grid can be considered to have fewer neighbors or be neighbors with boxes on the opposite side. We're deciding to use the toroidal boundary conditions with boxes on the opposite side. Two binary states, on or off, one or zero, or full or empty. Our initial conditions is initial grid of boxes, like we've drawn. And there are lots of possible initial conditions that we can perhaps look at in a little bit. All on or all off, single cell on or single cell off. Maybe we can create some patterns or we can randomly distribute things. Okay? And what is an iteration? Well, the iteration is redrawing the entire grid with all the new states, and you can either redraw it in the same space or erase everything and redraw it in the same space, or you can redraw it in another place so that you can see the progression. We are actually going to try, in our first example, to redraw this in another space. So now let's look at Conway's rules. The rules for the game of life. Say the state of a new box is determined from the current box and it's eight neighbors. So in other words, if I'm in a certain place, my next state will be determined from my current state as well as the state of all my neighbors around me. If I live, that means that I was a full cell. I was on or full at the beginning, and I remain full. And that only happens if a certain number of my neighbors are also full. In other words, if I have exactly two neighbors or exactly three neighbors, it means I am happy and comfortable and I live. I'm a full cell that remains full. If I die, that means I'm a full or an on cell that becomes empty. And that happens if a certain number of my neighbors are full. Either if I have zero or only one neighbor, you can consider me dying of loneliness. If I have four, five, six, seven or eight neighbors, you can consider that as me dying of overpopulation or crowding. To be born, that's a condition where an empty cell becomes full, going from empty to becoming full. And that happens if a certain number of neighbors are full, exactly three neighbors, three and only three neighbors. Otherwise, there's also a condition of just remaining empty. That's the fourth situation where empty stays empty. And that occurs when I don't have exactly three full neighbors. There's also a condition where old cells can change color to identify them. That happens in the computer model that we'll see in a little bit. So let's record the rules here, shall we? If we are in an on state and we want to stay on, that's called living. If we're in an on state and we need to turn off, we're going to call that dying. If we're in off state and we need to turn on, we're going to call that being born. And the last state is an off state staying off. And that doesn't really have an official title in Conway's model. So I'll just put some parentheses here. Maybe we can call that stasis or stays. And so to recall the rules, we lived when we had exactly two or three neighbors, a number of neighbors. We died when we didn't have two or three neighbors, if we had zero or one, or if we had four or more. I'll put four plus here for four or more. If we were going to be born, that happened when we had exactly three and off, staying in our same condition as when we didn't have three, when we had some number besides three. So there's the rule set for Conway's game of life. So let's go ahead and see if we can apply the game of life to our grade up above. I'm going to start with this living cell that's in the upper left hand, not quite in the very corner there, but in the upper left hand, and I'm going to go ahead and dot it out over here. We want to figure out what the status of this cell is going to be as we move from the initial conditions on the left, the initial conditions here on the left to the first iteration here on the right. So let's look at this. If I look first, I see that I have a living cell or a cell that is full, which means I'm either going to live or die, and I do not need to worry about the rules for being born or staying, but either I'm going to live or die. So now I need to count my number of live neighbors. In this case, there is one live neighbor to the south, and one live neighbor to the southeast, in which case I am going to live. So I'm going to take that grid, and I'm going to fill it in. So in the next iteration, it will be live. And I'm going to look at the next grid, the one immediately to the right of that. In this case, I have a grid that is not alive, so it is empty. It's off to start with. And so I'm going to use the rules to determine whether I am born or whether I stay put. And to do that again, I count the number of live neighbors I have. One, two, three, four. Well, I have four live neighbors, and four live neighbors mean that I'm not born. Nothing special happens, so I stay empty, effectively. I'm going to continue to apply that same process. Let me move to the right again. Again, another empty cell. Now I have one, two neighbors this time. I only have two neighbors that are live, but that is not the right number to have me be born. So once again, I'm going to stay dead. Now I move one more space to the right, and now I'm up against the boundary. Now I have to pay attention to the boundary rules. If I remember correctly in the boundary, I'm going to look up here. I'm going to look over to the right, and I'm going to look down into the right, and I will see that there are no neighbors there that are live. There's only one neighbor that's important. This is the live neighbor up to the left, and that's not enough to allow me to be born. So therefore, I'm going to stay dead. And let's repeat that same process for the last grid box in the row, the one way over here on the left. I'll make it red so it's a little bit easier to see. That grid box, how many neighbors does it have? Well, if you said two, you're correct. Only the two to the right and below, because there are none on the other side. We would have to look over here on the other side of these three, but there aren't any live boxes there, because I have exactly two neighbors. Similarly, that cell does not come to life. So now we've calculated one row in the new iteration, but we would like to figure out what all 25 of those boxes do. So take a moment, take some time, and see if you can calculate a few of these. I'll pause the recording, calculate as many as you would like, I'll do the same, and then we can check our answers. How did you do? Well, notice there's been a bit of a population boom here. Three of our cells that were originally there survived because they had enough neighbors, as did one of the cells down near the bottom. However, a couple of cells passed away from loneliness, but there were some conditions that were just perfect for the creation of some new cells, and now we have four new cells, the population has grown. So in our first iteration, our population, or our number of population being the number of full cells or the cells that are on, is now bigger. What do you suppose will happen in the next iteration? Well, there might be some conditions for additional cells to grow, but you'll also notice that some of the cells that are already there are going to be crowded. For example, this cell here now has one, two, three, four neighbors, which means it's overcrowded, and it will not survive through the next iteration. That cell will be empty in the next iteration. So for interested in studying that, we would need to create a new box and repeat the process. However, the purpose of having computers is to have them do repetitive tasks for us. If you ever find yourself doing something over and over and over again, well, it might be easier to have that automated. That's the idea of cellular automata. So our next step, we're going to go look at a version of Conway's Game of Life that is available on the internet. The web link is visible here, and will be provided to you. However, I will also show you momentarily how you can find it. So while there are multiple versions of the Game of Life available on the web, we are going to look at a particular one that's at a website called www.shodor.org. If you go to the site there, it will bring up, there's a little search box there, and you can search in that search box and then it will bring up a couple of options. The one you're looking for is the first one, Interactivate Life. What you should see when you first start up this program is a grid with lots of small dots on it. And what you will recognize is each of those, if you look closely, are small, square grid spaces. Well, we had a much different size grid when we were working with it before. Let's change some of our settings here so that we can investigate this a little more closely to start with. So to do so, you're going to want to click the little box that says Game Setup, and then if you can read it, you're going to want to change the world size. Game Setup, change the world size. Now let's go ahead and configure this into a 10 by 10 grid and apply your changes. When you do so now, which you should see, the grid will be blank, you can click Randomize, and you will see that it will fill some of the grids with red and the others will remain black. The red will be our on, and the black will be the off. And you should see that this is a grid that's 10 units across by 10 units up and down. If you once again click on the Game Setup and look at Change Rules, you will see the rules of the game, which could potentially be changed, but here's how they're listed there. You can sort of see that you can either live or die when you have zero, one, two, three, four, and so on, a number of neighbors, and our rules here are the standard rules of you live when you have two neighbors or three neighbors and die in all other cases. And then we can also use a checkbox to indicate which conditions under which an empty cell becomes a live cell, or in other words, whether something is born in that particular spot. We do not want to modify the rules at the moment, so go ahead and ignore those changes in return. Now, one of the things that you can do here is you can add any cells at any time, and notice nothing's actually happening because we're not running or we do not have the... we're not actually applying the rules at the moment to this particular grid. So we're going to ask you to clear the grid to start with. Go ahead and put a single block out there in the middle. Well, you should already know by the rules what's going to happen to this single block. If I apply the rules, the single block should die of loneliness. It's step. When you do so, the block goes away. Well, try this. Let's put two blocks in place. What do you think is going to happen with those two blocks? Well, if you look at the block in the top, it's going to do what? It only has one neighbor, so it's going to die of loneliness. What about the block at the bottom? It only has one neighbor. It's going to die of loneliness. Let's hit step, and now I have nothing on the screen again. What happens if I hit step again? Step, step, step. Well, none of them are spontaneously born once they're gone, but do you remember what this condition is called? That we're each step. Looks just like the step before it. That would be what we would call steady state. Our state remains the same, no matter what. Let's try another setup. Let's put three of these little cells next to each other. Now think about this. What's going to happen here? What's going to happen in this kid's situation? Think what's going to happen when you hit step? See if you can figure it out. Let's go ahead and see what happens when I hit step. That makes sense. This upper right-hand corner had exactly three neighbors, which is the condition for being born, and now I have four of these live units. What's going to happen next? Predict, and when you're ready, we'll hit step. Nothing much happened. Step. Nothing happened. Step. It looks like I'm maintaining the same state each time. Oops, we meant something happened there. Some of them turned a lighter shade of blue, and then when I hit the next one, the next one turned that shade of blue. This is an option to the game of life. It's just to give you an idea that there is some level of change there, that after each cell has been around for a long time, it'll change a slightly darker color to give us an indication of which cells may be older than other cells. If you click step multiple times, eventually it'll turn more of a shade of purple, and eventually it'll turn entirely blue. Those are to indicate our older cells. However, if we ignore that color change, what we can see is that we have also reached a condition of steady state, and this is a stable quote-unquote population that once we reach this box of four, we end up with a box of four that stays around forever. Let's try something else here. Hit clear. And let's go ahead and put three of them in a row like this. If you need to hit pause and think about what you think will happen when we do a step with this population. All right, let's take a look. Step. Notice it changed our configuration a little bit. What if I hit step again? Step. Step. Step. Step. It seems like I'm falling into a bit of a pattern here. Oops, there's that one in the middle. The one in the middle is not changing. It seems to be getting older, but the ones on the sides are. I'm going to go ahead and hit start. What start does is it's going to run each iteration and do them over and over and over again. And what we can see is this seems to go blinking back and forth between the vertical orientation and the horizontal orientation with each step. Let's talk about some of the patterns that we're beginning to see. So we saw a steady state pattern where we had this square. And we saw a pattern that went back and forth in a cycle. We're going to call that a cyclic pattern, C-Y-C-L-I-C, a cyclic pattern. And that pattern has a period, a period being the length of time from when it goes from one state to another state and then returns to itself. In this case, the cyclic pattern has a period of two. One step, two steps, and I'm back where I came from where I started. One step, two steps, and I'm back where I started. So the pattern down here is a steady state pattern, basically cyclic with a period of one, what we call that steady state. And up here, we have a pattern that's cyclic with a period of two. So what other patterns are there? What else can you find? What happens if I build something like this? What do you think is going to happen? This looks like it's getting old. Turning blue must be that I've discovered another steady state pattern. What happens if I just add a single block to that population? Does that change something? Looks like it does. Well, it changes for a little bit and then it appears to achieve steady state. If you remember, the term for that is called transient behavior. For those few steps, if I can return it to when we were in this state, the few steps where it was changing, there's a changing step, there's a changing step or it changed, but now we noticed after that it's the same. Well, once it's achieved the point where it's reached steady state, it's no longer transient. But that time in between, when it's trying to, when it's changing until it reaches some sort of transient, let's see what happens if we do this. Uh-oh, now we have something that's changing pretty substantially. And when it gets big enough, it starts reaching the boundaries and then the boundaries start interacting with each other. And let me go ahead and hit start and see what sort of happens. Oh, eventually it reached steady state that all the other things died out and we reached a steady state. Meanwhile, all those other changes were again what we call transient behavior. So what patterns do we see? Steady state patterns, something that stays the same all the time. Go patterns with a certain period of two. Well, what would a period of three be? A period of three would be something that starts, then goes into another condition, then a third condition, and then back to the first one. We'll have to look and see if we can find something like that. Growing, well, the pattern we had there toward the end started was small and it got bigger and bigger and bigger, but eventually it collapsed and it went into steady state. Now that had a lot to do with the fact that we had our boundary conditions, but if we had a bigger screen, perhaps it would have kept growing. It did look like it was getting bigger with each step until it reached the boundaries. Let's take a look at a really interesting one and probably one of the ones that leads to this idea of the game of life. Here's a particularly interesting pattern. Feel free to recreate it if you would like. So let's take a look at what happens when we do a single iteration or a step with this pattern. Okay, so with chain, let's do another step. Changed again. It looks a little familiar. Here's a third step and here's a fourth step. Now, if you look carefully, you'll notice that this fourth step looked pretty much like the first step we started with. However, it's located in another location. Watch what I do again. I'm going to go through four steps and look at this pattern, look at it carefully and then we'll look in four steps. Let's see if we can see it again. One, two, three, four. And there's the same pattern, but this time this pattern has moved. In some ways, this pattern is almost cyclic with a period of four because it took us four steps to repeat what it looks like. However, it also shifted in its location. It's no longer in the same place. Now watch what happens when I hit start. Notice my little pattern looks like a little moving creature. This pattern is actually known as a glider in the game of life and it's one of the ideas that gives the game of life its name, that with this simple set of rules we're creating something that appears to be moving.