For example:
Code: Select all
1 1 1
0 0 1
0 0 0
Code: Select all
1 2 1
0 1 0
0 0 0
Code: Select all
1 1 1
0 2 0
0 0 0
To discard ambiguity, the n state cells can be born only from a n-1 state cell, and so on...
The notation I thought for this rulespace is the following:
Code: Select all
b3;2s23;2
I also wrote a python script that writes these ruletables, it's limited to two states, but I will generalize it in the future:
Code: Select all
#RuleTable writer
#23/08/12
#@hektor41
import golly as g
rule = g.getstring("Insert the rule","b3;3s23;23")
#Clean the file if already existing and then open it in append mode
open("/Applications/golly-2.4/Rules/{0}.table".format(rule), "w").write("")
table = open("/Applications/golly-2.4/Rules/{0}.table".format(rule), "a")
#Write the header
table.write("n_states:3\nneighborhood:Moore\nsymmetries:permute\n#Script-generated Ruletable\n")
ennad = "012345678"
survs = []
borns = []
death = []
def rule_format():
#Formats the born/survival rule for each state
bornrule = rule[1:rule.index("s")]
survrule = rule[rule.index("s")+1:len(rule)]
bidx = 0
sidx = 0
for br in xrange(0,len(bornrule)):
if bornrule[br] == ";":
borns.append(bornrule[bidx:br])
bidx += len(bornrule[bidx:br])+1
borns.append(bornrule[bidx:len(bornrule)])
for sr in xrange(0,len(survrule)):
if survrule[sr] == ";":
survs.append(survrule[sidx:sr])
sidx += len(survrule[sidx:sr])+1
survs.append(survrule[sidx:len(survrule)])
def death_format():
#Same but with death
for sr in xrange(0,len(survs)):
deathrule = ""
for x in xrange(0,len(ennad)):
if ennad[x] not in survs[sr]:
deathrule += ennad[x]
death.append(deathrule)
def createTransitions(total,start,final):
sub = []
for i in xrange(0,len(total)):
now = int(total[i])
if start > 1: # If the value of the central cell is > 1 then emulate an added neighbour by decreasing the total
now -= 1
s = "{0},{1}{2}{3}\n".format(start,"1,"*now,"0,"*(8-now),final) # Initially fills the string with 1*total
count = (s[1:].count("1,") + s[1:].count("2,")*2) # This is specific for TWO state automata!
while count == now:
if s not in sub:
sub.append(s)
s = s[0]+s[1:].replace("1,1,","2,0,",1) # Replace every occurrence of 1,1, with 2,0, // This is also specific and not general
count = (s[1:].count("1,") + s[1:].count("2,")*2) # Update the count
else:
break
return sub
#---------
rule_format()
death_format()
table.write("\n\n\n#Borns\n")
for bi in xrange(0,len(borns)):
for bx in createTransitions(borns[bi],bi,bi+1):
table.write(bx)
table.write("\n#Survs\n")
for si in xrange(0,len(survs)):
for sx in createTransitions(survs[si],si+1,si+1):
table.write(sx)
table.write("\n#Dies\n")
for di in xrange(0,len(death)):
for dx in createTransitions(death[di],di+1,0):
table.write(dx)
table.flush()
table.close()
g.setalgo("RuleTable")
g.setrule(rule)