gmc_nxtman wrote:...is there a way to convert any life-like cellular automaton rulestring to a .table format? I think there might be python script for this but I'm not sure.
It wouldn't be terribly difficult to write a generalized table-generating Python script. Here's a sample of the kind of output the script would generate:
Code: Select all
@RULE B3678_S34678
Sample conversion of a Life-like rule (Day and Night) to table format
(As usual, just copy all this text, then in Golly choose File > Open Clipboard.)
state 0: OFF
state 1: ON
@TABLE
n_states:2
neighborhood:Moore
symmetries:permute
var a={0,1}
var b={0,1}
var c={0,1}
var d={0,1}
var e={0,1}
var f={0,1}
var g={0,1}
var h={0,1}
var i={0,1}
# 3-neighbor birth
0,1,1,1,0,0,0,0,0,1
# 6-neighbor birth
0,1,1,1,1,1,1,0,0,1
# 7-neighbor birth
0,1,1,1,1,1,1,1,0,1
# 8-neighbor birth
0,1,1,1,1,1,1,1,1,1
# 3-neighbor survival
1,1,1,1,0,0,0,0,0,1
# 4-neighbor survival
1,1,1,1,1,0,0,0,0,1
# 6-neighbor survival
1,1,1,1,1,1,1,0,0,1
# 7-neighbor survival
1,1,1,1,1,1,1,1,0,1
# 8-neighbor survival
1,1,1,1,1,1,1,1,1,1
# all other cells die
a,b,c,d,e,f,g,h,i,0
@COLORS
1 216 255 216
@ICONS
XPM
/* width height num_colors chars_per_pixel */
"31 31 5 1"
/* colors */
". c #000000"
"B c #404040"
"C c #808080"
"D c #C0C0C0"
"E c #FFFFFF"
/* icon for state 1 */
"..............................."
"..............................."
"..........BCDEEEEEDCB.........."
".........CEEEEEEEEEEEC........."
".......BEEEEEEEEEEEEEEEB......."
"......DEEEEEEEEEEEEEEEEED......"
".....DEEEEEEEEEEEEEEEEEEED....."
"....BEEEEEEEEEEEEEEEEEEEEEB...."
"....EEEEEEEEEEEEEEEEEEEEEEE...."
"...CEEEEEEEEEEEEEEEEEEEEEEEC..."
"..BEEEEEEEEEEEEEEEEEEEEEEEEEB.."
"..CEEEEEEEEEEEEEEEEEEEEEEEEEC.."
"..DEEEEEEEEEEE...EEEEEEEEEEED.."
"..EEEEEEEEEEE.....EEEEEEEEEEE.."
"..EEEEEEEEEE.......EEEEEEEEEE.."
"..EEEEEEEEEE.......EEEEEEEEEE.."
"..EEEEEEEEEE.......EEEEEEEEEE.."
"..EEEEEEEEEEE.....EEEEEEEEEEE.."
"..DEEEEEEEEEEE...EEEEEEEEEEED.."
"..CEEEEEEEEEEEEEEEEEEEEEEEEEC.."
"..BEEEEEEEEEEEEEEEEEEEEEEEEEB.."
"...CEEEEEEEEEEEEEEEEEEEEEEEC..."
"....EEEEEEEEEEEEEEEEEEEEEEE...."
"....BEEEEEEEEEEEEEEEEEEEEEB...."
".....DEEEEEEEEEEEEEEEEEEED....."
"......DEEEEEEEEEEEEEEEEED......"
".......BEEEEEEEEEEEEEEEB......."
".........CEEEEEEEEEEEC........."
"..........BCDEEEEEDCB.........."
"..............................."
"..............................."
XPM
/* width height num_colors chars_per_pixel */
"15 15 5 1"
/* colors */
". c #000000"
"B c #404040"
"C c #808080"
"D c #C0C0C0"
"E c #FFFFFF"
/* icon for state 1 */
"..............."
"....BDEEEDB...."
"...DEEEEEEED..."
"..DEEEEEEEEED.."
".BEEEEEEEEEEEB."
".DEEEEEEEEEEED."
".EEEEE...EEEEE."
".EEEEE...EEEEE."
".EEEEE...EEEEE."
".DEEEEEEEEEEED."
".BEEEEEEEEEEEB."
"..DEEEEEEEEED.."
"...DEEEEEEED..."
"....BDEEEDB...."
"..............."
XPM
/* width height num_colors chars_per_pixel */
"7 7 6 1"
/* colors */
". c #000000"
"B c #404040"
"C c #808080"
"D c #C0C0C0"
"E c #FFFFFF"
"F c #E0E0E0"
/* icon for state 1 */
".BFEFB."
"BEEEEEB"
"FEE.EEF"
"EE...EE"
"FEE.EEF"
"BEEEEEB"
".BFEFB."
Obviously this definition could be rewritten more cleverly with a shorter table. For example, the whole Day and Night table above could be rewritten like this:
Code: Select all
# 3-, 6-, 7-, and 8-neighbor birth and survival
a,1,1,1,0,0,0,0,0,1
a,1,1,1,1,1,1,0,0,1
a,1,1,1,1,1,1,1,0,1
a,1,1,1,1,1,1,1,1,1
# 4-neighbor survival
1,1,1,1,1,0,0,0,0,1
# all other cells die
a,b,c,d,e,f,g,h,i,0
But slightly different tricks would be needed for different rules, to use variables to group the lines correctly. It would make for a simpler script to go in the other direction.
With a
less clever definition, you don't even need variables, and you can produce a table for any Life-like rule just by changing the last characters in every line in the table to 0 or 1 as appropriate:
Code: Select all
@TABLE
n_states:2
neighborhood:Moore
symmetries:permute
#C OFF cells -- 1 at the end for birth conditions
0,0,0,0,0,0,0,0,0,0
0,1,0,0,0,0,0,0,0,0
0,1,1,0,0,0,0,0,0,0
0,1,1,1,0,0,0,0,0,1
0,1,1,1,1,0,0,0,0,0
0,1,1,1,1,1,0,0,0,0
0,1,1,1,1,1,1,0,0,1
0,1,1,1,1,1,1,1,0,1
0,1,1,1,1,1,1,1,1,1
#C ON cells -- 1 at the end for survival conditions
1,0,0,0,0,0,0,0,0,0
1,1,0,0,0,0,0,0,0,0
1,1,1,0,0,0,0,0,0,0
1,1,1,1,0,0,0,0,0,1
1,1,1,1,1,0,0,0,0,1
1,1,1,1,1,1,0,0,0,0
1,1,1,1,1,1,1,0,0,1
1,1,1,1,1,1,1,1,0,1
1,1,1,1,1,1,1,1,1,1