Yep, have read the thread, it was difficult for me to find the correct spltter in it. (BTW: this collection contans nonpsmakables as well)
The reaction envelope is not what is easy to use in sorting so pattern files are helpfull, but some types of sorting could be helpfull.
... 90turners by the 8phase (we do not mind timing too much)
... 0, 180 turners by line difference
... paralel splitters by line difference
but I agree searching for cheap perp splitter with correct output phases was not easy ... when I have timing criteria in the pattern file incorporated and was lazy to create pattern file ignoring it.
The text files are good for automated searching.
Here is what could be augmented for speialised search when other criterias are important (e.a. ignoring timing):
Code: Select all
--#cheap p2 clusters ... with expected cost
--max bb+cost deepening ... depthprev=depth, depth=depthprev+3
--#put first one in each (16) orentation+phase to origin check unique bb and hash (continue if match)
--if bb+cost > depth continue (width+height+cost)
-- #if bb+cost in range test lines an classify
-- #minx, miny, maxx, maxy
-- #for othercsluster
-- #for each oriention check unique bb and hash of the other piece
-- #check bb range for x coordinate
-- #for x in range check bb yrange
-- #for y in yrange
-- #put other, check p2, check bb,hash unique
-- #test lines and classify
--#output classification rles
--#increase depth (while there is an empty cathegory)
--#classify ... updates rle.txt cost, degrees, colors, phases, parallel output lines distance, parallel input, output line distances (0 deg first, 180 deg last)
--#rles upto bbcost ordered by cost with glidercnt, degree, colors, phases filteres (with prefix filtering (glidercnt filter, degree filter, degreecolor filter, degreecolorphase filter))
local g = golly()
local smallobj = {}
local glider = g.parse("2o$obo$o!")
g.autoupdate(true)
g.setalgo('HashLife')
g.setrule("Life")
g.setoption("savexrle", 0)
local function inttostring(num)
return string.sub(num, 1, string.find(num .. ".", "%.") - 1)
end
local outFiles = {}
local outputs = {}
local function classify_numgliders(cost, rlestr)
g.new("classify_numgliders")
g.setrule("Life")
g.setbase(2)
g.putcells(g.parse(rlestr))
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
return
end
local gliderCnt = pop0 / 5
local patt1 = g.getcells(rect1)
while (rect1[1] - rect0[1]) % 16 ~= 0 or (rect1[2] - rect0[2]) % 16 ~= 0 or (rect1[3] - rect0[3]) % 16 ~= 0 or (rect1[4] - rect0[4]) % 16 ~= 0 or rect1[1] - rect0[1] == 0 or rect1[2] - rect0[2] == 0 do
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
return
end
patt1, patt0 = g.getcells(rect1), patt1
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "or")
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "xor")
local pop2 = 0 + g.getpop()
if pop2 ~= pop1 then
--I do not expect glider histories would intersect ... I would miss these cases
return
end
end
if not outFiles[gliderCnt] then
while #outFiles < gliderCnt do
outFiles[1 + #outFiles] = io.open("c:\\golly\\Patterns\\Splitters\\" .. inttostring(1 + #outFiles) .. "splitters.txt", "w")
end
end
local o = outFiles[gliderCnt]
o:write(cost .. ";" .. rlestr .. "\n")
end
local function classify_turner_dirs(cost, rlestr)
g.new("classify_turner_dirs")
g.setrule("Life")
g.setbase(2)
g.putcells(g.parse(rlestr))
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
return
end
local gliderCnt = pop0 / 5
local patt1 = g.getcells(rect1)
while rect0[3] ~= 3 or rect0[4] ~= 3 do
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
return
end
patt1, patt0 = g.getcells(rect1), patt1
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "or")
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "xor")
local pop2 = 0 + g.getpop()
if pop2 ~= pop1 then
--I do not expect glider histories would intersect ... I would miss these cases
return
end
end
local deg = ((rect0[2] < rect1[2]) and 1 or -1)
local fileNo = 1 + ((deg + 1) * 3 - ((rect0[1] < rect1[1]) and 2 or 0) * deg) // 2
local o = outFiles[fileNo]
o:write(cost .. ";" .. rlestr .. "\n")
end
local function locate_start_glider(rlestr)
local patt=g.parse(rlestr)
local maxxpy,x,y=-99999,-99999,-99999
local step = 2+(#patt%2)
for i=1,#patt-1,step do
local xpy=patt[i+1]+patt[i]
if maxxpy<xpy then
x,y,maxxpy = patt[i],patt[i+1],xpy
end
end
return x-2,y-1
end
local function classify_turner(cost, rlestr, dirsignx, dirsigny)
g.new("classify_turner")
g.setrule("Life")
g.setbase(2)
local startx,starty=locate_start_glider(rlestr)
local patt = g.parse(rlestr, -startx, -starty)
g.putcells(patt)
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
--g.note("positioned!")
g.setstep(0)
g.step()
g.putcells(patt, 0, 0, 1, 0, 0, 1, "xor")
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
local period = (0 + g.getpop() == 0) and 1 or 2
g.new("classify_turner")
g.setbase(2)
g.putcells(patt)
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
g.note("A")
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
g.note("B")
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("C")
return
end
local gliderCnt = pop0 / 5
if gliderCnt ~= 1 then
g.note("glidercount")
return
end
local patt1 = g.getcells(rect1)
while rect0[3] ~= 3 or rect0[4] ~= 3 do
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
g.note("D")
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("E")
return
end
patt1, patt0 = g.getcells(rect1), patt1
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "or")
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "xor")
local pop2 = 0 + g.getpop()
if pop2 ~= pop1 then
g.note("F")
--I do not expect glider histories would intersect ... I would miss these cases
return
end
end
if ((rect0[2] - rect1[2]) * dirsigny < 0) or ((rect0[1] - rect1[1]) * dirsignx < 0) then
g.note("G")
return
end
local phase, gen, x0, y0 = -1, 0 + g.getgen()
if g.getcell(rect1[1] + 1 + dirsignx, rect1[2] + 1) == 1 then
phase = 0
x0, y0 = rect1[1] + dirsignx * (gen // 4), rect1[2] + dirsigny * (gen // 4)
elseif g.getcell(rect1[1] + 1 - dirsignx, rect1[2] + 1 + dirsigny) == 1 then
phase = 3
x0, y0 = rect1[1] + dirsignx * (1 + (gen // 4)), rect1[2] + dirsigny * (1 + (gen // 4))
end
if g.getcell(rect1[1] + 1, rect1[2] + 1 + dirsigny) == 1 then
phase = 2
x0, y0 = rect1[1] + dirsignx * (1 + (gen // 4)), rect1[2] + dirsigny * (gen // 4)
elseif g.getcell(rect1[1] + 1 + dirsignx, rect1[2] + 1 - dirsigny) == 1 then
phase = 1
x0, y0 = rect1[1] + dirsignx * (1 + (gen // 4)), rect1[2] + dirsigny * (gen // 4)
end
local xpyshift, ymxshift = x0 + y0, y0 - x0
local critery1,critery2,critery1txt,critery2txt
if dirsignx+dirsigny==2 then
critery1,critery2 = ymxshift,2*xpyshift-phase
critery1txt,critery2txt="lineshift=","delay="
elseif dirsignx+dirsigny==-2 then
critery1,critery2 = ymxshift,(4*y0+phase) % 8
critery1txt,critery2txt="lineshift=","ph%8="
elseif dirsigny==1 then
critery1,critery2 = (ymxshift%2),4*y0-phase
critery1 = (critery1*8)+(critery2%8)
critery1txt,critery2txt="colorchange*8+ydelay%8=","ydelay="
else
critery1,critery2 = (ymxshift%2),4*x0-phase
critery1 = (critery1*8)+(critery2%8)
critery1txt,critery2txt="colorchange*8+xdelay%8=","xdelay="
end
outputs[1+#outputs]={critery1,critery2,cost,cost .. ";"..critery1txt..critery1..";"..critery2txt..critery2..";y-x=" .. ymxshift .. ";x+y=" .. xpyshift .. ";x0=" .. x0 .. ";y0=" .. y0 .. ";p" .. period .. ";ph%4=" .. phase .. ";" .. rlestr}
end
local function classify_2splitter_dirs(cost, rlestr)
g.new("classify_2splitter_dirs")
g.setrule("Life")
g.setbase(2)
g.putcells(g.parse(rlestr))
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
g.note("A")
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
g.note("B")
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("C")
return
end
local gliderCnt = pop0 / 5
if gliderCnt ~= 2 then
g.note("gliderCnt")
return
end
local patt1 = g.getcells(rect1)
while (rect1[1] - rect0[1]) % 16 ~= 0 or (rect1[2] - rect0[2]) % 16 ~= 0 or (rect1[3] - rect0[3]) % 16 ~= 0 or (rect1[4] - rect0[4]) % 16 ~= 0 or rect1[1] - rect0[1] == 0 or rect1[2] - rect0[2] == 0 do
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
return
end
patt1, patt0 = g.getcells(rect1), patt1
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "or")
g.putcells(patt0, 0, 0, 1, 0, 0, 1, "xor")
local pop2 = 0 + g.getpop()
if pop2 ~= pop1 then
--I do not expect glider histories would intersect ... I would miss these cases
return
end
end
local degx = (((rect1[3]-rect0[3]) == 0) and 1 or 0)*(rect1[1]-rect0[1]<0 and 1 or -1)
local degy = (((rect1[4]-rect0[4]) == 0) and 1 or 0)*(rect1[2]-rect0[2]<0 and 1 or -1)
local fileNo
if degx*degx+degy*degy==2 then
--paralel outputs
if degx>0 then
if degy>0 then
fileNo = 1
else
fileNo = 4
end
else --degx
if degy>0 then
fileNo = 2
else
fileNo= 3
end
end --degx
elseif degx*degx+degy*degy==1 then
--perpendicullar outputs
if degx==0 then
if degy>0 then
--up
fileNo = 5
else
--down
fileNo= 7
end
else --degx
if degx>0 then
fileNo= 8
--left
else
fileNo = 6
--right
end
end
else
--0_180 or 90_270
if g.getcell(rect1[1], rect1[2]+1)==1 then
fileNo= 9 --0_180
else
fileNo = 10 --90_270
end
end
--g.show("FileNo "..fileNo)
local o=outFiles[fileNo]
o:write(cost..";"..rlestr.."\n")
end
local function classify_2splittersParallel(cost, rlestr, dirsignx, dirsigny)
g.new("classify_2splittersParallel")
g.setrule("Life")
g.setbase(2)
local startx, starty = locate_start_glider(rlestr)
g.putcells(g.parse(rlestr), -startx, -starty)
local patt = g.getcells(g.getrect())
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
--g.note("positioned!")
g.setstep(0)
g.step()
g.putcells(patt, 0, 0, 1, 0, 0, 1, "xor")
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
local period = (0 + g.getpop() == 0) and 1 or 2
g.new("classify_2splittersParallel")
g.setbase(2)
g.putcells(patt)
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
g.note("A")
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
g.note("B")
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("C")
return
end
local gliderCnt = pop0 / 5
if gliderCnt ~= 2 then
g.note("glidercount")
return
end
local patt1 = g.getcells(rect1)
while rect1[3] - rect0[3] ~= 0 or rect1[4] - rect0[4] ~= 0 do
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
g.note("D")
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("E")
return
end
end
if ((rect0[2] - rect1[2]) * dirsigny < 0) or ((rect0[1] - rect1[1]) * dirsignx < 0) then
g.note("G")
return
end
local gc,gs,gp,gd={},{},{},{}
local frontx,fronty,backx,backy=rect1[1]+((1-dirsignx)//2)*(rect1[3]-1),rect1[2]+((1-dirsigny)//2)*(rect1[4]-1),rect1[1]+((1+dirsignx)//2)*(rect1[3]-1),rect1[2]+((1+dirsigny)//2)*(rect1[4]-1)
g.show("f={"..frontx..","..fronty.."},b={"..backx..","..backy.."}")
if g.getcell(frontx + dirsignx,fronty)==1 and g.getcell(frontx,fronty + dirsigny)==1 then
gc[1+#gc] = {frontx + dirsignx, fronty + dirsigny}
gc[1+#gc] = {backx - dirsignx, backy - dirsigny}
else
gc[1+#gc] = {frontx + dirsignx, backy - dirsigny}
gc[1+#gc] = {backx - dirsignx, fronty + dirsigny}
end
local gen = 0 + g.getgen()
for i=1,#gc do
gd[i] = ((dirsigny>0) and "N" or "S")..((dirsignx>0) and "W" or "E")
if g.getcell(gc[i][1] + dirsignx, gc[i][2]) == 1 then
gp[i],gs[i] = 0,{gc[i][1] - 1 + dirsignx * (gen // 4), gc[i][2] - 1 + dirsigny * (gen // 4)}
elseif g.getcell(gc[i][1] - dirsignx, gc[i][2] + dirsigny) == 1 then
gp[i],gs[i] = 3,{gc[i][1] - 1 + dirsignx * (1 + (gen // 4)), gc[i][2] - 1 + dirsigny * (1 + (gen // 4))}
end
if g.getcell(gc[i][1], gc[i][2] + dirsigny) == 1 then
gp[i],gs[i] = 2,{gc[i][1] -1 + dirsignx * (1 + (gen // 4)), gc[i][2] - 1 + dirsigny * (gen // 4)}
elseif g.getcell(gc[i][1] + dirsignx, gc[i][2] - dirsigny) == 1 then
gp[i],gs[i] = 1,{gc[i][1] - 1 + dirsignx * (1 + (gen // 4)), gc[i][2] - 1 + dirsigny * (gen // 4)}
end
end
g.show("f={"..frontx..","..fronty.."},b={"..backx..","..backy.."},gc={{"..gc[1][1]..","..gc[1][2].."},{"..gc[2][1]..","..gc[2][2].."}}"..(gp[1] or "n")..(gp[2] or "n")..gd[1]..gd[2])
--g.note((gp[1] or "n")..gp[2] or "n")
g.show("gc={{"..gc[1][1]..","..gc[1][2].."},{"..gc[2][1]..","..gc[2][2].."}} gp={"..gp[1]..","..gp[2].."} gs={{"..gs[1][1]..","..gs[1][2].."},{"..gs[2][1]..","..gs[2][2].."}}, gd={"..gd[1]..","..gd[2].."}")
local xdelta, ydelta = gs[2][1] - gs[1][1], gs[2][2] - gs[1][2]
local xpydelta, ymxdelta = xdelta + ydelta, ydelta - xdelta
local linedist,delay
if dirsignx+dirsigny~=0 then --0/180
linedist,delay=ymxdelta,2*xpydelta+(gp[1]-gp[2])*dirsigny
else
linedist,delay=xpydelta,2*ymxdelta+(gp[1]-gp[2])*dirsigny
end
if delay<0 then
linedist,delay=-linedist,-delay
end
outputs[1+#outputs]={linedist,delay,cost,cost .. ";linedist=" .. linedist .. ";delay=" .. delay ..
";x0="..gs[1][1]..";y0="..gs[1][2]..";ph0%4="..gp[1]..";"..gd[1]..";x1="..gs[2][1]..";y1="..gs[2][2]..";ph1%4="..gp[2]..";" .. gd[2]..";p"..period..";".. rlestr}
end
local function classify_2splittersOpposite(cost, rlestr, dirsignx, dirsigny)
g.new("classify_2splittersOpposite")
g.setrule("Life")
g.setbase(2)
local startx, starty = locate_start_glider(rlestr)
g.putcells(g.parse(rlestr), -startx, -starty)
local patt = g.getcells(g.getrect())
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
--g.note("positioned!")
g.setstep(0)
g.step()
g.putcells(patt, 0, 0, 1, 0, 0, 1, "xor")
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
local period = (0 + g.getpop() == 0) and 1 or 2
g.new("classify_2splittersOpposite")
g.setbase(2)
g.putcells(patt)
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
g.note("A")
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
g.note("B")
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("C")
return
end
local gliderCnt = pop0 / 5
if gliderCnt ~= 2 then
g.note("glidercount")
return
end
local patt1 = g.getcells(rect1)
while rect1[3] - rect0[3] ~= 32 or rect1[4] - rect0[4] ~= 32 do
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
g.note("D")
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("E")
return
end
end
local gc,gs,gp,gd={},{},{},{}
local frontx,fronty,backx,backy=rect1[1]+((1-dirsignx)//2)*(rect1[3]-1),rect1[2]+((1-dirsigny)//2)*(rect1[4]-1),rect1[1]+((1+dirsignx)//2)*(rect1[3]-1),rect1[2]+((1+dirsigny)//2)*(rect1[4]-1)
g.show("f={"..frontx..","..fronty.."},b={"..backx..","..backy.."}")
gc[1+#gc] = {frontx + dirsignx, fronty + dirsigny}
gc[1+#gc] = {backx - dirsignx, backy - dirsigny}
local gen = 0 + g.getgen()
for i=1,#gc do
gd[i] = ((dirsigny>0) and "N" or "S")..((dirsignx>0) and "W" or "E")
if g.getcell(gc[i][1] + dirsignx, gc[i][2]) == 1 then
gp[i],gs[i] = 0,{gc[i][1] - 1 + dirsignx * (gen // 4), gc[i][2] - 1 + dirsigny * (gen // 4)}
elseif g.getcell(gc[i][1] - dirsignx, gc[i][2] + dirsigny) == 1 then
gp[i],gs[i] = 3,{gc[i][1] - 1 + dirsignx * (1 + (gen // 4)), gc[i][2] - 1 + dirsigny * (1 + (gen // 4))}
end
if g.getcell(gc[i][1], gc[i][2] + dirsigny) == 1 then
gp[i],gs[i] = 2,{gc[i][1] -1 + dirsignx * (1 + (gen // 4)), gc[i][2] - 1 + dirsigny * (gen // 4)}
elseif g.getcell(gc[i][1] + dirsignx, gc[i][2] - dirsigny) == 1 then
gp[i],gs[i] = 1,{gc[i][1] - 1 + dirsignx * (1 + (gen // 4)), gc[i][2] - 1 + dirsigny * (gen // 4)}
end
dirsignx,dirsigny=-dirsignx,-dirsigny --flipping twice, the other glider has opposite direction
end
g.show("f={"..frontx..","..fronty.."},b={"..backx..","..backy.."},gc={{"..gc[1][1]..","..gc[1][2].."},{"..gc[2][1]..","..gc[2][2].."}}"..(gp[1] or "n")..(gp[2] or "n")..gd[1]..gd[2])
--g.note((gp[1] or "n")..gp[2] or "n")
g.show("gc={{"..gc[1][1]..","..gc[1][2].."},{"..gc[2][1]..","..gc[2][2].."}} gp={"..gp[1]..","..gp[2].."} gs={{"..gs[1][1]..","..gs[1][2].."},{"..gs[2][1]..","..gs[2][2].."}}..gd={"..gd[1]..","..gd[2].."}")
local xdelta, ydelta = gs[2][1] - gs[1][1], gs[2][2] - gs[1][2]
local xpydelta, ymxdelta = xdelta + ydelta, ydelta - xdelta
local linedist,delaymod8
if dirsignx+dirsigny~=0 then --0/180
linedist,delaymod8=ymxdelta,(2*xpydelta+(gp[1]+gp[2]))%8
else
linedist,delaymod8=xpydelta,(2*ymxdelta+(gp[1]+gp[2]))%8
end
outputs[1+#outputs]={linedist,delaymod8,cost,cost .. ";linedist=" .. linedist .. ";delaymod8=" .. delaymod8 ..
";x0="..gs[1][1]..";y0="..gs[1][2]..";ph0%4="..gp[1]..";"..gd[1]..";x1="..gs[2][1]..";y1="..gs[2][2]..";ph1%4="..gp[2]..";" .. gd[2]..";p"..period..";".. rlestr}
end
local function classify_2splittersPerp(cost, rlestr, dirsignx, dirsigny)
g.new("classify_2splittersPerp")
g.setrule("Life")
g.setbase(2)
local startx, starty = locate_start_glider(rlestr)
g.putcells(g.parse(rlestr), -startx, -starty)
local patt = g.getcells(g.getrect())
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
--g.note("positioned!")
g.setstep(0)
g.step()
g.putcells(patt, 0, 0, 1, 0, 0, 1, "xor")
g.putcells(glider, 0, 0, 1, 0, 0, 1, "xor")
local period = (0 + g.getpop() == 0) and 1 or 2
g.new("classify_2splittersPerp")
g.setbase(2)
g.putcells(patt)
g.setstep(10)
g.step()
g.setstep(6)
local rect0 = g.getrect()
local pop0 = 0 + g.getpop()
if pop0 % 5 ~= 0 or pop0 == 0 then
g.note("A")
return
end
local patt0 = g.getcells(rect0)
g.step()
local rect1 = g.getrect()
if not rect1 then
g.note("B")
return
end
local pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("C")
return
end
local gliderCnt = pop0 / 5
if gliderCnt ~= 2 then
g.note("glidercount")
return
end
local patt1 = g.getcells(rect1)
while (rect1[3] - rect0[3])~=32*dirsigny*dirsigny or (rect1[4] - rect0[4])~=32*dirsignx*dirsignx do
g.note((rect1[3] - rect0[3]).." "..(rect1[4] - rect0[4]).." "..dirsignx.." "..dirsigny)
g.step()
g.update()
rect1, rect0 = g.getrect(), rect1
if not rect1 then
g.note("D")
return
end
pop1 = 0 + g.getpop()
if pop1 ~= pop0 then
g.note("E")
return
end
end
local gc,gs,gp,gd={},{},{},{}
local dirx,diry=dirsignx+dirsigny*dirsigny,dirsigny+dirsignx*dirsignx
local frontx,fronty,backx,backy=rect1[1]+((1-dirx)//2)*(rect1[3]-1),rect1[2]+((1-diry)//2)*(rect1[4]-1),rect1[1]+((1+dirx)//2)*(rect1[3]-1),rect1[2]+((1+diry)//2)*(rect1[4]-1)
g.show("f={"..frontx..","..fronty.."},b={"..backx..","..backy.."}")
if g.getcell(frontx + dirx,fronty)~=1 or g.getcell(frontx,fronty + diry)~=1 then
dirx,diry=dirsignx-dirsigny*dirsigny,dirsigny-dirsignx*dirsignx
frontx,fronty,backx,backy=rect1[1]+((1-dirx)//2)*(rect1[3]-1),rect1[2]+((1-diry)//2)*(rect1[4]-1),rect1[1]+((1+dirx)//2)*(rect1[3]-1),rect1[2]+((1+diry)//2)*(rect1[4]-1)
end
gc[1+#gc] = {frontx + dirx, fronty + diry}
gc[1+#gc] = {backx - dirx, backy - diry} -- perp direction
local gen = 0 + g.getgen()
for i=1,#gc do
gd[i] = ((diry>0) and "N" or "S")..((dirx>0) and "W" or "E")
if g.getcell(gc[i][1] + dirx, gc[i][2]) == 1 then
gp[i],gs[i] = 0,{gc[i][1] - 1 + dirx * (gen // 4), gc[i][2] - 1 + diry * (gen // 4)}
elseif g.getcell(gc[i][1] - dirx, gc[i][2] + diry) == 1 then
gp[i],gs[i] = 3,{gc[i][1] - 1 + dirx * (1 + (gen // 4)), gc[i][2] - 1 + diry * (1 + (gen // 4))}
end
if g.getcell(gc[i][1], gc[i][2] + diry) == 1 then
gp[i],gs[i] = 2,{gc[i][1] -1 + dirx * (1 + (gen // 4)), gc[i][2] - 1 + diry * (gen // 4)}
elseif g.getcell(gc[i][1] + dirx, gc[i][2] - diry) == 1 then
gp[i],gs[i] = 1,{gc[i][1] - 1 + dirx * (1 + (gen // 4)), gc[i][2] - 1 + diry * (gen // 4)}
end
dirx,diry=dirx*(1-2*dirsigny*dirsigny),diry*(1-2*dirsignx*dirsignx) --the perp dir
end
local order
g.show("f={"..frontx..","..fronty.."},b={"..backx..","..backy.."},gc={{"..gc[1][1]..","..gc[1][2].."},{"..gc[2][1]..","..gc[2][2].."}}"..(gp[1] or "n")..gd[1]..(gp[2] or "n")..gd[2]..dirsignx..dirsigny..dirx..diry)
--g.note((gp[1] or "n")..gp[2] or "n")
g.show("gc={{"..gc[1][1]..","..gc[1][2].."},{"..gc[2][1]..","..gc[2][2].."}} gp={"..gp[1]..","..gp[2].."} gs={{"..gs[1][1]..","..gs[1][2].."},{"..gs[2][1]..","..gs[2][2].."}} gd={"..gd[1]..","..gd[2].."}")
local xdelta, ydelta = gs[2][1] - gs[1][1], gs[2][2] - gs[1][2]
--local xpydelta, ymxdelta = xdelta + ydelta, ydelta - xdelta
--local linedist,delay
local criteria1,criteria2,criteria1txt,criteria2txt
if dirsignx~=0 then --horizontal
criteria1,criteria2=8*((xdelta+ydelta)%2)+(4*(xdelta%2)+gp[2]-gp[1])%8,xdelta
criteria2txt,criteria1txt="deltax=","8*colordif+phasedif="
else
criteria1,criteria2=8*((xdelta+ydelta)%2)+(4*(ydelta%2)+gp[2]-gp[1])%8,ydelta
criteria2txt,criteria1txt="deltay=","8*colordif+phasedif="
end
outputs[1+#outputs]={criteria1,criteria2,cost,cost .. ";" .. criteria1txt .. criteria1 .. ";" .. criteria2txt .. criteria2 ..
";x0="..gs[1][1]..";y0="..gs[1][2]..";ph0%4="..gp[1]..";"..gd[1]..";x1="..gs[2][1]..";y1="..gs[2][2]..";ph1%4="..gp[2]..";"..gd[2]..";p"..period..";".. rlestr}
end
local function process_txtfile(basefilename, phase, dirsignx, dirsigny)
g.show(basefilename)
--g.note(basefilename)
local i = io.open("c:\\golly\\Patterns\\Splitters\\" .. basefilename .. ".txt", "r")
local inputline = i:read()
while inputline do
local seppos = string.find(inputline, "%;")
local cost, rle = 0 + string.sub(inputline, 1, seppos - 1), string.sub(inputline, seppos + 1)
if phase==0 then
classify_numgliders(cost,rle)
elseif phase==1 then
classify_turner_dirs(cost,rle)
elseif phase==2 then
classify_turner(cost,rle,dirsignx,dirsigny)
elseif phase==3 then
classify_2splitter_dirs(cost, rle)
elseif phase==4 then
classify_2splittersParallel(cost,rle,dirsignx,dirsigny)
elseif phase==5 then
classify_2splittersOpposite(cost,rle,dirsignx,dirsigny)
elseif phase==6 then
classify_2splittersPerp(cost,rle,dirsignx,dirsigny)
end
inputline = i:read()
end
i:close()
end
local function process_files(maxlevel)
outFiles[1 + #outFiles] = io.open("c:\\golly\\Patterns\\Splitters\\turners.txt", "w")
for i =10, maxlevel, 2 do
process_txtfile("ships_" .. inttostring(i), 0)
end
for i = 1, #outFiles do
outFiles[i]:close()
end
end
local dirs = { { "0", 1, 1 }, { "90", -1, 1 }, { "180", -1, -1 }, { "270", 1, -1 } }
local function process_turners()
outFiles={io.open("c:\\golly\\Patterns\\Splitters\\0_turners.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\90_turners.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\180_turners.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\270_turners.txt", "w"),
}
process_txtfile("turners",1)
for i = 1, #outFiles do
outFiles[i]:close()
end
for i = 1, #dirs do
local dir, dirsignx, dirsigny = dirs[i][1], dirs[i][2], dirs[i][3]
outputs={}
process_txtfile(dir.."_turners", 2, dirsignx, dirsigny)
local o = io.open("c:\\golly\\Patterns\\Splitters\\" .. dir .. "__turners.txt", "w")
--there must be no dupicates
table.sort(outputs, function (k1, k2) for i=1,4 do if k1[i]~=k2[i] then return k1[i]<k2[i] end end end)
for i=1,#outputs do
o:write(outputs[i][4] .. "\n")
end
o:close()
outputs={}
end
end
local function process_2splitters()
outFiles={io.open("c:\\golly\\Patterns\\Splitters\\2_0_0_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_90_90_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_180_180_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_270_270_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_0_90_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_90_180_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_180_270_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_0_270_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_0_180_splitters.txt", "w"),
io.open("c:\\golly\\Patterns\\Splitters\\2_90_270_splitters.txt", "w")
}
process_txtfile("2splitters", 3)
for i = 1, #outFiles do
outFiles[i]:close()
end
for i = 1, #dirs do
local dir, dirsignx, dirsigny = dirs[i][1], dirs[i][2], dirs[i][3]
if i<4 then
dirsignx,dirsigny = (dirsignx + dirs[i+1][2])/2,(dirsigny + dirs[i+1][3])/2
process_txtfile("2_" .. dir .. "_"..(dir+90).."_splitters", 6, dirsignx, dirsigny)
else
dirsignx,dirsigny = (dirsignx + dirs[1][2])/2,(dirsigny + dirs[1][3])/2
process_txtfile("2_0_270_splitters", 6, dirsignx, dirsigny)
end
end
--there must be no dupicates
table.sort(outputs, function (k1, k2) for i=1,4 do if k1[i]~=k2[i] then return k1[i]<k2[i] end end end)
local o = io.open("c:\\golly\\Patterns\\Splitters\\2_splitters_perp.txt", "w")
for i=1,#outputs do
o:write(outputs[i][4] .. "\n")
end
o:close()
outputs={}
for i = 1, #dirs do
local dir, dirsignx, dirsigny = dirs[i][1], dirs[i][2], dirs[i][3]
process_txtfile("2_" .. dir .. "_"..dir.."_splitters", 4, dirsignx, dirsigny)
end
--there must be no dupicates
table.sort(outputs, function (k1, k2) for i=1,4 do if k1[i]~=k2[i] then return k1[i]<k2[i] end end end)
local o = io.open("c:\\golly\\Patterns\\Splitters\\2_splitters_parallel.txt", "w")
for i=1,#outputs do
o:write(outputs[i][4] .. "\n")
end
o:close()
outputs={}
for i = 1, 2 do
local dir, dirsignx, dirsigny = dirs[i][1], dirs[i][2], dirs[i][3]
process_txtfile("2_" .. dir .. "_"..(dir+180).."_splitters", 5, dirsignx, dirsigny)
end
--there must be no dupicates
table.sort(outputs, function (k1, k2) for i=1,4 do if k1[i]~=k2[i] then return k1[i]<k2[i] end end end)
local o = io.open("c:\\golly\\Patterns\\Splitters\\2_splitters_opposite.txt", "w")
for i=1,#outputs do
o:write(outputs[i][4] .. "\n")
end
o:close()
outputs={}
end
--process_files(46)
--process_turners()
process_2splitters()
I am going to think about bumper/bouncer destructons by well timed gliders using the excess gliders from the W p256.
I have not find trivial hits of other objects by a single glider so some sort of catalyst should be added there ... so SoD specially on hershel tracks is the main priority.
.... I do not have a collection of glider to LWSS turners ... what would be helpfull considerng the snarks...