3-color totalistic cellular automata in golly

For discussion directly related to ConwayLife.com, such as requesting changes to how the forums or home page function.
Post Reply
azim58
Posts: 2
Joined: February 21st, 2014, 12:28 pm

3-color totalistic cellular automata in golly

Post by azim58 » February 21st, 2014, 12:33 pm

How can I make a 3-color totalistic cellular automata in golly? For example there are lots of pictures of such cellular automata found here: http://www.wolframscience.com/downloads ... mages.html. For example the cellular automata from code 1635, code 1815, code 2007, and code 1659 are the types of cellular automata that I want to make. Thanks for any help and information you have to offer me!

User avatar
dvgrn
Moderator
Posts: 10613
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: 3-color totalistic cellular automata in golly

Post by dvgrn » February 21st, 2014, 5:46 pm

azim58 wrote:How can I make a 3-color totalistic cellular automata in golly? For example there are lots of pictures of such cellular automata found here: http://www.wolframscience.com/downloads ... mages.html. For example the cellular automata from code 1635, code 1815, code 2007, and code 1659 are the types of cellular automata that I want to make. Thanks for any help and information you have to offer me!
As far as I know, no one has written a generalized rule-generator script for Wolfram's enumeration of 3-state totalistic CAs. Golly only natively supports even-numbered "elementary" 1-dimensional CA (with Wolfram numbers up to 255).

The standard way to trick Golly into supporting a new set of rules is to write a Python script that takes the rule specification as input. In this case the script would accept an integer and interpret it as Wolfram numbering for a 3-state totalistic CA.

You end up with a new .rule file for every number you run through the script, but otherwise this is a reasonably workable system. See Golly's Scripts/Python/RuleGenerators for examples.

There are only a few thousand (3^7) 1D 3-state totalistic rules, and the rule files are fairly trivial to generate. Here's a sample:

Rule table for 3-state totalistic CA, Wolfram rule #2007 --
copy to clipboard and choose File > Open Clipboard in Golly 2.4+

Code: Select all

@RULE W2007T_k=3

Wolfram 3-state totalistic rule code 2007
A sample 3-state 1D CA using Wolfram's numbering system

@TABLE

n_states:3
neighborhood:Moore
symmetries:reflect_horizontal

var n={0,1,2}

# Change just the numbers on the far right to adjust the Wolfram code.
# For a Wolfram totalistic 3-color CA, all the output state numbers under each
#  sum must be the same.  E.g., for code 2007, the numbers are 0, 0, 1, 2, 0, 2, 2.
#
# 2007 = 0*3^0 + 0*3^1 + 1*3^2 + 2*3^3 + 0*3^4 + 2*3^5 + 2*3^6.
# See  http://www.wolframalpha.com/input/?i=3-color+code+2007
#
# To extend this to more colors, it would be necessary to list all possible partitions of
#  each sum into integers [0..k], as has been done here for k=3.  A few combinations
#  were left out because they were horizontal reflections of listed combinations.

# sum=0
0,0,0,n,n,n,n,n,0,0

# sum=1
0,0,1,n,n,n,n,n,0,0
0,1,0,n,n,n,n,n,0,0

# sum=2
0,0,1,n,n,n,n,n,1,1
0,0,2,n,n,n,n,n,0,1
0,1,1,n,n,n,n,n,0,1
0,2,0,n,n,n,n,n,0,1

# sum=3
0,0,1,n,n,n,n,n,2,2
0,0,2,n,n,n,n,n,1,2
0,1,1,n,n,n,n,n,1,2
0,1,2,n,n,n,n,n,0,2
0,2,1,n,n,n,n,n,0,2

# sum=4
0,0,2,n,n,n,n,n,2,0
0,1,1,n,n,n,n,n,2,0
0,2,0,n,n,n,n,n,2,0
0,2,1,n,n,n,n,n,1,0

# sum=5
0,1,2,n,n,n,n,n,2,2
0,2,1,n,n,n,n,n,2,2

# sum=6
0,2,2,n,n,n,n,n,2,2

@COLORS
0   0   0   0
1   0 128 255   light blue
2 255 128   0   orange
As with Golly's support for Wolfram codes for elementary CA, the transition table assumes a starting state all on a single line; child states appear on successive lines. Really everything is happening on a two-dimensional grid -- but as you might expect, you'll get strange results if you start with a multi-line pattern, or if you go "back in time" and edit anything above the bottom line. No warranty express or implied, etc., etc.

A simple Python script could easily decode an input Wolfram number for any 3-state totalistic CA, and write out a very similar rule table. The only difference would be that the rightmost numbers under each "# sum=n" section would change to the appropriate base-3 digit.

A slightly bigger challenge would be a generalized script that could also handle four colors or more. It would probably just list all the possible partitions of each sum, without worrying about reflections... As you can see, rule-table format is not really designed to handle this type of totalistic rule -- but for a reasonable number of colors, a script could generate the correct rule table fairly easily.

[...I'm hoping that Golly doesn't have some much simpler way of doing this, that I'm forgetting all about!]

User avatar
dvgrn
Moderator
Posts: 10613
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: 3-color totalistic cellular automata in golly

Post by dvgrn » February 21st, 2014, 10:53 pm

dvgrn wrote:[...I'm hoping that Golly doesn't have some much simpler way of doing this, that I'm forgetting all about!]
The main thing that I was worried about was the "oneDimensional" neighborhood that Golly supports; I couldn't get it to work at first. Turned out the problem was between my keyboard and my chair -- I was listing the center state twice in each rule line.

The key difference is that the "oneDimensional" neighborhood really is one-dimensional -- all the action happens in a single line, instead of moving progressively down the screen. The Y dimension isn't used to show the progression of time; cells in different rows have no effect on each other, so you can run a different experiment in each horizontal row of cells.

On the other hand, you just see a single line for each experiment instead of a nice New Kind of Science-y picture of the evolution of the rule.

Code: Select all

@RULE W2007T_1dim_k=3

Wolfram 3-state totalistic rule 2007,
  using Golly's "oneDimensional" neighborhood.
  All evolution occurs in a single line, instead of
  future generations appearing below older generations
  as in the previously posted W2007T_k=3 rule.

@TABLE

# sample totalistic 3-color Wolfram rule
n_states:3
neighborhood:oneDimensional
symmetries:reflect

# sum=0
0,0,0,0

# sum=1
0,0,1,0
1,0,0,0

# sum=2
0,1,1,1
1,0,1,1
0,0,2,1
2,0,0,1

# sum=3
0,1,2,2
1,0,2,2
2,0,1,2
1,1,1,2

# sum=4
0,2,2,0
2,0,2,0
1,1,2,0
2,1,1,0

# sum=5
1,2,2,2
2,1,2,2

# sum=6
2,2,2,2

@COLORS
0   0   0   0
1   0 128 255   light blue
2 255 128   0   orange
You can get a surprising-but-not-really effect by running the W2007T_k=3 rule on a starting pattern for a while, then switching to W2007T_1dim_k=3.

azim58
Posts: 2
Joined: February 21st, 2014, 12:28 pm

Re: 3-color totalistic cellular automata in golly

Post by azim58 » February 26th, 2014, 9:53 pm

Absolutely awesome!!! That is exactly what I wanted. Thank you so much for your post and the code.

Yoel
Posts: 384
Joined: July 2nd, 2020, 1:02 am
Location: Electronic jungle
Contact:

Re: 3-color totalistic cellular automata in golly

Post by Yoel » November 16th, 2020, 12:28 am

Here are templates that I use for 2-color and 3-color cyclical symmetrical 1D CA. I mean, one (black) dead state plus 2 or 3 colorful live states.

For 2 colors it means that toggling all cells to the opposite live color never changes the behavior of any pattern. For 3 colors it means that shifting all cells cyclically (red->green; green->blue;blue->red) never changes the behavior of any pattern. This is different from totalistic, but more consistent in a way, since all live states are completely equal.

I didn't bother to write a script for producing such rules, because these templates can be easily tweaked by hand. 3-color rules include all 2-color rules as a subset, and 2-color rules include Wolfram's rule 54, which is suspected to be Turing-complete. Note that for 2 colors 102 can not give birth (it would break the symmetry).

Code: Select all

@RULE 1D-RB

# Template for 2-color one-dimentional cellular automata

# Copyright by Yoel Matveyev, 2020
# The GNU General Public License v3.0

@COLORS

0 0 0 0
1 255 0 0
2 0 0 255

@TABLE

n_states:3
neighborhood:Moore
symmetries:reflect_horizontal

# Birth

# 001

0,0,1,0,0,0,0,0,0,0
0,0,2,0,0,0,0,0,0,0

# 101

0,0,1,0,0,0,0,0,1,0
0,0,2,0,0,0,0,0,2,0

# Survival

# 010

0,1,0,0,0,0,0,0,0,0
0,2,0,0,0,0,0,0,0,0

# 011

0,1,1,0,0,0,0,0,0,0
0,2,2,0,0,0,0,0,0,0

# 012

0,1,2,0,0,0,0,0,0,0
0,2,1,0,0,0,0,0,0,0

# 111

0,1,1,0,0,0,0,0,1,0
0,2,2,0,0,0,0,0,2,0

# 112

0,1,2,0,0,0,0,0,1,0
0,2,1,0,0,0,0,0,2,0

# 212

0,1,2,0,0,0,0,0,2,0
0,2,1,0,0,0,0,0,1,0

Code: Select all

@RULE 1D-RGB

# Template for 3-color one-dimentional cellular automata

# Copyright by Yoel Matveyev, 2020
# The GNU General Public License v3.0

@COLORS

0 0 0 0
1 255 0 0
2 0 255 0
3 0 0 255

@TABLE

n_states:4
neighborhood:Moore
symmetries:reflect_horizontal

# Birth

# 001

0,0,1,0,0,0,0,0,0,0
0,0,2,0,0,0,0,0,0,0
0,0,3,0,0,0,0,0,0,0

# 101

0,0,1,0,0,0,0,0,1,0
0,0,2,0,0,0,0,0,2,0
0,0,3,0,0,0,0,0,3,0

# 102

0,0,1,0,0,0,0,0,2,0
0,0,2,0,0,0,0,0,3,0
0,0,3,0,0,0,0,0,1,0

# Survival

# 010

0,1,0,0,0,0,0,0,0,0
0,2,0,0,0,0,0,0,0,0
0,3,0,0,0,0,0,0,0,0

# 011

0,1,1,0,0,0,0,0,0,0
0,2,2,0,0,0,0,0,0,0
0,3,3,0,0,0,0,0,0,0

# 012

0,1,2,0,0,0,0,0,0,0
0,2,3,0,0,0,0,0,0,0
0,3,1,0,0,0,0,0,0,0

# 013

0,1,3,0,0,0,0,0,0,0
0,2,1,0,0,0,0,0,0,0
0,3,2,0,0,0,0,0,0,0

# 111

0,1,1,0,0,0,0,0,1,0
0,2,2,0,0,0,0,0,2,0
0,3,3,0,0,0,0,0,3,0

# 112

0,1,2,0,0,0,0,0,1,0
0,2,3,0,0,0,0,0,2,0
0,3,1,0,0,0,0,0,3,0

# 113

0,1,3,0,0,0,0,0,1,0
0,2,1,0,0,0,0,0,2,0
0,3,2,0,0,0,0,0,3,0

# 212

0,1,2,0,0,0,0,0,2,0
0,2,3,0,0,0,0,0,3,0
0,3,1,0,0,0,0,0,1,0

# 213

0,1,3,0,0,0,0,0,2,0
0,2,1,0,0,0,0,0,3,0
0,3,2,0,0,0,0,0,1,0

# 313

0,1,3,0,0,0,0,0,3,0
0,2,1,0,0,0,0,0,1,0
0,3,2,0,0,0,0,0,2,0
Altogether, there are 5832 2-color rules and 66060288 3-color rules, not counting trivial rules without birth.

Note that rules with 001->0 are unlikely to be interesting. They tend to die fast even when running on an infinite/cylinder tiling.

Here is also a template for symmetrical 2-color extensions of Rule 110 (243 possible extensions, some of which are trivial and uninteresting):

Code: Select all

@RULE W110-RB

# Template for 2-color extensions of Rule 110

# Copyright by Yoel Matveyev, 2020
# The GNU General Public License v3.0

@COLORS

0 0 0 0
1 255 0 0
2 0 0 255

@TABLE

n_states:3
neighborhood:Moore
symmetries:none

0,0,1,0,0,0,0,0,0,1
0,1,0,0,0,0,0,0,0,1
0,1,1,0,0,0,0,0,0,1
0,0,1,0,0,0,0,0,1,1
0,1,0,0,0,0,0,0,1,1

0,0,0,0,0,0,0,0,2,2
0,2,0,0,0,0,0,0,0,2
0,2,0,0,0,0,0,0,2,2
0,0,2,0,0,0,0,0,2,2
0,2,2,0,0,0,0,0,0,2

# 012

0,1,2,0,0,0,0,0,0,1
0,2,0,0,0,0,0,0,1,2

# 021

0,2,1,0,0,0,0,0,0,1
0,1,0,0,0,0,0,0,2,2

# 112

0,1,2,0,0,0,0,0,1,2
0,2,1,0,0,0,0,0,2,1

# 211

0,1,1,0,0,0,0,0,2,1
0,2,2,0,0,0,0,0,1,2

# 121

0,1,2,0,0,0,0,0,2,1
0,2,1,0,0,0,0,0,1,2
Enjoy!

EDIT: I didn't know that there is a built-in option for 1D neighborhood in Golly tables. I'm not going to rewrite these tables, because 1D CA are anyhow emulated by non-symmetrical 2D.

Post Reply