The Q2R2vN conserves some value (energy), see python script
viewtopic.php?f=11&t=1293&start=50#p11114
The Brian's Rule 005 also conserves some value, because belongs to rule with side=corner tb3 list.
Below is python script for calculation
Code: Select all
# Calculates energy for corner-side reversible rule
from glife import rect
from time import time
import golly as g
r = rect( g.getselrect() )
if r.empty:
r = rect( g.getrect() )
if r.empty: g.exit("No selection and the pattern is empty.")
r.top = r.top - 1
r.height = r.height + 2
r.left = r.left-1
r.width = r.width + 2
oldsecs = time()
maxstate = g.numstates() - 1
En1 = 0
En2 = 0
sn1 = [-1, 1, -1, 1]
sn2 = [-1,-1, 1, 1]
for row in xrange(r.top, r.top + r.height):
for col in xrange(r.left, r.left + r.width):
cell = g.getcell(col, row)
neib = g.getcell(col-1, row)
En1 = En1 - (1 - sn1[cell]*sn2[neib])
En2 = En2 - (1 - sn2[cell]*sn1[neib])
neib = g.getcell(col, row-1)
En1 = En1 - (1 - sn1[cell]*sn2[neib])
En2 = En2 - (1 - sn2[cell]*sn1[neib])
neib = g.getcell(col-1, row-1)
En1 = En1 + (1 - sn1[cell]*sn2[neib])
En2 = En2 + (1 - sn2[cell]*sn1[neib])
neib = g.getcell(col-1, row+1)
En1 = En1 + (1 - sn1[cell]*sn2[neib])
En2 = En2 + (1 - sn2[cell]*sn1[neib])
g.show("Energies: " + str(En1/2) + "+" + str(En2/2) + "=" + str((En1+En2)/2))
It computes selection or whole pattern, if selection is empty. Selection should include empty cells
on boundary because similarly with Q2R2 energy is due to difference between states of adjacent
cells. Two values is shown by some reason, but conserved the sum.
But, Revtwo CA I just metioned also conserves some value, yet it is a more tricky
Code: Select all
# Calculates energy for Revtwo rule
from glife import rect
from time import time
import golly as g
r = rect( g.getselrect() )
if r.empty:
r = rect( g.getrect() )
if r.empty: g.exit("No selection and the pattern is empty.")
r.top = r.top - 1
r.height = r.height + 2
r.left = r.left-1
r.width = r.width + 2
oldsecs = time()
maxstate = g.numstates() - 1
En = 0
sn1 = [-1, 1, -1, 1]
sn2 = [-1,-1, 1, 1]
for row in xrange(r.top, r.top + r.height):
for col in xrange(r.left, r.left + r.width + 1):
cell = g.getcell(col, row)
En = En + 2*(1 - sn1[cell]*sn2[cell])
neib = g.getcell(col-1, row)
En = En + 2*(1 - sn1[cell]*sn2[neib])
En = En + 2*(1 - sn2[cell]*sn1[neib])
neib = g.getcell(col, row-1)
En = En + 2*(1 - sn1[cell]*sn2[neib])
En = En + 2*(1 - sn2[cell]*sn1[neib])
neib = g.getcell(col-1, row-1)
En = En - 3*(1 - sn1[cell]*sn2[neib])
En = En - 3*(1 - sn2[cell]*sn1[neib])
neib = g.getcell(col-1, row+1)
En = En - 3*(1 - sn1[cell]*sn2[neib])
En = En - 3*(1 - sn2[cell]*sn1[neib])
g.show("Energy: " + str(-En/2))
The energies are useful for check, for example I found an error in previous post, because
initially supposed that my old Revtwo rule is side=corner, i.e. confused that with other
old rule (sorry for names
)
Code: Select all
@RULE Revdoubl
Reversible second order rule
from tb3 list
0 1 1
1 1 1
@TREE
num_states=4
num_neighbors=8
num_nodes=22
1 0 2 1 3
1 1 3 0 2
2 0 0 0 0
2 0 1 0 1
2 1 0 1 0
3 2 2 2 2
3 3 4 3 4
3 4 2 4 2
4 5 5 5 5
4 6 7 6 7
4 7 5 7 5
5 8 8 8 8
5 9 10 9 10
6 11 12 11 12
6 12 11 12 11
6 11 11 11 11
7 13 14 13 14
7 14 15 14 15
7 15 15 15 15
8 16 17 16 17
8 17 18 17 18
9 19 20 19 20
Alexander