- <simulation name="Life_Extended" author="John Conway adpated by Jack">
- <description>
- <section>This is a simple implementation of the famous Conway's
- Game of Life, extended to add color to longer lived cells. Including
- probability starters from Rietman's Exploiring the Geometry of Nature
Paint some "living" cells on a "dead" background and - enjoy!</section>
- <section caption="Description">This cellular automaton is guided by the
- following rules: A dead cell becomes alive when there are exactly three living
- cells in its neighborhood. A living cell dies if there are less than two or more
- than three cells in its neighborhood which are alive. This version of Conway's
- Game of Life extends the original one by marking what rules were applied at
- certain locations in the universe. When a living cell dies because there are
- less than two living cells in its neighborhood it is marked blue, if it dies
- because there are more than three cells in its neighorhood which are alive it is
- marked green. You can also determine the lifetime of living cells since their
- color changes to red after some time. The cells will change color from White
- to Yellow to Green to Blue to Gray as they "age".</section>
- </description>
- <abstract-cell-type id="living" />
- <cell-type id="Start10" color="90 90 90">
- <mutation cell-type="Alive" probability="0.10">
- <condition cell-type="Start10" />
- </mutation>
- <mutation cell-type="Dead" probability="0.90">
- <condition cell-type="Start10" />
- </mutation>
- </cell-type>
- <cell-type id="Start15" color="85 85 85">
- <mutation cell-type="Alive" probability="0.15">
- <condition cell-type="Start15" />
- </mutation>
- <mutation cell-type="Dead" probability="0.85">
- <condition cell-type="Start15" />
- </mutation>
- </cell-type>
- <cell-type id="Start20" color="80 80 80">
- <mutation cell-type="Alive" probability="0.20">
- <condition cell-type="Start20" />
- </mutation>
- <mutation cell-type="Dead" probability="0.80">
- <condition cell-type="Start20" />
- </mutation>
- </cell-type>
- <cell-type id="Start25" color="75 75 75">
- <mutation cell-type="Alive" probability="0.25">
- <condition cell-type="Start25" />
- </mutation>
- <mutation cell-type="Dead" probability="0.75">
- <condition cell-type="Start25" />
- </mutation>
- </cell-type>
- <cell-type id="Start50" color="50 50 50">
- <mutation cell-type="Alive" probability="0.50">
- <condition cell-type="Start50" />
- </mutation>
- <mutation cell-type="Dead" probability="0.50">
- <condition cell-type="Start50" />
- </mutation>
- </cell-type>
- <cell-type id="Dead" color="0 0 0" active="false">
- <mutation cell-type="Alive">
- <condition cell-type="living" min="3" max="3"/>
- </mutation>
- </cell-type>
- <cell-type id="Alive" color="255 255 255">
- <implementation cell-type="living" />
- <mutation cell-type="Dead">
- <condition cell-type="living" max="1"/>
- </mutation>
- <mutation cell-type="Dead">
- <condition cell-type="living" min="4"/>
- </mutation>
- <mutation cell-type="Young">
- <condition cell-type="living" min="2" max="3" />
- </mutation>
- </cell-type>
- <cell-type id="Young" color="255 255 0">
- <implementation cell-type="living" />
- <mutation cell-type="Dead">
- <condition cell-type="living" max="1"/>
- </mutation>
- <mutation cell-type="Dead">
- <condition cell-type="living" min="4"/>
- </mutation>
- <mutation cell-type="Adult">
- <condition cell-type="living" min="2" max="3" />
- </mutation>
- </cell-type>
- <cell-type id="Adult" color="0 255 0">
- <implementation cell-type="living" />
- <mutation cell-type="Dead">
- <condition cell-type="living" max="1"/>
- </mutation>
- <mutation cell-type="Dead">
- <condition cell-type="living" min="4"/>
- </mutation>
- <mutation cell-type="Mature">
- <condition cell-type="living" min="2" max="3" />
- </mutation>
- </cell-type>
- <cell-type id="Mature" color="0 64 255">
- <implementation cell-type="living" />
- <mutation cell-type="Dead">
- <condition cell-type="living" max="1"/>
- </mutation>
- <mutation cell-type="Dead">
- <condition cell-type="living" min="4"/>
- </mutation>
- <mutation cell-type="Old">
- <condition cell-type="living" min="2" max="3" />
- </mutation>
- </cell-type>
- <cell-type id="Old" color="192 192 192">
- <implementation cell-type="living" />
- <mutation cell-type="Dead">
- <condition cell-type="living" max="1"/>
- </mutation>
- <mutation cell-type="Dead">
- <condition cell-type="living" min="4"/>
- </mutation>
- </cell-type>
- </simulation>
Line 20 is an example of one of the things that makes Cafun a powerful cellular automaton engine. The abstract-cell-type allows many actual cell-types (we'll talk about those below) to behave as a single type. In this case we will have several variants of "living" cells and we want them all to contribute to whether a cell lives or dies in the next generation.
The remainder of the file defines the various cell-types and the rules that control them. The repetitive nature of some of the definitions is required so we can have the each generation progress to the next type. One thing to be aware of, Cafun determines a cell-type by it's color. So don't make two types the same color. The program will define them as the first cell-type with that color definition. I'll describe one example of the three distinct cell-types we have in the file, and then you're on your own.
Line 61-65: Cell-type Dead
The Dead cell type is the background type. In most runs of the simulation the bulk of the cells will be dead. Dead cells will change to Alive cells if they are surrounded by exactly 3 living cells. We'll look at the details of the cell-type elements in the next section on the Alive Cell type.
Lines 66-77 Cell-type Alive
The cell-type definition for the Alive cells is repeated below with explanatory notes.
<cell-type id="Alive" color="255 255 255">
This tag defines the cell-type. The id attribute is how the type will be referred to in the simulation definition. The color is how it will be shown on screen. Reminder, this is how Cafun identifies the type. If you created another cell-type with the same color (R:255 G:255 B:255 or white) it would be identified as Alive.
<implementation cell-type="living" />
This tag shows that this cell-type implements the abstract cell-type "living" and any mutations defined to it.
<mutation cell-type="Dead">
<condition cell-type="living" max="1"/>
</mutation>
The three tags above are a mutation definition. These are the rules that the cell follows. This first mutation and the one below could be moved the "living" abstract cell-type but having them in each cell-type definition allows for modifying the rules for some types of living cells compared to others. The cell-type in the mutation element is what the cell under consideration would become if the conditions are met. In this case the cell will become a Dead cell id it is a living cell with a maximum of 1 neighbor. Since there is no minimum number it is implied that have zero neighbors would also satisfy this rule. So the cell-type in the condition indicates what type of cells in the eight cell neighborhood contribute the the count to satisfy this rule.
<mutation cell-type="Dead">
<condition cell-type="living" min="4"/>
</mutation>
This mutation is the same as the first but for all count values 4 and higher.
<mutation cell-type="Young">
<condition cell-type="living" min="2" max="3" />
</mutation>
This is the "continues to live rule" from the game of life. But in this case we are going to transform the cell into the next "generation" of living cell. This allows us to use color to see where the activity is in the simulation. In this case the cell will become a "Young" cell (color: yellow) if it survives. The progression is Alive(white), Young(yellow), Adult(green), Mature(blue), Old(gray). Stable GoL configurations will eventually turn gray. Oscillators will most often have a gray part and a white part. Gliders are mostly white but some of the cells survive a couple of generations to turn yellow and green.
</cell-type> - This is the closing cell-type tag.
You can define new cell-types with different mutations using this basic pattern. If you find an article that describes a cellular automaton that you wish to try, just code the rules that they give you as mutations.
Line 29-36: A Rietman style probabilistic starter
This particular starter is the 15% starter that allows you to randomly fill the CA world with 15% live cells. There are starters for 10%, 15%, 20%, 25% and 50%. Simply fill with one of these cell types to get your random start. You could also use a large brush and put down areas of each and see what happens. The piece that provides the randomness is in the mutation element:
<mutation cell-type="Alive" probability="0.15">
The probability attribute indicates what the chance is that this mutation will trigger. In this case it is set to 0.15 or 15%. So there is a 15% chance that the cell will change to an Alive cell in the next generation. There is a matching mutation that has an 85% chance to trigger and it would turn the cell to a Dead cell.
So there you have it. Extensions to Conway's Game of Life that make it a little more colorful and easier to randomly seed your starting world. One addition I've considered that would create a distinct change from the Game of Life and add a new dynamic to the simulation is to give the Old cells a chance, say 50%, to convert to a Start50 cell. This would mean that all Old cells, those that had lived at least 5 generations would have a 50 percent chance to be changed into a cell that had a 50 percent chance to die. This would potentially cause certain stable constructs to whither away as one or more cells die off. You are encouraged to try to make that change yourself.
That's it for now. Next time we return to Object Oriented Programming.