NaiveLife

For discussion of other cellular automata.
Post Reply
User avatar
gameoflifeboy
Posts: 474
Joined: January 15th, 2015, 2:08 am

NaiveLife

Post by gameoflifeboy » July 2nd, 2015, 10:49 pm

Inspired by this post, I have made a script that runs a pattern in NaiveLife for a given number of generations:

Code: Select all

import golly as g
import os

filename = g.getdir('rules') + 'NaiveLife_Emulated.rule'

contents = '''@RULE NaiveLife_Emulated
@TABLE
n_states:4
neighborhood:Moore
symmetries:none
var a = {0,1,2,3}
var b = a
var c = a
var d = a
var e = a
var f = a
var g = a
var s = {2,3}
0,a,b,c,d,e,f,s,g,2
1,a,b,c,d,e,f,s,g,3

3,1,1,0,0,0,0,0,0,1
3,1,0,1,0,0,0,0,0,1
3,1,0,0,1,0,0,0,0,1
3,1,0,0,0,1,0,0,0,1
3,1,0,0,0,0,1,0,0,1
3,1,0,0,0,0,0,1,0,1
3,1,0,0,0,0,0,0,1,1
3,0,1,1,0,0,0,0,0,1
3,0,1,0,1,0,0,0,0,1
3,0,1,0,0,1,0,0,0,1
3,0,1,0,0,0,1,0,0,1
3,0,1,0,0,0,0,1,0,1
3,0,1,0,0,0,0,0,1,1
3,0,0,1,1,0,0,0,0,1
3,0,0,1,0,1,0,0,0,1
3,0,0,1,0,0,1,0,0,1
3,0,0,1,0,0,0,1,0,1
3,0,0,1,0,0,0,0,1,1
3,0,0,0,1,1,0,0,0,1
3,0,0,0,1,0,1,0,0,1
3,0,0,0,1,0,0,1,0,1
3,0,0,0,1,0,0,0,1,1
3,0,0,0,0,1,1,0,0,1
3,0,0,0,0,1,0,1,0,1
3,0,0,0,0,1,0,0,1,1
3,0,0,0,0,0,1,1,0,1
3,0,0,0,0,0,1,0,1,1
3,0,0,0,0,0,0,1,1,1

s,1,1,1,0,0,0,0,0,1
s,1,1,0,1,0,0,0,0,1
s,1,1,0,0,1,0,0,0,1
s,1,1,0,0,0,1,0,0,1
s,1,1,0,0,0,0,1,0,1
s,1,1,0,0,0,0,0,1,1
s,1,0,1,1,0,0,0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var o = h
s,h,i,j,k,l,m,n,o,0

@COLORS
1 255 0 0
2 0 255 0
3 255 255 0'''

f = open(filename, 'w')
f.write(contents)
f.close()

def advance():
    origrule = g.getrule()
    box = g.getrect()
    if len(box) == 0:
        g.exit()
    celllist = g.transform(g.getcells(box), -box[0], -box[1])
    g.new('')
    across = box[2] + 6
    down = box[2] + box[3] + 9
    g.setrule('NaiveLife_Emulated:T' + str(across) + ',' + str(down) + '+1')
    upperx = -(across // 2)
    uppery = -(down // 2)
    g.putcells(celllist, upperx + 1, uppery + 2)
    g.setcell(upperx, uppery, 2)

    g.run(across * down)

    state = g.getcell(upperx, uppery)
    g.setcell(upperx, uppery, state - 2)
    celllist = g.getcells([upperx, uppery, across, down])
    g.new('')
    g.setrule(origrule)
    g.putcells(celllist, box[0] - upperx - 1, box[1] - uppery - 2)

numgens = int(g.getstring("How many gens do you want to run in NaiveLife?", '1'))
for gen in xrange(numgens):
    advance()
    g.show("Advanced %d out of %d generations." % (gen + 1, numgens))
The rule this implements is also fun to play with on its own. For example, running a pattern in a 10x10 torus with shift 1 long enough usually eventually becomes a stable agar:

Code: Select all

x = 7, y = 7, rule = NaiveLife_Emulated:T10,10+1
B4$4.2A$3.2A.A$4.A!

User avatar
calcyman
Moderator
Posts: 2932
Joined: June 1st, 2009, 4:32 pm

Re: NaiveLife

Post by calcyman » November 18th, 2018, 11:39 pm

Nicely done! Here's the original NaiveLife spaceship:

Code: Select all

x = 9, y = 20, rule = NaiveLife_Emulated:T64,64+1
4.2A$6.A$5.2A$6.2A2$5.A.A$5.A.2A$6.3A$7.2A11$B!
What do you do with ill crystallographers? Take them to the mono-clinic!

Post Reply