Regenerating Generations
Posted: April 22nd, 2020, 9:25 pm
I have an idea for a new rulespace called regenerating generations
The rulestring is rgN/lL/bB/sS/rbB1/rsS1 where N is the number of states, B is the birth condition, S is the survival condition, B1 is the second birth condition, S1 is the second survival condition and L is a state number.
For example, rg3/l1/b3/s23/rb4/rs5
Here is how it works:
If cell is dead:
Code to generate rule tree:
I have also found this rule housed in this rulespace that looks alot like CGoL. Rule string is rg3/l1/b3/s2,3/rb3,6/rs5,8
The rulestring is rgN/lL/bB/sS/rbB1/rsS1 where N is the number of states, B is the birth condition, S is the survival condition, B1 is the second birth condition, S1 is the second survival condition and L is a state number.
For example, rg3/l1/b3/s23/rb4/rs5
Here is how it works:
If cell is dead:
- If B is satisfied:
- Cell becomes state L
- else:
- Cell stays dead
- If S is satisfied:
- Cell stays alive
- else:
- Cell becomes Dying 1
- If B1 is satisfied:
- Cell becomes Dying (n - 1) or Alive
- elif S1 is satisfied:
- Cell stays at Dying n
- else:
- Cell becomes Dying (n + 1) or Dead
Code to generate rule tree:
Code: Select all
class GenerateRuleTree:
def __init__(self, numStates, numNeighbors, f):
self.numParams = numNeighbors + 1;
self.world = {}
self.r = []
self.params = [0] * self.numParams
self.nodeSeq = 0
self.numStates = numStates
self.numNeighbors = numNeighbors
self.f = f
self.recur(self.numParams)
self.writeRuleTree()
def getNode(self, n):
if n in self.world:
return self.world[n]
else:
new_node = self.nodeSeq
self.nodeSeq += 1
self.r.append(n)
self.world[n] = new_node
return new_node
def recur(self, at):
if at == 0:
return self.f(self.params)
n = str(at)
for i in range(self.numStates):
self.params[self.numParams - at] = i
n += " " + str(self.recur(at - 1))
return self.getNode(n)
def writeRuleTree(self):
print("num_states=" + str(self.numStates))
print("num_neighbors=" + str(self.numNeighbors))
print("num_nodes=" + str(len(self.r)))
for rule in self.r:
print(rule)
rule_string = "rg3/l1/b3/s2,3/rb3,6/rs5,8"
birth = set([int(x) for x in rule_string.split("/")[2].replace("b", "").split(",")])
survival = set([int(x) for x in rule_string.split("/")[3].replace("s", "").split(",")])
regen_birth = set([int(x) for x in rule_string.split("/")[4].replace("rb", "").split(",")])
regen_survival = set([int(x) for x in rule_string.split("/")[5].replace("rs", "").split(",")])
birth_state = int(rule_string.split("/")[1].replace("l", ""))
def my_transition_function(neighbours):
n = 0
for i in neighbours[:-1]:
if i == 1: n += 1
if neighbours[-1] == 0:
if n in birth:
return birth_state
return 0
elif neighbours[-1] == 1:
if n in survival:
return 1
return 2
else:
if n in regen_birth:
return neighbours[-1] - 1
elif n in regen_survival:
return neighbours[-1]
return (neighbours[-1] + 1) % n_states
n_states = int(rule_string.split("/")[0].replace("rg", ""))
n_neighbors = 8
GenerateRuleTree(n_states, n_neighbors, my_transition_function)
Code: Select all
@RULE Custom-Rule-1
@TREE
num_states=3
num_neighbors=8
num_nodes=40
1 0 2 0
2 0 0 0
1 0 1 0
2 0 2 0
3 1 3 1
1 1 1 1
2 2 5 2
3 3 6 3
4 4 7 4
2 5 0 5
3 6 9 6
4 7 10 7
5 8 11 8
1 0 2 2
2 0 13 0
3 9 14 9
4 10 15 10
5 11 16 11
6 12 17 12
1 0 2 1
2 13 19 13
3 14 20 14
4 15 21 15
5 16 22 16
6 17 23 17
7 18 24 18
2 19 0 19
3 20 26 20
4 21 27 21
5 22 28 22
6 23 29 23
7 24 30 24
8 25 31 25
3 26 14 26
4 27 33 27
5 28 34 28
6 29 35 29
7 30 36 30
8 31 37 31
9 32 38 32