Saka wrote:gameoflifemaniac wrote:But is there any notation for asymmetric rules?

Not at the moment. Only for non totalistic rules.

LifeViewer has a notation, and it's possible that some variant of that notation could get included in Golly 2.9 / 3.0. Here's plain-vanilla Life re-encoded as an asymmetric rule string:

Code: Select all

```
#N Acorn
#O Charles Corderman
#C A methuselah with lifespan 5206.
#C www.conwaylife.com/wiki/index.php?title=Acorn
x = 7, y = 3, rule = MAPARYXfhZofugWaH7oaIDogBZofuhogOiAaIDogIAAgAAWaH7oaIDogGiA6ICAAIAAaIDogIAAgACAAIAAAAAAAA
bo5b$3bo3b$2o2b3o!
```

The ARYX... string is just the following binary number, basically a rearrangement of the pattern of eaters and no-eaters in the megacell's lookup table, in a standard base64 encoding --

Code: Select all

`00000001000101100001011101111110000101100110100001111110111010000001011001101000011111101110100001101000100000001110100010000000000101100110100001111110111010000110100010000000111010001000000001101000100000001110100010000000100000000000000010000000000000000001011001101000011111101110100001101000100000001110100010000000011010001000000011101000100000001000000000000000100000000000000001101000100000001110100010000000100000000000000010000000000000001000000000000000100000000000000000000000000000000000000000000000`

There's also an option to generate random rules by putting in a threshold value -- i.e., the likelihood that that each bit will be a 1.

**EDIT:** LifeViewer uses a left-to-right top-to-bottom ordering of the nine cell states. The megacell has its neighbors numbered around the outside starting from the middle of one edge, then into the center (see diagram in previous post).

Here are the minor adjustments that were needed to the code in megafier-universal.lua to generate the above bitstring. Theoretically this standalone Lua script should produce the correct LifeViewer MAP bitstring for the current rule, as long as Golly is simulating a two-state non-totalistic rule. The script won't care about whether Golly's using RuleLoader or some other algorithm -- it just runs all 512 possible combinations for one tick and compiles the results.

Code: Select all

```
-- make_nontotalistic_LifeViewer_rulestring_v1.0.lua
local g = golly()
local gp = require "gplus"
local split = gp.split
-- local pattern = gp.pattern
function fixrule(s)
return (gp.split(s,":")) -- remove bounded grid spec, if any
end
g.addlayer("temp") -- keep and test the current rule
fixedrule=fixrule(g.getrule())
g.setrule(fixedrule)
bitlist={{-1,-1,256},{0,-1,128},{1,-1,64},{-1,0,32},{0,0,16},{1,0,8},{-1,1,4},{0,1,2},{1,1,1}}
for j = 1, 9 do
x, y, bit = table.unpack(bitlist[j])
for i=0, 511 do
if i&bit>0 then g.setcell(i*5+x,y,1) end
end
end
g.run(1)
bits={}
ind=1
local rulestr, invstr, revinvstr="","",""
for k=0,2555,5 do
if g.getcell(k,0)==1 then
rulestr=rulestr.."1"
invstr=invstr.."0"
revinvstr="0"..revinvstr
else
rulestr=rulestr.."0"
invstr=invstr.."1"
revinvstr="1"..revinvstr
end
end
-- build base64 lookup table
local lookupstr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
bdict={}
for i=1,64 do
local w=""
for j=0,5 do
if (i-1)&2^j>0 then w="1"..w else w="0"..w end
end
bdict[w]=lookupstr:sub(i,i)
end
-- decide whether to use standard, inverted, or inverted-reversed bitstring, based on fixedrule
-- (assuming Golly is correctly simulating rules with B0, with or without S8, to avoid strobing)
-- the following won't work for anisotropic non-totalistic rules defined by MAP strings,
-- so we'll have to decode the MAP rulestring into a 512-bit string in that case, check first and last digits...
-- but in that case, we already know the string, so why are we running this script anyway?
if string.match(fixedrule,"B0") then rulestr = string.match(fixedrule,"S.*8") and revinvstr or invstr end
local s = rulestr.."0000" -- pad so that len mod 6=0
base64=""
for i=1,511,6 do base64=base64..bdict[s:sub(i,i+5)] end
g.setclipstr(rulestr.."\n"..base64)
g.show("Copied to clipboard: "..base64)
-- Life = 'ARYXfhZofugWaH7oaIDogBZofuhogOiAaIDogIAAgAAWaH7oaIDogGiA6ICAAIAAaIDogIAAgACAAIAAAAAAAA'
```

**EDIT2:** Fair warning: the script doesn't work correctly for B0-and-S8 or B0-but-no-S8 isotropic or Life-like rules yet, because Golly goes into simulation mode. So the script sees the simulated rule in operation rather than the "real" rule. Will edit in a version 1.0 of the script above, when I get around to sorting that out.

[Those aren't the greatest rules to simulate with megacells anyway, because you tend to get weird edge effects in any finite patch of megacells -- would have to add p16777216 guns all round the edges to get a B0-and-S8 rule working right. And the B0-no-S8 simulation would strobe ON and OFF all the time.]

**EDIT3:** Almost fixed now, I think -- it will work for any nontotalistic rule, isotropic or anisotropic, until Golly is updated to simulate B0 anisotropic rules natively without strobing. Then we'll have to check for whatever the native rule format is for anisotropic rules, and go to version 1.1.

Anyone see any bugs? I only did the most absolutely minimal testing, but a bounded-grid with a minimal anisotropic rule worked almost as expected... just ended up with the mirror image of what I wanted. Will correct that tomorrow.

**EDIT4:** Patched the mirror-image problem. Here's a simple test case:

Test rule that leaves ON cells on, and also turns on OFF cells with one neighbor in the southeaast:

Code: Select all

```
@RULE testNWrule
@TABLE
n_states:2
neighborhood:Moore
symmetries:none
0,0,0,0,1,0,0,0,0,1
```

Output from script:

Code: Select all

```
01000000000000001111111111111111000000000000000011111111111111110000000000000000111111111111111100000000000000001111111111111111000000000000000011111111111111110000000000000000111111111111111100000000000000001111111111111111000000000000000011111111111111110000000000000000111111111111111100000000000000001111111111111111000000000000000011111111111111110000000000000000111111111111111100000000000000001111111111111111000000000000000011111111111111110000000000000000111111111111111100000000000000001111111111111111
QAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//w
```

Making the same rule as a MAP rule:

Code: Select all

```
x = 15, y = 5, rule = MAPQAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//w
3ob3o2b2ob3o$bo2bo3bo4bo$bo2b2o3bo3bo$bo2bo5bo2bo$bo2b3ob2o3bo!
```