Rule request thread

For discussion of other cellular automata.
User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » January 5th, 2018, 8:56 am

How about a rule that simulates a 3D rule which is two cells thick on the Z axis?

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » January 5th, 2018, 11:30 pm

gameoflifemaniac wrote:Three Life universes at once?
I wouldn't mind seeing the rules with three and four independent universes, but the DoubleB3S23 rule is as far as my patience goes for building these rules manually. If we write a script to generate the lines of the rule table, we might as well make it work also for four and five independent universes, and just see how Golly handles a rule table with 1.3 million lines in it, and how many are needed for five independent states.

Maybe it will be somewhat less than 1.3 million rule lines for four states, if we can come up with a workable way to use variables. DoubleB3S23 manages with fewer than 55 rule lines, after all.

So... if someone would build colored icons for the sixteen states, showing different colored squares in each of the four quadrants, then we could use the first eight of the icons for TripleB3S23. Or 32 states, with a fifth state in the center? The automated script could use whatever icons anyone wants to make.

It still seems as if six or more independent universes is going to be too many for Golly to be happy with, though it might be able to handle five if it had to. Every time you add an independent bit to the pile, you double the number of groups of rule lines you need, and also the size of each group increases exponentially. Best to have a script generate all the possibilities.

Here's what the TripleB3S23 rule could look like, minus the auto-generated rule lines:

Code: Select all

@RULE TripleB3S23-INCOMPLETE
@TABLE

n_states:8
neighborhood:Moore
symmetries:permute

# The three universes will be state 1, state 2, and state 4.
# Summing these independent universes gives the composite state.
# 0x001 bit ON (+1)
var a={1,3,5,7}
var aa=a
var ab=a
var ac=a
var ad=a
var ae=a
var af=a
var ag=a

# 0x001 bit OFF
var b={0,2,4,6}
var ba=b
var bb=b
var bc=b
var bd=b
var be=b
var bf=b
var bg=b

# 0x010 bit ON (+2)
var c={2,3,6,7}
var ca=c
var cb=c
var cc=c
var cd=c
var ce=c
var cf=c
var cg=c

# 0x010 bit OFF
var d={0,1,4,5}
var da=d
var db=d
var dc=d
var dd=d
var de=d
var df=d
var dg=d

# 0x100 bit ON (+4)
var e={4,5,6,7}
var ea=e
var eb=e
var ec=e
var ed=e
var ee=e
var ef=e
var eg=e

# 0x100 bit OFF
var f={0,1,2,3}
var fa=f
var fb=f
var fc=f
var fd=f
var fe=f
var ff=f
var fg=f

# don't-care cells
var x={0,1,2,3,4,5,6,7}
var xa=x
var xb=x
var xc=x
var xd=x
var xe=x
var xf=x
var xg=x
var xh=x

# # the following are the rules for DoubleB3S23 --
# # can be used as a template for completing TripleB3S23
#
# # birth for both 0x01 and 0x10 bits
# x,1,1,1,2,2,2,0,0,3
# x,1,1,3,2,2,0,0,0,3
# x,1,3,3,2,0,0,0,0,3
# x,3,3,3,0,0,0,0,0,3
# 
# # survival for 0x01 bit, birth for 0x10 bit
# 1,2,2,2,1,1,0,0,0,3
# 1,2,2,3,1,0,0,0,0,3
# 1,2,3,3,0,0,0,0,0,3
# 
# # birth for 0x01 bit, survival for 0x10 bit
# 2,1,1,1,2,2,0,0,0,3
# 2,1,1,3,2,0,0,0,0,3
# 2,1,3,3,0,0,0,0,0,3
# 
# # 2-neighbor survival for 0x01 bit, 3-neighbor survival for 0x10 bit
# 3,1,1,2,2,2,0,0,0,3
# 3,1,3,2,2,0,0,0,0,3
# 3,3,3,2,0,0,0,0,0,3
# 
# # 3-neighbor survival for 0x01 bit, 2-neighbor survival for 0x10 bit
# 3,1,1,1,2,2,0,0,0,3
# 3,1,1,3,2,0,0,0,0,3
# 3,1,3,3,0,0,0,0,0,3
# 
# # 2-neighbor survival for both 0x01 and 0x10 bits
# 3,1,1,2,2,0,0,0,0,3
# 3,1,3,2,0,0,0,0,0,3
# 3,3,3,0,0,0,0,0,0,3
# 
# # birth for 0x01 bit, death for 0x10 bit
# x,a,aa,ab,ba,bb,bc,bd,be,1
# x,a,aa,ab,ba,bb,bc,bd,be,1
# 1,a,aa,ba,bb,bc,bd,be,bf,1
# 3,a,aa,ba,bb,bc,bd,be,bf,1
# 
# # death for 0x01 bit, birth for 0x10 bit
# x,c,ca,cb,da,db,dc,dd,de,2
# x,c,ca,cb,da,db,dc,dd,de,2
# 2,c,ca,da,db,dc,dd,de,df,2
# 3,c,ca,da,db,dc,dd,de,df,2
# 
# # death for both bits
# x,xa,xb,xc,xd,xe,xf,xg,xh,0

@COLORS

0 0 0 0
1 255 0 0
2 0 255 0
3 255 255 0
4 0 0 255
5 255 0 255
6 255 255 0
7 255 255 255

@ICONS
# ????

User avatar
gameoflifemaniac
Posts: 1242
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: Rule request thread

Post by gameoflifemaniac » January 6th, 2018, 10:39 am

dvgrn wrote:
gameoflifemaniac wrote:Three Life universes at once?
I wouldn't mind seeing the rules with three and four independent universes, but the DoubleB3S23 rule is as far as my patience goes for building these rules manually. If we write a script to generate the lines of the rule table, we might as well make it work also for four and five independent universes, and just see how Golly handles a rule table with 1.3 million lines in it, and how many are needed for five independent states.

Maybe it will be somewhat less than 1.3 million rule lines for four states, if we can come up with a workable way to use variables. DoubleB3S23 manages with fewer than 55 rule lines, after all.

So... if someone would build colored icons for the sixteen states, showing different colored squares in each of the four quadrants, then we could use the first eight of the icons for TripleB3S23. Or 32 states, with a fifth state in the center? The automated script could use whatever icons anyone wants to make.

It still seems as if six or more independent universes is going to be too many for Golly to be happy with, though it might be able to handle five if it had to. Every time you add an independent bit to the pile, you double the number of groups of rule lines you need, and also the size of each group increases exponentially. Best to have a script generate all the possibilities.

Here's what the TripleB3S23 rule could look like, minus the auto-generated rule lines:

Code: Select all

@RULE TripleB3S23-INCOMPLETE
@TABLE

n_states:8
neighborhood:Moore
symmetries:permute

# The three universes will be state 1, state 2, and state 4.
# Summing these independent universes gives the composite state.
# 0x001 bit ON (+1)
var a={1,3,5,7}
var aa=a
var ab=a
var ac=a
var ad=a
var ae=a
var af=a
var ag=a

# 0x001 bit OFF
var b={0,2,4,6}
var ba=b
var bb=b
var bc=b
var bd=b
var be=b
var bf=b
var bg=b

# 0x010 bit ON (+2)
var c={2,3,6,7}
var ca=c
var cb=c
var cc=c
var cd=c
var ce=c
var cf=c
var cg=c

# 0x010 bit OFF
var d={0,1,4,5}
var da=d
var db=d
var dc=d
var dd=d
var de=d
var df=d
var dg=d

# 0x100 bit ON (+4)
var e={4,5,6,7}
var ea=e
var eb=e
var ec=e
var ed=e
var ee=e
var ef=e
var eg=e

# 0x100 bit OFF
var f={0,1,2,3}
var fa=f
var fb=f
var fc=f
var fd=f
var fe=f
var ff=f
var fg=f

# don't-care cells
var x={0,1,2,3,4,5,6,7}
var xa=x
var xb=x
var xc=x
var xd=x
var xe=x
var xf=x
var xg=x
var xh=x

# # the following are the rules for DoubleB3S23 --
# # can be used as a template for completing TripleB3S23
#
# # birth for both 0x01 and 0x10 bits
# x,1,1,1,2,2,2,0,0,3
# x,1,1,3,2,2,0,0,0,3
# x,1,3,3,2,0,0,0,0,3
# x,3,3,3,0,0,0,0,0,3
# 
# # survival for 0x01 bit, birth for 0x10 bit
# 1,2,2,2,1,1,0,0,0,3
# 1,2,2,3,1,0,0,0,0,3
# 1,2,3,3,0,0,0,0,0,3
# 
# # birth for 0x01 bit, survival for 0x10 bit
# 2,1,1,1,2,2,0,0,0,3
# 2,1,1,3,2,0,0,0,0,3
# 2,1,3,3,0,0,0,0,0,3
# 
# # 2-neighbor survival for 0x01 bit, 3-neighbor survival for 0x10 bit
# 3,1,1,2,2,2,0,0,0,3
# 3,1,3,2,2,0,0,0,0,3
# 3,3,3,2,0,0,0,0,0,3
# 
# # 3-neighbor survival for 0x01 bit, 2-neighbor survival for 0x10 bit
# 3,1,1,1,2,2,0,0,0,3
# 3,1,1,3,2,0,0,0,0,3
# 3,1,3,3,0,0,0,0,0,3
# 
# # 2-neighbor survival for both 0x01 and 0x10 bits
# 3,1,1,2,2,0,0,0,0,3
# 3,1,3,2,0,0,0,0,0,3
# 3,3,3,0,0,0,0,0,0,3
# 
# # birth for 0x01 bit, death for 0x10 bit
# x,a,aa,ab,ba,bb,bc,bd,be,1
# x,a,aa,ab,ba,bb,bc,bd,be,1
# 1,a,aa,ba,bb,bc,bd,be,bf,1
# 3,a,aa,ba,bb,bc,bd,be,bf,1
# 
# # death for 0x01 bit, birth for 0x10 bit
# x,c,ca,cb,da,db,dc,dd,de,2
# x,c,ca,cb,da,db,dc,dd,de,2
# 2,c,ca,da,db,dc,dd,de,df,2
# 3,c,ca,da,db,dc,dd,de,df,2
# 
# # death for both bits
# x,xa,xb,xc,xd,xe,xf,xg,xh,0

@COLORS

0 0 0 0
1 255 0 0
2 0 255 0
3 255 255 0
4 0 0 255
5 255 0 255
6 255 255 0
7 255 255 255

@ICONS
# ????
The rule doesn't move at all. Is this why the rule is incomplete?
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » January 6th, 2018, 11:30 am

gameoflifemaniac wrote:
dvgrn wrote:...Here's what the TripleB3S23 rule could look like, minus the auto-generated rule lines:

Code: Select all

...
# # the following are the rules for DoubleB3S23 --
# # can be used as a template for completing TripleB3S23
...
@ICONS
# ????
The rule doesn't move at all. Is this why the rule is incomplete?
Yes. Must you really quote entire previous posts including patterns and rule tables and everything? It's not as if anyone really needs to see another exact copy quite so soon.

Start at the top of the rule table and look at every line. The whole thing really is human-readable. It seems mysterious at first, because the

Code: Select all

1,2,2,2,1,1,0,0,0,3
lines aren't labeled. But that's really the biggest item that you have to learn, and it's not complicated at all. The above line translates to
[ implied IF ]

CellStartState=1,
NorthNeighborState=2,
NortheastNeighborState=2,
EastNeighborState=2,
SoutheastNeighborState=1,
SouthNeighborState=1,
SouthwestNeighborState=0,
WestNeighborState=0,
and
NorthwestNeighborState=0
{or any permutation of the above, because the permute symmetry is set}

[ implied THEN ]

set the cell state to 3, and stop reading the rule list -- a matching rule has been found.
A rule table is just made up of a series of statements like this, in abbreviated form. If you read the whole rule file, and notice the comments along the way that provide the answer to your question, then you should be able to follow the logic and see why the commented-out lines would produce a working DoubleB3S23 universe.

It's not too horribly difficult to complete a TripleB3S23 rule manually, but it would be tedious and very easy to miss a few cases, so I'd advise writing a script to generate all the right rule lines.

User avatar
Rhombic
Posts: 1072
Joined: June 1st, 2013, 5:41 pm

Re: Rule request thread

Post by Rhombic » January 6th, 2018, 12:09 pm

The double life might allow tricks in computation for scripts. For instance, it is trivial to find, say, one glider in a specific orientation that destroys either of two different patterns, regardless of which it is (shown, how this glider destroys both a B and a century):

Code: Select all

x = 9, y = 8, rule = DoubleB3S23
7.C$6.3C$5.2C.A3$3C$2.C$.C!
As you might be able to tell, performing this trick without DoubleB3S23 takes longer because you have to check for every possibility whether the combination of the bounding boxes of the results is smaller or not. I'm using glider-destruction.py, which minimises results based on bounding box. So the idea of simulating two diffrent patterns at once and studying the relative position of the outcome could potentially be very useful. Slow salvos, how to synthesise specific objects for cleaner syntheses. I don't know, it will take some creativity but there is something.
SoL : FreeElectronics : DeadlyEnemies : 6a-ite : Rule X3VI
what is “sesame oil”?

User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » January 6th, 2018, 10:02 pm

What would the MAP strings for B1/S and B1/S012345678 be, given that the bottom left most cell is never born from the B1 condition?

User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » March 18th, 2018, 10:31 am

muzik wrote:What would the MAP strings for B1/S and B1/S012345678 be, given that the bottom left most cell is never born from the B1 condition?
Still waiting.

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » March 18th, 2018, 11:02 am

muzik wrote:
muzik wrote:What would the MAP strings for B1/S and B1/S012345678 be, given that the bottom left most cell is never born from the B1 condition?
Still waiting.
I'm very curious, with all due respect, to know why you're still waiting instead of figuring it out yourself.

Given, say, Rhombic's script plus the MAP documentation in the LifeWiki, what exactly stops you from running the script once starting from B1/S or B1/S012345678, and getting the rule you want?

I can certainly add more paragraphs to the documentation if that would be helpful, but I don't know quite what's left that needs explaining.

User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » March 18th, 2018, 12:08 pm

Didn't realize those existed until now because i'm stupid. I'll try and get my head around it.

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » March 18th, 2018, 12:27 pm

muzik wrote:Didn't realize those existed until now because i'm stupid. I'll try and get my head around it.
Looking at it again, I see one thing that could make everything much easier.

I thought Rhombic's script defaulted to the current rule set in Golly, but it just defaults to B3/S23 (in MAP format).

EDIT: Just posted a Lua version of MAPper. Seems to work okay for the two cases mentioned above.

The script can double as a Life-like rule to MAP rule converter -- you can copy the MAP string out of the initial dialog, then cancel the script.

Code: Select all

Input=001000000

[meaning
001
000
000
]

-- B1/S
-- aIAAAIAAAACAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-- becomes
-- aIAAAIAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

-- B1/S012345678
-- aID//4AA//+AAP//AAD//4AA//8AAP//AAD//wAA//+AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//w
-- becomes
-- aID//4AA//8AAP//AAD//4AA//8AAP//AAD//wAA//+AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//w

User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » March 18th, 2018, 2:49 pm

Cant exactly say these results were what I was expecting. I was expecting it to fill out like a heptagon, just like how this does a hexagon:

Code: Select all

x = 1, y = 1, rule = B1/SH
o!
However, the actual result is a Sierpinski triangle:

Code: Select all

x = 1, y = 1, rule = MAPaIAAAIAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
o!
How could I get a replicator that forms a heptagon?

dani
Posts: 1222
Joined: October 27th, 2017, 3:43 pm

Re: Rule request thread

Post by dani » March 18th, 2018, 3:15 pm

muzik wrote:How could I get a replicator that forms a heptagon?
Try adding:

Code: Select all

x = 16, y = 5, rule = MAPaIAAAIAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
5o2bo3b5o$obobo3bo2bo3bo$o2b2ob4obobobo$o3bo3bo2bo3bo$5o2bo3b5o!
(B2e)

User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » March 18th, 2018, 4:19 pm

That didn't do it.

Code: Select all

x = 1, y = 1, rule = MAPaIAAAIAAAAAAAAAAAAAAAICAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
o!

User avatar
77topaz
Posts: 1496
Joined: January 12th, 2018, 9:19 pm

Re: Rule request thread

Post by 77topaz » March 18th, 2018, 5:36 pm

I think the limitations of the square grid may just prevent heptagon-shaped replicators entirely (for example, regular replicators don't form octagons either, but squares or diamonds).

User avatar
muzik
Posts: 5612
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Rule request thread

Post by muzik » March 18th, 2018, 7:09 pm

77topaz wrote:I think the limitations of the square grid may just prevent heptagon-shaped replicators entirely (for example, regular replicators don't form octagons either, but squares or diamonds).
The Replicator rule allows for eightfold replication though.

User avatar
77topaz
Posts: 1496
Joined: January 12th, 2018, 9:19 pm

Re: Rule request thread

Post by 77topaz » March 18th, 2018, 10:35 pm

muzik wrote:The Replicator rule allows for eightfold replication though.
But that occurs in a square shape, not an octagonal shape:

Code: Select all

x = 3, y = 3, rule = B1357/S1357
b2o$2o$bo!

Caenbe
Posts: 52
Joined: September 20th, 2016, 4:24 pm
Location: USA

Re: Rule request thread

Post by Caenbe » July 16th, 2018, 5:21 pm

I asked for this before, but it got misunderstood, so I'm gonna try again.

I want a way to take a normal life-like rule, say B3678/S01245 (just an example) and run it so instead of the cells all updating simultaneously, they update in a specific asynchronous fashion.

The way cells should update is as follows:
At time 4n, all cells with even x and even y update.
At time 4n+1, all cells with odd x and even y update.
At time 4n+2, all cells with odd x and odd y update.
At time 4n+3, all cells with even x and odd y update.
In other words, 1/4 of the cells update at any given tick, and the locations of the cells that are updated alternately shift horizontally and vertically.

The motivation behind this is so I can take a rule such as B3678/S01245, where the B's are the complement of the S's, and turn it into a reversible rule.

Hopefully that was clear enough. Please, someone do this, because I'm really intrigued by this rulespace.
Music make you lose control
Music make you lose control
echo "print(10**10**5//~-10**1000//9801)" | python | aplay

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » July 17th, 2018, 12:16 am

Caenbe wrote:I asked for this before, but it got misunderstood, so I'm gonna try again.

I want a way to take a normal life-like rule, say B3678/S01245 (just an example) and run it so instead of the cells all updating simultaneously, they update in a specific asynchronous fashion.

The way cells should update is as follows:
At time 4n, all cells with even x and even y update.
At time 4n+1, all cells with odd x and even y update.
At time 4n+2, all cells with odd x and odd y update.
At time 4n+3, all cells with even x and odd y update.
In other words, 1/4 of the cells update at any given tick, and the locations of the cells that are updated alternately shift horizontally and vertically.

The motivation behind this is so I can take a rule such as B3678/S01245, where the B's are the complement of the S's, and turn it into a reversible rule.

Hopefully that was clear enough. Please, someone do this, because I'm really intrigued by this rulespace.
This sounds interesting, and I'd certainly be happy to help someone write a Lua or Python script to produce the necessary rule table. But I don't really need the practic -- so somebody else will have to make the initial effort.

To convert an arbitrary pattern to work like this, I think you'll just need an 8-state rule -- four OFF states and four ON states, but states 2 through 7 always just retain their state and cycle 3->5->7>1 and 2->4>6->0. The first part of the script just adds 2, 4, or 6 to the state number according to the location. That's a simple enough script for anyone to write in any language, given sufficient motivation.

Then you need more code to parse "B3678/S01245" into "B3", "B6", "B7", "B8", "S0", "S1", "S2", "S4", "S5". We can get away with permute symmetry as long as you don't need to support isotropic rules -- so you can have a lookup table that converts

"B3" into "0, 1,1,1,0,0,0,0,0, 1",
"B6" into "0, 1,1,1,1,1,1,0,0, 1",
"S5" into "1, 1,1,1,1,1,0,0,0, 1" and so on.

Then the script writes the relevant lines out to a rule table file, but with variables defining all the OFF and ON states replacing all but the first and last 0's and 1's above:

var OFF = {0,2,4,6}
var ON = {1,3,5,7}
var any1 = {0,1,2,3,4,5,6,7}
var any2 = any1
var any3 = any1
var any4 = any1
var any5 = any1
var any6 = any1
var any7 = any1
var any8 = any1

2,any,any,any,any,any,any,any,any,4
4,any,any,any,any,any,any,any,any,6
6,any,any,any,any,any,any,any,any,0
3,any,any,any,any,any,any,any,any,5
5,any,any,any,any,any,any,any,any,7
7,any,any,any,any,any,any,any,any,1

# B3
0,ON,ON,ON,OFF,OFF,OFF,OFF,OFF,1
# etc.

Does anyone have the code for writing two-state Life-like rules as rule tables, lying around somewhere? There seem to be rule tables showing up that look like they're generated by this kind of script, but I don't know where the code is offhand.

wildmyron
Posts: 1542
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: Rule request thread

Post by wildmyron » July 17th, 2018, 3:30 am

I think you've detailed quite a good scheme to simulate these rules. Just need to make sure that the scheme for translating On and Off cells to the corresponding state matches the spec for when they should transition. I think it's easier if the cell states cycle in the opposite direction, i.e. 7->5->3->1 and 6->4->2->0. Then converting a 2-state pattern to a valid starting pattern should be as simple as:

Cells which update in generations 4n+m have 2*m added to there current state. (Assuming the current generation is 0 (or divisible by 4).

The only other wrinkle is this won't work well with infinite layers in Golly - either run on a plane / torus, or add a ninth state and let 0 remain as vacuum.
dvgrn wrote:# B3
0,ON,ON,ON,OFF,OFF,OFF,OFF,OFF,1
# etc.
I think you need to amend this to include the state transitions. For the scheme I propose (and including survival rules for Life) this becomes:

Code: Select all

0,ON,ON,ON,OFF,OFF,OFF,OFF,OFF,7 # B3
1,ON,ON,OFF,OFF,OFF,OFF,OFF,OFF,7 # S2
1,ON,ON,ON,OFF,OFF,OFF,OFF,OFF,7 # S3
Actually, after testing this I realise that additional variables are required for ON and OFF. Here's a complete test of the idea with B3/S23.

Code: Select all

@RULE AsyncLife
An Asynchronous version of Conway's Game of Life
http://conwaylife.com/forums/viewtopic.php?p=61953#p61953

Cells obey the usual rules of Life, but instead of the cells all updating
simultaneously, they update in a specific asynchronous fashion.

Cell states:
0: 		vacuum
odd: 	On cells
even:	Off cells

The way cells update is as follows:
At time 4n, all cells with even x and even y update (initialised to states 1 and 2).
At time 4n+1, all cells with odd x and even y update (initialised to states 3 and 4).
At time 4n+2, all cells with odd x and odd y update (initialised to states 5 and 6).
At time 4n+3, all cells with even x and odd y update (initialised to states 7 and 8).

@TABLE
n_states: 9
neighborhood: Moore
symmetries: permute

var OFF1 = {2,4,6,8}
var OFF2 = OFF1
var OFF3 = OFF1
var OFF4 = OFF1
var OFF5 = OFF1
var OFF6 = OFF1
var OFF7 = OFF1
var OFF8 = OFF1
var ON1 = {1,3,5,7}
var ON2 = ON1
var ON3 = ON1
var ON4 = ON1
var ON5 = ON1
var ON6 = ON1
var ON7 = ON1
var ON8 = ON1
var any1 = {1,2,3,4,5,6,7,8}
var any2 = any1
var any3 = any1
var any4 = any1
var any5 = any1
var any6 = any1
var any7 = any1
var any8 = any1

# Active cells
2,ON1,ON2,ON3,OFF4,OFF5,OFF6,OFF7,OFF8,7 	# B3
1,ON1,ON2,OFF3,OFF4,OFF5,OFF6,OFF7,OFF8,7 	# S2
1,ON1,ON2,ON3,OFF4,OFF5,OFF6,OFF7,OFF8,7 	# S3
2,any1,any2,any3,any4,any5,any6,any7,any8,8
1,any1,any2,any3,any4,any5,any6,any7,any8,8 # Death

# Inactive cells
4,any1,any2,any3,any4,any5,any6,any7,any8,2
6,any1,any2,any3,any4,any5,any6,any7,any8,4
8,any1,any2,any3,any4,any5,any6,any7,any8,6
3,any1,any2,any3,any4,any5,any6,any7,any8,1
5,any1,any2,any3,any4,any5,any6,any7,any8,3
7,any1,any2,any3,any4,any5,any6,any7,any8,5

@COLORS
0    0    0    0
1  255  255  255
2   64   64   64
3  255    0    0
4   64    0    0
5  255  128    0
6   64   32    0
7  255  255    0
8   64   64    0
And here's a quick and dirty script to initialise an asynchronous universe from a 2-state pattern:

Code: Select all

-- initAsyncUniverse - initialise a part of the universe to run asynchronous CA rules
-- see http://conwaylife.com/forums/viewtopic.php?p=61953#p61953
-- Author: Arie Paap, July 2018
-- Credit: Based on Golly's invert.lua by Andrew Trevorrow

-- Usage: Draw a pattern in a 2-state rule at Gen 0 and then run this script

local g = golly()
local gp = require "gplus"

-- re-assigning inner loop functions results in a 10% speed up
local setcell = g.setcell
local getcell = g.getcell

-- Determine the area to initialise
local buffer = 50
local r = g.getselrect()
if #r == 0 then r = {0, 0, 0, 0} end

r[1] = r[1] - buffer
r[2] = r[2] - buffer
r[3] = r[3] + 2*buffer
r[4] = r[4] + 2*buffer

r = gp.rect(r)

-- Convert cells within this area

local oldsecs = os.clock()
local newsecs = os.clock()
local state = 0

for row = r.top, r.bottom do
    -- if large selection then give some indication of progress
    newsecs = os.clock()
    if newsecs - oldsecs >= 1.0 then
        oldsecs = newsecs
        g.update()
    end
    for col = r.left, r.right do
        state = 2 + 2 * ( 2*(row % 2) + (col % 2) )     
        setcell(col, row, state - getcell(col, row))
    end
end
This is significantly more explosive than I was expecting. Here are two nice test patterns:

Code: Select all

x = 8, y = 2, rule = AsyncLife
2A3.3A$2A3.3A!

Code: Select all

x = 3, y = 1, rule = AsyncLife
3A!
Run the script after opening each of these patterns in Golly.
@Caenbe: Does this match the behaviour you were hoping for?
dvgrn wrote:Does anyone have the code for writing two-state Life-like rules as rule tables, lying around somewhere? There seem to be rule tables showing up that look like they're generated by this kind of script, but I don't know where the code is offhand.
I think many of those rules have been hand written based on a template, though there may be a script. The saveContiguousLife() function from apgsearch should be easily adaptable to this task. It shouldn't be too much work to adapt it using the AsyncLife rule as a template and using the scoline() function to generate the Birth and Survival rules. I'll leave that to someone else though.
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by AforAmpere. The latest collection is hosted on GitHub and contains well over 1,000,000 spaceships.

Semi-active here - recovering from a severe case of LWTDS.

User avatar
Goldtiger997
Posts: 762
Joined: June 21st, 2016, 8:00 am

Re: Rule request thread

Post by Goldtiger997 » July 17th, 2018, 3:48 am

dvgrn wrote:Does anyone have the code for writing two-state Life-like rules as rule tables, lying around somewhere? There seem to be rule tables showing up that look like they're generated by this kind of script, but I don't know where the code is offhand.
Well I have this one by EricG which works for all isotropic rules, so it should work for two-state Life-like rules:

Code: Select all

# HenselNotation->Ruletable(1.3).py
#  by Eric Goldstein, July 20, 2012.

import golly

dialog_box_message =  '''This script will allow you to enter the non-totalistic rule notation 
used by Johan Bontes' Life32 program, based on work by Alan Hensel.
Please look in the script file to see how the notation works.
Newly created rules will be placed in Golly's Rules directory (set in Golly"s preferences).

Note:  Alan Hensel's notation for r and y are swapped in Life32.   Life32's rule dialog box
shows the correct arrangements, but they are swapped in the implementation.
What should work as 3r, 4r, and 5r, actually work as 3y, 4y, and 5y, and vice versa.
This script swaps the definition of r and y just like Life32 does, so that rules will
run the same way using either Golly or Life32.

An example rule is given below as a default.  Rules are case-insensitive.
B2a/S12, S12/B2a, and 12/2a are valid and equivalent.  

Inverse specifications are allowed.  For example, David Bell's Just Friends rule can be 
expressed B2-a/S12 indicating that all B2 arrangements are included except 2a.


There are two ways to use this script.  Both ways will create a new ruletable, and 
set the active layer of Golly to use the new rule. 
1) You can enter a rule below.
2) You can copy the contents of a life32 file starting with "#r" and then click
on this script, after which you'll be able to paste the pattern into Golly's active layer.

Enter a rule here:
   '''



# Golly"s ruletable format use the following notation:  
#  C,N,NE,E,SE,S,SW,W,NW,C' 
# where C is the current state, and C' is the new state, and
# where the eight neighbors in the Moore neighborhood are as shown below.

#     NW  N  NE 
#     W   C  E  
#     SW  S  SE 

# The lookup table below for Life32"s non-totalistic notation uses the eight neighbor values:
#   N,NE,E,SE,S,SW,W,NW

# The following code shows how the non-totalistic notation works:

notationdict = {  
                 "1e" : "1,0,0,0,0,0,0,0",  #   N 
                 "1c" : "0,1,0,0,0,0,0,0",  #   NE
                 "2a" : "1,1,0,0,0,0,0,0",  #   N,  NE
                 "2e" : "1,0,1,0,0,0,0,0",  #   N,  E 
                 "2k" : "1,0,0,1,0,0,0,0",  #   N,  SE
                 "2i" : "1,0,0,0,1,0,0,0",  #   N,  S 
                 "2c" : "0,1,0,1,0,0,0,0",  #   NE, SE
                 "2v" : "0,1,0,0,0,1,0,0",  #   NE, SW
                 "3a" : "1,1,1,0,0,0,0,0",  #   N,  NE, E
                 "3v" : "1,1,0,1,0,0,0,0",  #   N,  NE, SE 
                 "3y" : "1,1,0,0,1,0,0,0",  #   N,  NE, S      (3r in non-swapped notation)
                 "3q" : "1,1,0,0,0,1,0,0",  #   N,  NE, SW
                 "3j" : "1,1,0,0,0,0,1,0",  #   N,  NE, W
                 "3i" : "1,1,0,0,0,0,0,1",  #   N,  NE, NW
                 "3e" : "1,0,1,0,1,0,0,0",  #   N,  E,  S
                 "3k" : "1,0,1,0,0,1,0,0",  #   N,  E,  SW
                 "3r" : "1,0,0,1,0,1,0,0",  #   N,  SE, SW     (3y in non-swapped notation)
                 "3c" : "0,1,0,1,0,1,0,0",  #   NE, SE, SW 
                 "4a" : "1,1,1,1,0,0,0,0",  #   N,  NE, E,  SE
                 "4y" : "1,1,1,0,1,0,0,0",  #   N,  NE, E,  S  (4r in non-swapped notation)
                 "4q" : "1,1,1,0,0,1,0,0",  #   N,  NE, E,  SW
                 "4i" : "1,1,0,1,1,0,0,0",  #   N,  NE, SE, S
                 "4r" : "1,1,0,1,0,1,0,0",  #   N,  NE, SE, SW (4y in non-swapped notation)
                 "4k" : "1,1,0,1,0,0,1,0",  #   N,  NE, SE, W
                 "4v" : "1,1,0,1,0,0,0,1",  #   N,  NE, SE, NW 
                 "4z" : "1,1,0,0,1,1,0,0",  #   N,  NE, S,  SW
                 "4j" : "1,1,0,0,1,0,1,0",  #   N,  NE, S,  W
                 "4t" : "1,1,0,0,1,0,0,1",  #   N,  NE, S,  NW
                 "4w" : "1,1,0,0,0,1,1,0",  #   N,  NE, SW, W
                 "4e" : "1,0,1,0,1,0,1,0",  #   N,  E,  S,  W
                 "4c" : "0,1,0,1,0,1,0,1",  #   NE, SE, SW, NW
                 "5a" : "0,0,0,1,1,1,1,1",  #   SE, S,  SW, W,  NW
                 "5v" : "0,0,1,0,1,1,1,1",  #   E,  S,  SW, W,  NW
                 "5y" : "0,0,1,1,0,1,1,1",  #   E,  SE, SW, W,  NW (5r in non-swapped notation)
                 "5q" : "0,0,1,1,1,0,1,1",  #   E,  SE, S,  W,  NW
                 "5j" : "0,0,1,1,1,1,0,1",  #   E,  SE, S,  SW, NW 
                 "5i" : "0,0,1,1,1,1,1,0",  #   E,  SE, S,  SW, W 
                 "5e" : "0,1,0,1,0,1,1,1",  #   NE, SE, SW, W,  NW, 
                 "5k" : "0,1,0,1,1,0,1,1",  #   NE, SE, S,  W,  NW
                 "5r" : "0,1,1,0,1,0,1,1",  #   NE, E,  S,  W, NW  (5y in non-swapped notation)
                 "5c" : "1,0,1,0,1,0,1,1",  #   N,  E,  S,  W,  NW
                 "6a" : "0,0,1,1,1,1,1,1",  #   E,  SE, S,  SW, W,  NW
                 "6e" : "0,1,0,1,1,1,1,1",  #   NE, SE, S,  SW, W,  NW
                 "6k" : "0,1,1,0,1,1,1,1",  #   NE, E,  S,  SW, W,  NW
                 "6i" : "0,1,1,1,0,1,1,1",  #   NE, E,  SE, SW, W,  NW
                 "6c" : "1,0,1,0,1,1,1,1",  #   N,  E,  S,  SW, W,  NW
                 "6v" : "1,0,1,1,1,0,1,1",  #   N,  E,  SE, S,  W,  NW
                 "7e" : "0,1,1,1,1,1,1,1",  #   NE, E,  SE, S,  SW, W,  NW 
                 "7c" : "1,0,1,1,1,1,1,1"   #   N,  E,  SE, S,  SW, W,  NW
                }


#  Here's a graphical depiction of the notation.
dummyvariable = '''
x = 147, y = 97, rule = B/S012345678
21b3o6b5o5bo3bo6b3o6b5o5bo3bo5bo3bo6b3o10bo5b4o6b5o5bobobo5b5o$20bo3bo
5bo9bo2bo6bo3bo7bo7bo3bo5bo3bo5bo3bo9bo5bo3bo7bo7bobobo9bo$20bo9bo9bob
o7bo3bo7bo7bo3bo5bo3bo5bo3bo9bo5bo3bo7bo7bobobo8bo$20bo9b3o7b2o8b5o7bo
7bo3bo6bobo6bo3bo9bo5b4o8bo7bobobo7bo$20bo9bo9bobo7bo3bo7bo7bo3bo7bo7b
obobo5bo3bo5bo3bo7bo7bobobo6bo$20bo3bo5bo9bo2bo6bo3bo7bo8bobo8bo7bo2bo
6bo3bo5bo3bo7bo7bobobo5bo$21b3o6b5o5bo3bo5bo3bo5b5o7bo9bo8b2obo6b3o6bo
3bo7bo8bobo6b5o4$b3o6b7o$o3bo5bo5bo$o2b2o5bo5bo$obobo5bo2bo2bo$2o2bo5b
o5bo$o3bo5bo5bo$b3o6b7o4$b2o17b7o3b7o$obo17bo5bo3bo5bo$2bo17bobo3bo3bo
2bo2bo$2bo17bo2bo2bo3bo2bo2bo$2bo17bo5bo3bo5bo$2bo17bo5bo3bo5bo$5o15b
7o3b7o4$b3o16b7o3b7o3b7o3b7o3b7o3b7o$o3bo15bo5bo3bo5bo3bo5bo3bo5bo3bo
5bo3bo5bo$4bo15bobobobo3bo2bo2bo3bobo3bo3bobo3bo3bo2bo2bo3bo3bobo$3bo
16bo2bo2bo3bob2o2bo3bo2bo2bo3bob2o2bo3bo2bo2bo3bo2bo2bo$2bo17bo5bo3bo
5bo3bo2bo2bo3bo5bo3bo2bo2bo3bobo3bo$bo18bo5bo3bo5bo3bo5bo3bo5bo3bo5bo
3bo5bo$5o15b7o3b7o3b7o3b7o3b7o3b7o4$b3o16b7o3b7o3b7o3b7o3b7o3b7o3b7o3b
7o3b7o3b7o$o3bo15bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo
3bo5bo$4bo15bobobobo3bo2bo2bo3bobo3bo3bob2o2bo3bo3bobo3bobobobo3bo2b2o
bo3bo3bobo3bo3bobo3bobobobo$2b2o16bo2bo2bo3bob2o2bo3bo2b2obo3bob2o2bo
3bo2b2obo3bob2o2bo3bo2bo2bo3bo2bo2bo3bo2b2obo3bo2bo2bo$4bo15bobo3bo3bo
2bo2bo3bo2bo2bo3bo5bo3bo3bobo3bo5bo3bo2bo2bo3bob2o2bo3bo2bo2bo3bo2bo2b
o$o3bo15bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo$b
3o16b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o4$2b2o16b7o3b7o3b7o3b7o3b7o
3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o$bobo16bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3b
o5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo$o2bo16bobobobo3bo2bo2bo
3bo2b2obo3bob3obo3bob2o2bo3bobobobo3bob2o2bo3bob2o2bo3bo3bobo3bobobobo
3bob3obo3bobo3bo3bob2o2bo$5o15bo2bo2bo3bob3obo3bob2o2bo3bob2o2bo3bo2bo
2bo3bob2o2bo3bob2o2bo3bob2o2bo3bob3obo3bo2bo2bo3bo2bo2bo3bob2o2bo3bo2b
o2bo$3bo16bobobobo3bo2bo2bo3bo3bobo3bo5bo3bob2o2bo3bobo3bo3bo2bo2bo3bo
3bobo3bo2bo2bo3bob2o2bo3bo2bo2bo3bo2b2obo3bo2b2obo$3bo16bo5bo3bo5bo3bo
5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo$3bo16b
7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o4$5o15b7o3b7o3b7o3b
7o3b7o3b7o3b7o3b7o3b7o3b7o$o19bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5b
o3bo5bo3bo5bo3bo5bo$4o16bo2bo2bo3bobobobo3bo2b2obo3bo3bobo3bob2o2bo3bo
bo3bo3bobobobo3bob2o2bo3bob2o2bo3bobobobo$4bo15bob3obo3bo2b2obo3bob2o
2bo3bo2b2obo3bob2o2bo3bob3obo3bob3obo3bob2o2bo3bob2o2bo3bob3obo$4bo15b
o2b2obo3bobobobo3bobobobo3bob3obo3bob2o2bo3bob2o2bo3bobo3bo3bo2b2obo3b
obobobo3bo2bo2bo$o3bo15bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo
3bo5bo3bo5bo$b3o16b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o3b7o4$b3o16b7o3b
7o3b7o3b7o3b7o3b7o$o3bo15bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo$o19bo2bo
2bo3bobobobo3bo2b2obo3bo2b2obo3bobobobo3bob2o2bo$4o16bob3obo3bo2b2obo
3bob3obo3bo2b2obo3bob3obo3bob3obo$o3bo15bob3obo3bob3obo3bobobobo3bob3o
bo3bobobobo3bo2b2obo$o3bo15bo5bo3bo5bo3bo5bo3bo5bo3bo5bo3bo5bo$b3o16b
7o3b7o3b7o3b7o3b7o3b7o4$5o15b7o3b7o$4bo15bo5bo3bo5bo$3bo16bo2b2obo3bob
3obo$3bo16bob3obo3bo2b2obo$2bo17bob3obo3bob3obo$2bo17bo5bo3bo5bo$2bo
17b7o3b7o4$b3o6b7o$o3bo5bo5bo$o3bo5bob3obo$b3o6bob3obo$o3bo5bob3obo$o
3bo5bo5bo$b3o6b7o!
'''


# The following function takes a rule element like B2a or B2-a and creates the appropriate ruletable row.
# Parameters:
# bs is a string with one of two values "0," to indicate birth, and "1," to indicates survival.
# totalistic_num is one character string "0" ... "8"
# notation_letter is a one character string indicating Hensel's notation "a", 
# inverse_list is a list of notation letters for inverse notation 

def create_table_row(bs,totalistic_num, notation_letter, inverse_list):
   result = ""
   if totalistic_num == "0":
     result = bs + "0,0,0,0,0,0,0,0" + ",1"+"\n"  
   elif totalistic_num == "8":
     result = bs + "1,1,1,1,1,1,1,1" + ",1" +"\n"  
   elif notation_letter != "none":
      result = bs + notationdict[totalistic_num+notation_letter] + ",1" +"\n"
   elif inverse_list != []:
      for i in notationdict: 
         if not (i[1] in inverse_list) and i.startswith(totalistic_num):
            result = result +  bs + notationdict[i] + ",1" +"\n"
   else: 
      for i in notationdict:
         if i.startswith(totalistic_num):
            result = result +  bs + notationdict[i] + ",1" + "\n"
   return result


CR = chr(13)
LF = chr(10)
pastepattern = "none"

yourclipboard = golly.getclipstr()
yourclipboard = yourclipboard.replace(CR+LF,LF)
yourclipboard = yourclipboard.replace(CR,LF)

if yourclipboard.startswith("#r "):
  rulestring = yourclipboard.split(" ")[1].split("\n")[0]
  pastepattern = yourclipboard.split("#r "+rulestring)[1] 
else:
  rulestring = golly.getstring(dialog_box_message, "B2a/S12") 


# The following code cleans up the rulestring
# so that it makes a valid and somewhat readable file name - eg "B2-a_S12.table"

rulestring = rulestring.replace(" ", "")
rulestring = rulestring.lower()
rulestring = rulestring.replace("b", "B")
rulestring = rulestring.replace("s", "S")

# The variable named rulestring will be parsed.  
# The variable named rule_name will be the name of the new file.
# Valid rules contain a slash character but filenames can not include slashes.

rule_name = rulestring.replace("/", "_")  

# To do:  Allow the user to specify their own name for a rule.

#  The following code cleans up the rule string to 
#  make life easier for the parser.

if rulestring.startswith("B") or rulestring.startswith("S"):
    rulestring = rulestring.replace("/", "")
else:
    rulestring = rulestring.replace("/", "B")

rulestring = rulestring + "\n"  

# Lets make a new file

f = open(golly.getdir("rules")+rule_name+".table", "w")

# Now create the header for the rule table

neighborhood = "Moore"  
# Incorporate Paul Callahan's hexagonal non-totaistic notation next?
f.write("neighborhood:"+neighborhood+"\n")

# The next line is where the magic happens! 
f.write("symmetries:rotate4reflect\n") 


# Lets stick with 2 states for now, but it would be interesting 
# to add generations-style decay states, as MCell's Weighted Life does.

n_states = 2   
f.write("n_states:"+str(n_states)+"\n\n")

f.write("""
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}

""")

# Now that the header for the rule table has been created, 
# parse the rulestring, and add rows to the ruletable as we go.

# Lets say rule strings contain "rule elements", such as B2i, or B2-a, which are composed of: 
# 1) a birth or survival flag 
# 2) a "totalistic context" consisting of an integer between zero and 8
# 3) a "notation_letter".   
# 4) a flag for "positive" or "inverse" notation

bs = "1,"                        # Use "1," for survival or "0," for birth
totalistic_context = "none"      # "none" will be replaced with "0" through
                                 # "8" by the parser.
last_totalistic_context = "none" # Lets the parser remember the previous  
                                 # integer it encountered.
notation_letter = "none"         # "none","a", "e", "i", etc.
positive_or_inverse = "positive" 
inverse_list = []

for x in rulestring:
  if x == "S" or x == "B" or x.isdigit() or x == "\n":
     last_totalistic_context = totalistic_context   
     totalistic_context = x                         
     if last_totalistic_context != "none"  and notation_letter == "none":
         f.write(create_table_row(bs, last_totalistic_context, "none",[]))             
     if last_totalistic_context != "none" and  positive_or_inverse == "inverse":
         f.write(create_table_row(bs, last_totalistic_context, "none", inverse_list))  
     # Now lets get ready to move on to the next character.
     notation_letter = "none"
     inverse_list = []
     positive_or_inverse = "positive"
     if x == "S" or x == "B":
         totalistic_context = "none"
     if x == "S":
         bs = "1,"
     if x == "B": 
         bs = "0,"
  elif x == "-":
    positive_or_inverse = "inverse"
  elif x in ["c", "a", "e", "k", "i", "v", "j", "y", "q", "r", "w", "t", "z"] and totalistic_context != "none":
     if positive_or_inverse == "positive":
        notation_letter = x
        f.write(create_table_row(bs, totalistic_context, notation_letter, []))    
     else:
        notation_letter = x
        inverse_list.append(x) 


f.write("# Death otherwise"+"\n")
f.write("1,a,b,c,d,e,f,g,h,0"+"\n\n")
f.flush()
f.close()
golly.setalgo("RuleTable")
golly.setrule(rule_name)
if pastepattern != "none":
  golly.setclipstr(pastepattern)
  golly.show("Paste the pattern when you are ready....")
else:
  golly.show("Created "+rule_name+".table in "+golly.getdir("rules"))

wildmyron
Posts: 1542
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: Rule request thread

Post by wildmyron » July 17th, 2018, 4:29 am

Goldtiger997 wrote:
dvgrn wrote:Does anyone have the code for writing two-state Life-like rules as rule tables, lying around somewhere? There seem to be rule tables showing up that look like they're generated by this kind of script, but I don't know where the code is offhand.
Well I have this one by EricG which works for all isotropic rules, so it should work for two-state Life-like rules:

<snip script>
That's overkill for asynchronous versions of Life-Like rules, but isotropic versions may well be of interest too.
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by AforAmpere. The latest collection is hosted on GitHub and contains well over 1,000,000 spaceships.

Semi-active here - recovering from a severe case of LWTDS.

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » July 17th, 2018, 8:38 am

Nice work! So now the only remaining detail is to adapt EricG's script to write out a rule table for an arbitrary rule, using variables instead of 0's and 1's, and then switch to that rule.

Some good code to borrow to get the rule file placed in the right place might be simsim314's LifeHistory2Life.py script.

Sure is hard to see Conway's Life in that rule's behavior, except that still lifes are all the same.

Caenbe
Posts: 52
Joined: September 20th, 2016, 4:24 pm
Location: USA

Re: Rule request thread

Post by Caenbe » July 17th, 2018, 6:24 pm

wildmyron wrote:Does this match the behaviour you were hoping for?
I don't know. The script is giving me errors. The first one was from one of the comments, so I deleted all the comments, and now I'm getting an error from the "local g = golly()" thing.

But, just from looking at the script, I'm unsure about this part:
wildmyron wrote: state = 2 + 2 * ( 2*(row % 2) + (col % 2) )
setcell(col, row, state - getcell(col, row))
It looks it's going to cause the update order to be off. I mentioned earlier
Caenbe wrote:the locations of the cells that are updated alternately shift horizontally and vertically.
This looks like it's going to alternate between shifting horizontally and diagonally. I think it should be:
state = 2 + 2 * ( 2*(row % 2) + ((row + col) % 2) )
setcell(col, row, state - getcell(col, row))
Music make you lose control
Music make you lose control
echo "print(10**10**5//~-10**1000//9801)" | python | aplay

User avatar
dvgrn
Moderator
Posts: 10610
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Rule request thread

Post by dvgrn » July 17th, 2018, 7:15 pm

Caenbe wrote:I don't know. The script is giving me errors. The first one was from one of the comments, so I deleted all the comments, and now I'm getting an error from the "local g = golly()" thing.
How are you trying to run that script, exactly? That one is in Lua, but Golly ordinarily figures out automatically if the script is Lua or Python. So the only way I can think that you'd get an error from "local g = golly()" (or those comments) would be if you're opening a Python command line, or trying to run the script via IDLE, something like that (?).

-- Or if you're running a version of Golly before 3.0. If you're doing that, then please either upgrade to Golly 3.x, or learn how to back-port Lua scripts to Python. Golly 2.x doesn't support Lua scripts.

EDIT: Or possibly if you saved the file with a .py extension... yes, aha, that does fake Golly out. Rename it to something.lua and try it again.

EDIT2: Oh, good -- problem solved.

Really, for the scripts above, or most Golly scripts, the quickest way to try them out is to copy them to the clipboard, then choose File > Run Clipboard.

Caenbe
Posts: 52
Joined: September 20th, 2016, 4:24 pm
Location: USA

Re: Rule request thread

Post by Caenbe » July 17th, 2018, 7:20 pm

dvgrn wrote:
Caenbe wrote:I don't know. The script is giving me errors. The first one was from one of the comments, so I deleted all the comments, and now I'm getting an error from the "local g = golly()" thing.
How are you trying to run that script, exactly? That one is in Lua, but Golly ordinarily figures out automatically if the script is Lua or Python. So the only way I can think that you'd get an error from "local g = golly()" (or those comments) would be if you're opening a Python command line, or trying to run the script via IDLE, something like that (?). Or if you're running a version of Golly before 3.0. If you're doing that, then please either upgrade to Golly 3.x, or learn how to back-port Lua scripts to Python. Golly 2.x doesn't support Lua scripts.

For the scripts above, or most Golly scripts, the quickest way to try them out is to copy them to the clipboard, then choose File > Run Clipboard.
Ohhhh, it's Lua. That explains it. I saved it as a .py file.
EDIT: I guess I should have mentioned, I don't have Lua yet. So, that'll be a blast to get working.
EDIT 2: Yep, thanks, just figured out Lua is already in Golly.
Last edited by Caenbe on July 18th, 2018, 8:56 am, edited 1 time in total.
Music make you lose control
Music make you lose control
echo "print(10**10**5//~-10**1000//9801)" | python | aplay

Post Reply