Prototype for 22da Soup Search
Posted: May 8th, 2014, 10:36 pm
A soup search script for 22da has been anticipated for some time, particularly because there are no known odd-period oscillators in the rule (and there are no known orthogonal spaceships in the rule, either). So here's a new soup search script that should make finding new oscillators and spaceships easier.
An unpickler script will be provided soon for those who don't want to read pickled lists.
Code: Select all
# Prototype soup search script for 22da. A pickled catalogue of data for novel objects is stored in a text file within Golly's patterns folder.
import time
import pickle
while 1 == 1: #soup search script by default goes forever
intrcttl=[(-2,-2),(-2,-1),(-2,0),(-1,-2),(-1,-1),(-1,0),(-1,1),(0,-2),(0,-1),(0,1),(0,2),(1,-1),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
pttrnlf=[]
try:
f=open(g.getdir("patterns")+"hexobj.txt","r+")
except:
f=open(g.getdir("patterns")+"hexobj.txt","w")
f.close()
try:
with open(g.getdir("patterns")+"hexobj.txt","r+") as f:
pl = pickle.load(f)
while pl:
pttrnlf=pttrnlf+[(pl[0],pl[1])]
pl = pickle.load(f)
except:
pl=0
rect=g.getrect()
if len(rect) != 0: g.clear(0)
g.select([-20,-20,40,40])
g.randfill(40)
g.run(10000)
rect=g.getrect()
cll=g.getcells(rect)
lngth = len(cll)
i=0
pttrnl=[]
while i < lngth:
if g.getcell(cll[i],cll[i+1])==1:
xinit=cll[i]
yinit=cll[i+1]
pttrntl=[(xinit,yinit)]
initpttrntl=[]
while pttrntl != initpttrntl:
initpttrntl=list(set(pttrntl))
for ct in pttrntl:
xinit1=ct[0]
yinit1=ct[1]
for nct in intrcttl:
if g.getcell(xinit1+nct[0],yinit1+nct[1]) == 1:
g.setcell(xinit1+nct[0],yinit1+nct[1],0)
pttrntl=pttrntl+[(xinit1+nct[0],yinit1+nct[1])]
pttrntl=list(set(pttrntl))
pttrntl1=range(len(pttrntl))
for j in range(len(pttrntl)):
pttrntl1[j]=(pttrntl[j][0]-xinit,pttrntl[j][1]-yinit)
pttrntl1.sort()
pttrnl+=[[len(pttrntl1),pttrntl1,(xinit,yinit)]]
i+=2
if len(pttrnl)>0:
pttrnl.sort()
ptst=1
for p in pttrnlf:
if pttrnl[0][0]==p[0] and pttrnl[0][1]==p[1]:
ptst=0
if ptst==1: pttrnl1 = [pttrnl[0]]
else: pttrnl1 = []
for i in range(1,len(pttrnl)):
if pttrnl[i][1]!=pttrnl[i-1][1]:
ptst=1
for p in pttrnlf:
if pttrnl[i][0]==p[0] and pttrnl[i][1]==p[1]:
ptst=0
if ptst==1: pttrnl1 = pttrnl1 + [pttrnl[i]]
if len(pttrnl1)>0:
f=open(g.getdir("patterns")+"hexobj.txt","a")
t=time.time()
for pttrn in pttrnl1:
pickle.dump(pttrn+[t],f)
f.close()