Kreechers: Cellular Automata Playground
It's life *John, but not as we know it
"So," you may be asking, "what's all this then, just another version of *John Conway's Life?". An understandable question, but the answer is no, it's actually something quite different and new, and also sort of yes, in that it's all about ones and zeros in a binary 2D world, so it may remind you of the original Life program from 1970.
To understand the difference between Kreechers and the Game of Life, and to explain what's going on, let's quickly recap on how the original program works. The idea is that the Game of Life takes place on a two-dimensional world, much like graph paper. In fact, it used to be played on graph paper before programs were written to run it.
Figure 1 |
◻ | ◻ | ◼ |
◼ | ◻ | ◻ |
◻ | ◼ | ◻ |
There are two simple rules to follow, from which a tremendous number of unexpected results can occur. These rules are:
- If a square is empty but exactly three of its neighbors (on the edges and diagonals) are full (see Figure 1), then the square is filled (emulating giving birth).
- If a square is filled, but there are either fewer than two or more than three filled neighboring squares (as in Figure 2) then the square becomes empty, emulating death
There is, as it happens, a sort of third rule, which isn't really a rule because it simply states that if none of the above is true then no change occurs to the square.
Figure 2 |
◼ | ◻ | ◼ |
◼ | ◼ | ◻ |
◼ | ◻ | ◼ |
Each square in turn on the graph paper (or in an array in a computer, which can be as large as you like) is then processed in this way until a sheet is completed. Then the whole process starts all over again at the first square, and continues ad-infinitum.
"Simple enough," you might think, if you've never come across the game before, but the results of carefully placing a few initially filled squares can be staggeringly complex. In fact, it has been proven that The Game of Life is 100% Turing complete, which means that it has the capability to perform any computations that a regular computer can, and there are even configurations of the game which recursively simulate the game itself, thus neatly proving the point!
You can also play the Game of Life in Kreechers (and in color too!) by pressing the button in the panel. After a while you will notice how many configurations wind up with a stable pattern, and others even result in total wipeout. With carefully placed initial cells, however, you can achieve quite interesting results.
Figure 3 |
|
More than that, instead of the standard rules of Life, you can try any of the 2562 other rules too, many of which create stunning mosaics, crystalline shapes and colonies, as shown in Figure 3.
Incidentally, the colors (which you don't often see in the Game of Life) were chosen to slowly cycle according to how old the particles are, starting over again if a particle dies and is replaced by a new one.
How Kreechers Works
Under the hood
The main thing about Kreechers is that there is no birth or death, and therefore the total number of filled locations always remains the same, unless you add or remove any using the mouse or buttons provided. Instead, movement and change occur by swapping the contents of locations according to sets of rules.
So let's start off with the same piece of graph paper used for Life, but then choose any sized matrix from 1×1 to 9×9. The mathematics allows for any sized matrix, but for reasons of practicality and the speed of current computers, 9 has been chosen as the maximum for this program.
Figure 4 |
◻ | ◻ |
◼ | ◻ |
Now, pass the matrix across the graph paper one positon at a time and apply a set of swap rules based on whether or not a cell under the matrix is filled. Let's take the case of using a 2×2 matrix to process the graph paper. As shown in Figure 4, there are four locations to examine. For each cell in the matrix a swap rule is applied if the square under the cell is filled. In the case of this figure, only the bottom-left location is filled.
In a 2×2 matrix there are 7 possible swap rules that can be applied, which are:
- Don't do anything
- Swap Top-Left and Top-Right
- Swap Top-Left and Bottom Left
- Swap Top-Left and Bottom-Right
- Swap Top-Right and Bottom-Left
- Swap Top-Right and Bottom-Right
- Swap Bottom-Left and Bottom-Right
Looking at the program running at the top of this page, you can see such a 2×2 matrix at the top-left of the window, and in it there are some filled and empty squares. The filled squares represent the swaps to be made if a cell under one of the four positions is filled. If only a single cell is shown in the matrix then the location is swapped with itself, which means nothing happens and this is how swap rule 1, "Don't do anything", works.
So, in the case of the default 2×2 rules, when this page first loads the rule matrix looks like Figure 5. Taking the data from Figure 4 of just the single bottom-left location being filled, we then look at the rule matrix and see that the bottom-left rule is to swap the top-left and bottom-right locations.
Figure 6 |
◼ | ◻ |
◼ | ◻ |
In this particular case, however, the swap will have no effect because the top-left and bottom-right locations are both the same (empty), and so there will be no noticable change (in fact the program knows this and just does nothing). However, should Figure 5 contain locations in the configuration of Figure 6, in which the top-left location is also filled, then the swap rule would end up making Figure 6 look like Figure 7, once the swap has been performed.
Figure 7 |
◻ | ◻ |
◼ | ◼ |
So, unlike Life, in which the two rules are fixed, in Kreechers the rules depend on which locations are already filled and, by swapping them around, the rules to be applied constantly change. More than that, you can choose between the seven different rules for each cell position in a 2×2 matrix, giving you 7×7×7×7 (74), or a total of 2,401 different possible combinations of rules. So already there are over a couple of thousand variations of the 2×2 version of Kreechers, which makes for some very interesting and varied results.
But this is just the beginning, because you can extend the size of the rule matrix in a multitude of different ways to get even more results and, if you choose a 9×9 matrix, for example, there are more than 10284 possible combinations – several orders of magitude greater than the total number of atoms in the Universe!
But wait, there's more!
Not only, but also...
With matrixes larger than 2×2 the rules allow for swapping any of the cells under the matrix (not just a 2×2 section), even up to 81 of them under a 9×9 matrix. There is, however, an issue when the matrix gets large, in that due to the enormous number of possible rule sets, huge numbers of them are (to us) quite uninteresting and resemble chaos. They are not chaotic, in fact, but are just too complex for us to visually take in.
So, to help us mortal humans understand the larger matrixes, I have added a switch with which you can limit the action of each of the rules in a matrix to just those swaps supported in a basic 2×2 matrix, as in Figure 8, where you can see the squares representing the locations under the matrix where the rules will be applied are shown in red.
These rules are applied to the four cells nearest to the center (of course it could have been any set of four cells, so I just opted for the middle), underneath the matrix. Even then, with a 9×9 matrix you still have more than 1068 possible combinations (perhaps just shy of the number of atoms in the Universe), but many, many more of them show some sort of pattern or behaviour we can understand.
Figure 9 |
|
To get started with this program, perhaps you may wish to click the [Apply Next Preset] button (or press 'A') now and then, and watch the results of simply writing the word 'Kreechers' into the world's empty locations. Note that the presets load into the current zoom level, so you will see different results depending on how far you are zoomed in or out. You will soon see many types of gliders and flyers (as in Figure 9), complex line crawlers (see Figure 10), and much more.
For example, try zooming in and out, as well as changing the matrix sizes, and turn on the mutation feature to automatically make one rule change in a rule set every 15 seconds (be patient though, some changes are very subtle). When mutation is on, the top-left matrix will highlight the most recent rule change.
You can directly change single rules in a matrix by clicking (and double-clicking) the cells to be changed, and you can also draw on the world with the mouse to fill empty locations with particles. This can be easier to do if you pause animation first. For even better precision, draw in Edit Mode, which pauses animation for you and also stabilises the panning window (unless [Shift] is held down, in which case you can pan to wherever you wish to edit). Right-clicking on any of the draw functions erases instead of drawing. Pausing and stepping will reveal much about the current rule set.
Figure 10 |
|
The colors shown are assigned according to how many times a parti has had its location swapped during each frame scan. Interestingly this displays a lot of patterning and also regularity too. Looking at even the very first preset using this colorization, I get the feeling that very many matrix sizes and rule sets are Turing complete, and it should be possible to create complex and fanciful computations (starting with simple logic gates and moving up) much more quickly and easily than with Life. To this end I will shortly release a Pattern Editor - watch this space.
If you create anything with this or develop it further, please accredit my work when you do so, thanks! And feel free to brainstorm with me at robin@robinnixon.com. Here is the Github Repository.
Designed for Desktop Computers. Initial
Public Release: v0.82 January 26th 2021
Kreechers © 2021 Robin Nixon - Quick Reference Guide
General Keyboard Commands
- A - Apply the next preselected world + rules
- C - Clear the world
- D - Hide/show the info Display
- F - Draw a random Filled rectangle
- G - Hide or show the Guide window
- H - Toggle between Hard & soft borders
- K - Copy world + rules to the Keyboard buffer
- L - Draw a random Line
- N - Choose a New set of random rules
- O - Draw a random Open rectangle
- P - Pause or restart animation
- S - When pausing Step one frame
- T - Toggle between color & monochrome
- W - Write 'kreechers' on the world
- < > - Increase or decrease resolution
General Mouse Actions
- Mouse move - Relocate the cursor
- Scroll wheel - Zoom in and out
- Left click - Create a particle - Enters temporary Edit Mode
- Right click - Delete a particle - Enters temporary Edit Mode
Keyboard + Mouse Buttons
- Ctrl + Left - Draw a line
- Ctrl + Right - Draw an open rectangle
- Ctrl + Both - Draw a filled rectangle
- Alt + Left - Create a rectangular selection
- Alt + Right - Create a square selection
- Shift + Left - Enter Edit mode
Edit Mode Controls
- Shift + Mouse + Wheel - Pan & zoom
- Esc - Exit Edit Mode
- All other editing commands apply
Keyboard Selection Commands
- Alt + B - Pop up the clipBoard window
- Alt + F - Flip the selection top to bottom
- Alt + M - Mirror the selection left to right
- Alt + R - Rotate the selection 90° with scaling
- Ctrl + C - Copy the selection
- Ctrl + X - Cut the selection
- Ctrl + V - Paste the selection at the mouse pointer
Clipboard Viewer
- Left click - Toggle cell values
- Esc - Exit Clipboard viewer
Nixon's Kreechers
- E - Enable or disable multiple passes
- M - Toggle Mutations every 15 seconds
- T - Track fast-moving, invisible particles
- U - Use rules on only a 2 × 2 section
- 1-9 - Select the number of rule columns
- Shift + 1-9 - Select the number of rule rows
Conway's Game of Life Variations
- Green Checkboxes - Neighbors needed for creation
- Red Checkboxes - Neighbors needed for deletion
- [ ] - Select the previous or next rule
- V - Change the Vertical offset
Currently suitable only for desk and laptop computers