I was going to suggest that you give modifying nbsearch2 a go yourself - it's definitely worthwhile having enough of an understanding of programming languages to make small changes like this one. But I couldn't resist.
Code: Select all
import golly as g
import math
import random
from timeit import default_timer as timer
rule=g.getstring("Rule:","B3/S23")
algo=g.getstring("Algorithm:","QuickLife")
s=g.getstring("Symmetry","All")
symm=0
if s!="All":
symm=s
#symm can be either C1, C2_1, C2_2, C2_4, D2_x, D2_+1, D2_+2, C4_1, C4_4, D4_x1, D4_x4, D4_+1, D4_+2, D4_+4, D8_1, D8_4, All, Rot
max_period=300
result_spacing=100
stab_step=7
exclude_periods=[1]
if rule=="GlideLife":
exclude_periods=[1,2,4,6,12,16]
if rule=="olife":
exclude_periods=[1,2,3,4,5,6,9,10,12,15,18,20,26,30,35]
if rule=="B3/S23":
exclude_periods=[1,2,3,6,8,4,5,10,15,30,14]
if rule in ["tlife","B3/S2-i34q"]:
exclude_periods=[1,2,4,5,160]
if rule=="salad":
exclude_periods=[1,2,4]
if rule=="B2inkce_S12":
exclude_periods=[1,2,4]
if rule=="B3678/S235678":
exclude_periods=[1,2,3,4,6,12,8]
if rule=="MoveIt":
exclude_periods=[1,2,3,4,6,8,12,16,24,32,48]
if rule=="B35678/S357":
exclude_periods=[1,2,6,4,3,8,12,35,5,14,24,13,10,15]
if rule=="B2-aS12":
exclude_periods=[1,14,6,3,2,4,7,26,42,9,28,12,78,16,48,236,24,84,182,13,156,5,130,21,10,208,234,15,11,70,8,19]
if rule=="B2i35r_S023-a4i":
exclude_periods=[1,2,4]
if rule=="B2in3S02-in3-n":
exclude_periods=[1,4,5,8,7,6,20,12,28,2,9,16,36,10,42,72,14,56,3,40,63,30,140,45,35]
if rule=="B37/S2-i34q":
exclude_periods=[1,2,5,4,3,20]
if rule=="B3/S235e":
exclude_periods=[1,2,15,3,5,10,8,30,4,6,14,40]
if rule=="randomnn":
exclude_periods=[20,4,14,7,28,140,84]
if rule=="Rotator":
exclude_periods=[12,40,120,4,60,10,20,24,8]
if rule=="B2ein3/S13":
exclude_periods=[1,2,4,6,5,10]
if rule=="PuffLife":
exclude_periods=[1,2,4,8,3,6,16,12]
if rule=="B3-k/S2-i3-k4cen":
exclude_periods=[1,2,5,4,3]
if rule=="B34ek5ak/S2-c34iz5y":
exclude_periods=[1,2,4,6]
if rule=="B35/S2":
exclude_periods=[2,4,1,3]
if rule=="B3568/S256":
exclude_periods=[1,2,3,4,6,12,5,10,15,20,14,42]
if rule=="B356/S234i":
exclude_periods=[1,2,4,6,12]
if rule=="b2ce3aiys12aei3r":
exclude_periods=[1,2,4,6,7,8,10,12,14,15,24,26,28,29,30,58,42,62,94,126,138,170,186,202,234,266]
if rule=="B3-cnry4-acery5i/S23-a4-jknqr5y8":
exclude_periods=[1,2,36,92,4,28,12,18,8]
if rule=="B3/S23-a4eiktz":
exclude_periods=[1,2,4,5,10,78,7,14,9,36,3,6]
if rule=="B34e5e/S2-in3-y5jk":
exclude_periods=[1,2,4,10,13,26,6,3]
if rule=="B2e3-r5i8/S23-a4kz7c":
exclude_periods=[1,2,7,14,4]
if rule=="B3/S23-e4k":
exclude_periods=[1,2,4,5,6,10,98,294,14,22,12]
if rule=="B34aq5c/S135":
exclude_periods=[1,2,4,3,6,13,26,8,12,52,39]
if rule=="B2-a3/S1c23-ainr4cekn":
exclude_periods=[1,2,4,12,31,6,62,8,5,10,124,28,20]
if rule=="B2-a3-in/S23":
exclude_periods=[1,2,6,4,44,12,3,16,9,18,132,5,8,36,220,20,30,22,60]
if rule=="B2-a3-in/S235c":
exclude_periods=[1,2,4,3,6,44,12,10,20,132,16,60,5,58,8]
def osc_test():
if g.empty():
return False
testcells=g.getcells(g.getrect())
testpop=g.getpop() # String representation
testhash=g.hash(g.getrect())
for i in range(1,max_period):
g.run(1)
if g.empty():
return False
if g.getpop()==testpop and g.hash(g.getrect())==testhash:
if g.getcells(g.getrect())==testcells:
if i not in exclude_periods:
return True
else:
return False
return False
def put_symm(cell_list,x0=0,y0=0,axx=1,axy=0,ayx=0,ayy=1,mode="or"):
global symm
if s=="All":
symm=["C1", "C2_1", "C2_2", "C2_4", "D2_x", "D2_+1", "D2_+2", "C4_1", "C4_4", "D4_x1", "D4_x4", "D4_+1", "D4_+2", "D4_+4", "D8_1", "D8_4"][random.randrange(16)]
if s=="Rot":
symm=["C1", "C2_1", "C2_2", "C2_4", "C4_1", "C4_4"][random.randrange(6)]
# g.putcells(cell_list,x0,y0,axx,axy,ayx,ayy,mode)
if symm=="C2_1" or symm=="C4_1" or symm=="D4_+1" or symm=="D8_1" or symm=="D4_x1":
g.putcells(cell_list,-x0,-y0,-axx,-axy,-ayx,-ayy,mode)
if symm=="C4_1" or symm=="D8_1":
g.putcells(cell_list,y0,-x0,ayx,ayy,-axx,-axy,mode)
g.putcells(cell_list,-y0,x0,-ayx,-ayy,axx,axy,mode)
if symm=="C2_2" or symm=="D4_+2":
g.putcells(cell_list,-x0-1,-y0,-axx,-axy,-ayx,-ayy,mode)
if symm=="C2_4" or symm=="C4_4" or symm=="D4_+4" or symm=="D8_4" or symm=="D4_x4":
g.putcells(cell_list,-x0-1,-y0-1,-axx,-axy,-ayx,-ayy,mode)
if symm=="D2_+1" or symm=="D8_1" or symm=="D4_+1":
g.putcells(cell_list,-x0,y0,-axx,-axy,ayx,ayy,mode)
if symm=="D4_+1" or symm=="D8_1" or symm=="D4_+2":
g.putcells(cell_list,x0,-y0,axx,axy,-ayx,-ayy,mode)
if symm=="D2_+2" or symm=="D4_+2" or symm=="D4_+4" or symm=="D8_4":
g.putcells(cell_list,-x0-1,y0,-axx,-axy,ayx,ayy,mode)
if symm=="D4_+4" or symm=="D8_4":
g.putcells(cell_list,x0,-y0-1,axx,axy,-ayx,-ayy,mode)
if symm=="C4_4" or symm=="D8_4":
g.putcells(cell_list,y0,-x0-1,ayx,ayy,-axx,-axy,mode)
g.putcells(cell_list,-y0-1,x0,-ayx,-ayy,axx,axy,mode)
if symm=="D8_4":
g.putcells(cell_list,-y0-1,-x0-1,-ayx,-ayy,-axx,-axy,mode)
if symm=="D2_x" or symm=="D8_1" or symm=="D8_4" or symm=="D4_x1" or symm=="D4_x4":
g.putcells(cell_list,y0,x0,ayx,ayy,axx,axy,mode)
if symm=="D4_x1" or symm=="D8_1":
g.putcells(cell_list,-y0,-x0,-ayx,-ayy,-axx,-axy,mode)
if symm=="D4_x4" or symm=="D8_4":
g.putcells(cell_list,-y0-1,-x0-1,-ayx,-ayy,-axx,-axy,mode)
def clear_layer():
r = g.getrect()
if r:
g.select(r)
g.clear(0)
return
x=10
main_fill=50
def main():
g.new("RandOsc")
g.setrule(rule)
g.setalgo(algo)
g.setbase(2)
test_layer=g.getlayer()
if g.numlayers()<g.maxlayers():
results_layer=g.addlayer()
g.setname('OscResults')
g.setlayer(test_layer)
else:
resultslayer=-1
results=0
count=0
prevcount=0
t_start=timer()
t_prev=t_start
while True:
clear_layer()
g.select([0,0,x,x])
g.randfill(main_fill)
cell_list=g.getcells([0,0,x,x])
# g.clear(0)
put_symm(cell_list)
g.setstep(stab_step)
g.step()
if osc_test():
osc = g.getcells(g.getrect())
results+=1
if results_layer>=0:
g.setlayer(results_layer)
g.putcells(osc, result_spacing*results, 0)
g.setname('OscResults (%d)' % results)
g.fit()
g.update()
g.setlayer(test_layer)
else:
return True
count+=1
if count%1000==0:
t_end=timer()
g.show("%d results found after %d soups tested (%d/sec current, %d/sec overall)" % (results, count, (count-prevcount)/(t_end-t_prev), (count)/(t_end-t_start)))
g.select([])
g.update()
g.new("")
g.setbase(2)
t_prev=t_end
prevcount=count
main()
I also couldn't resist making a few performance improvements. You should see about a six-fold performance improvement for CGoL. I haven't performance tested the script with any other rules though, but I expect that they'll be similar. I also modified the base step and the excluded periods list for tlife. I haven't added any duplicate checking to this script, so it will output results similarly to nbsearch1. Abort the script with 'Esc' to view the results.