![]() There's some cell structures that are worth mentioning. (Because of the size of the canvas and the non-responsive nature of the example, I recommend running it in 0.5 scale) addEventListener ( ' click ', () => )Įnter fullscreen mode Exit fullscreen modeĪnd here's a codepen where you can play around with it: I will create the field as a nested array of 100 by 100 boolean variables:ĭocument. When you connect those sides, the shape will actually look like a donut. Whatever leaves either side will reenter on the opposite side. When the field is shaped like a donut, it behaves like this: There's two possibilities: Either we consider the border as always dead (they are neighbors, but the rules are never applied to them) or the world is actually formed like a donut. Meaning: If the game sets cell 1 as "alive" that was dead before and starts applying the rules to its immediate neighbor cell 2, it should not consider the new state of cell 1 (alive) but the old one (dead) for the calculation of cell 2.īut this begs a question: What does it do at the border of the field? One thing is important, though: The next generation needs to be calculated all at once. In the following picture, we can see how it could look like if a cell is being born: The filled cell in the middle is alive in this generation, but dies the next generation. Here we can see what happens if less than 2 neighboring cells are alive. All other cells are the center cell's neighbors. We're going to see how the rules work by applying them to the center cell. (These rules allow for some pretty complex structures, but we'll come to that later!)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |