.
I've verified all the major issues by themselves (synth recipes, step size, the final ignition), but the run is not complete yet - so no 100% guarantee, but it's very probably working.
Code: Select all
import golly as g
import json
import os
class GunManager:
def __init__(self):
strGun1 = "88b2o$87bobo$81b2o4bo$79bo2bo2b2ob4o$79b2obobobobo2bo$82bobobobo$82bobob2o$83bo2$96b2o$87b2o7bo$87b2o5bobo$94b2o7$84b2o$85bo$82b3o$82bo42$149b2o$149bo$151bo$131b2o14b5o$132bo13bo$132bobo12b3o$133b2o15bo$147b4o$142b2o3bo3b2o$142b2o4b3o2bo$150bob2o$150bo$149b2o3$141b2o$141bo$142b3o$144bo10$18b2o$18b2o9$33b2o$33b2o2$124b2o$124bobo$126bo4b2o$122b4ob2o2bo2bo$122bo2bobobobob2o$125bobobobo$126b2obobo$130bo$13b2o$14bo101b2o$11b3o103bo7b2o$11bo105bobo5b2o$118b2o$113bo$104bo7bobo$104b3o6bo$5bo63b2obo34bo$5b3o61bob2o33b2o$8bo55b2o$7b2o14b2o40bo4b3o55b2o22bo$23b2o32bo6bo4bo2bo55bo21b3o$34b2o21b3o4b2o3b2o58b3o17bo$34bo25bo70bo17b2o$35b3o21b2o38b2o25b2o$37bo61b2o25bo$124bobo30b2o$124b2o32bo$158bob2o$150b2o4b3o2bo$111b2o37b2o3bo3b2o$48bo53b2o6bobo42b4o$48b3o31b2o19bo6bo30b2o15bo$24b2o25bo30bobo17bo6b2o29bobo12b3o$24bobo23b2o32bo17b2o36bo13bo$26bo57b2o53b2o14b5o$26b2o131bo$157bo$157b2o$113b2o$41bo70bobo$41b3o68bo$7b2o35bo66b2o$6bobo34b2o$6bo$5b2o$72b2o$62b2o8bo$42b2o18bobo8b3o$42b2o20bo10bo$64b2o$16b2o105b2o$16b2o33b2o70b2o$51b2o$23bob2o32b2o$23b2obo32bo$57bobo$57b2o$5b2o105b2o$6bo106bo19b2o$6bobo104bobo17bo$7b2o105b2o15bobo$126bo4b2o$125bobo$21b2o102bobo$21bobo90b2o10bo$23bo89bobo$23b2o88bo$112b2o$127b2o$103b2o22bo$35b2o67bo23b3o$36bo65bo27bo$36bobo63b5o14b2o$18b2o17b2o68bo13bo$18bo42b2o41b3o12bobo$19b3o39b2o40bo15b2o$21bo81b4o$101b2o3bo3b2o$100bo2b3o4b2o$100b2obo$2b2o99bo$bobo23bo31b2o42b2o$bo23b3o31bo$2o22bo35b3o$8b2o14b2o36bo48b2o$8b2o50b2o50bo$60bo48b3o$58bobo48bo$58b2o7$37b2o$37bo$7b2o26bobo$6bobo25bobo$6bo23b2o3bo$5b2o23b2o2$27b2o$27b2o2$54b2ob2o$55bobo$53bobo2bo$53b2o2b2o$17b2o$17b2o2$53bob2o$53b2obo$17b2o$17b2o2$26b2o23b2o$26b2o9b2o12bobo$37b2o14bo$53b2o!"
strGun1Ref = "52bo$50b3o$49bo$49b2o3$57b2o$58bo$58bob2o$50b2o4b3o2bo$50b2o3bo3b2o$55b4o$41b2o15bo$40bobo12b3o$40bo13bo$39b2o14b5o$31bo27bo$31b3o23bo$34bo22b2o$33b2o$48b2o$48bo$46bobo$35bo10b2o$34bobo$34bobo$29b2o4bo$28bobo15b2o$28bo17bobo$27b2o19bo$48b2o6$37b2o$37b2o9$49b2o$49bo$47bobo$47b2o$3b2o$4bo$2bo$2b5o14b2o$7bo13bo$4b3o12bobo29b2o$3bo15b2o30bo$3b4o42bobo$b2o3bo3b2o37b2o$o2b3o4b2o$2obo49b2o$3bo32b2o15bo$3b2o30bobo13bobo$35bo15b2o$34b2o$11b2o17bo$12bo17b3o$9b3o21bo$9bo22b2o7$42b2o$35b2o5bobo$35b2o7bo$44b2o2$31bo$30bobob2o$30bobobobo$27b2obobobobo2bo$27bo2bo2b2ob4o$29b2o4bo$35bobo$36b2o!"
strGun2 = "167bo$165b3o11bo$164bo14b3o$164b2o16bo14bo$181b2o12b3o$100b2o39bo52bo$101bo25bo13b3o50b2o$101bobo21b3o16bo$102b2o20bo18b2o$124b2o67b2o$174b2o17b2o$94b2o78b2o$94bo$92bobo$92b2o2$134b2o$134b2o41b2o$71b2o84b2o19bo$71b2o84bobo16bo$159bo16b2o$147b2o10b2o19b2o$147bo33bo$103b2o32b2o9b3o27b3o$103b2o11b2o20bo11bo27bo$116bo20bo$117b3o17b2o$119bo$196b2o$99b2o95bobo$99bo98bo$100b3o95b2o$102bo$81b2o$81b2o2$169b2o$122bo20bo25bo$121bobo7bo11b3o21bobo18b2o$122bo6b3o14bo20b2o19b2o$111bo16bo16b2o32b2o$111b3o14b2o49bo2bo$114bo60b2o4b2o$113b2o61bo20b2o$176bobo18bo$177b2o16bobo$195b2o$108b2o25b2o$109bo25b2o$109bobo$110b2o3$123b2o$123bobo6b2o32b2o$125bo6bo20b2o11b2o$125b2o6bo20bo$132b2o17b3o35b2o$151bo37b2o2b2o$193bobo$170b2o23bo$171bo23b2o$121b2o45b3o$121bobo44bo$123bo$3b2o118b2o$4bo$2bo$2b5o14b2o$7bo13bo$4b3o12bobo$3bo15b2o$3b4o$b2o3bo3b2o$o2b3o4b2o$2obo$3bo$3b2o3$11b2o100b2o$12bo100b2o53b2o$9b3o155bobo$9bo110bob2o37b2o4bo$120b2obo35bo2bo2b2ob4o$104b2o53b2obobobobo2bo$105bo56bobobobo$105bobo54bobob2o$106b2o55bo2$122bo53b2o$120b3o44b2o7bo$119bo11bo35b2o5bobo$104bo14b2o8b3o15bo9bo16b2o$103bobo22bo18b3o5b3o$104bo23b2o20bo3bo$149b2o3b2o$99bo$99b3o$102bo$101b2o61b2o$165bo$162b3o$93b2o67bo$93bo46b2o$90b2obo21b2o23b2o$90bo2b3o4b2o14bo35b2o$57bo33b2o3bo3b2o11b3o35bo2bo$57b3o33b4o16bo38b2o4b2o$60bo32bo15b2o47bobo$59b2o33b3o12bobo48bo$97bo13bo48b2o$92b5o14b2o37b2o$92bo58bo$94bo53b3o$93b2o53bo2$69b2o$62b2o5bobo$62b2o7bo$71b2o51bo$122b3o$58bo62bo$57bobob2o58b2o$57bobobobo$54b2obobobobo2bo$54bo2bo2b2ob4o$56b2o4bo$62bobo$63b2o$111b2o$110bobo5b2o$110bo7b2o$109b2o2$123bo$119b2obobo$118bobobobo$115bo2bobobobob2o$115b4ob2o2bo2bo$119bo4b2o$117bobo$117b2o!"
strGun2Ref = "59b2o$58bobo$52b2o4bo$50bo2bo2b2ob4o$50b2obobobobo2bo$53bobobobo$53bobob2o$54bo2$67b2o$58b2o7bo$58b2o5bobo$65b2o7$55b2o$56bo$53b3o$53bo5$29bo53b2o$27b3o53bo$26bo58bo$26b2o37b2o14b5o$16b2o48bo13bo$17bo48bobo12b3o$17bobo47b2o15bo$18b2o4b2o38bo16b4o$23bo2bo35b3o11b2o3bo3b2o$24b2o35bo14b2o4b3o2bo$36b2o23b2o21bob2o$36b2o46bo$15bo67b2o$13b3o$12bo$12b2o61b2o$75bo$76b3o$78bo$22b2o3b2o$23bo3bo20b2o$20b3o5b3o18bo$2b2o16bo9bo15b3o8b2o$bobo5b2o35bo11bo$bo7b2o44b3o4b2o$2o53bo7bo$60b3o$14bo45bo$10b2obobo$9bobobobo$6bo2bobobobob2o$6b4ob2o2bo2bo$10bo4b2o$8bobo$8b2o!"
self.gun1 = g.parse(strGun1, 252 - 11, 0)
self.gun1A = g.parse(strGun1Ref, 495 - 11, 302)
self.gld1 = g.parse("3o$o$bo!", 366 - 11, 182)
self.gun2 = g.parse(strGun2, -11, 270)
self.gun2A = g.parse(strGun2Ref, 287 - 11, 494)
self.gld2 = g.parse("3o$o$bo!", 167 - 11, 366)
self.glds = []
self.gldsRef = []
self.d = 40000
gunLength = 35000000
gunDist = 120000
gunMove = 250000
for i in xrange(0, 5):
self.PlaceGun(gunLength, gunDist + 300 * i, gunMove - 300* i, True, i % 2)
self.PlaceGun(gunLength, gunDist + 300 * i, gunMove- 300* i, False, i % 2)
def PlaceGun(self, gunLength, gunDist, gunMove, reflect, parity):
gun1T = g.transform(self.gun1, gunMove + gunDist + parity, gunMove -gunDist)
gun1AT = g.transform(self.gun1A, gunMove + gunDist + gunLength + parity, gunMove -gunDist + gunLength)
gun2T = g.transform(self.gun2, gunMove -gunDist+ parity, gunMove + gunDist)
gun2AT = g.transform(self.gun2A, gunMove -gunDist + gunLength+ parity, gunMove + gunDist + gunLength)
gld1 = g.transform(self.gld1, gunMove + gunDist + parity, gunMove -gunDist)
gld2 = g.transform(self.gld2, gunMove -gunDist + parity, gunMove + gunDist)
if not reflect:
g.putcells(gun1T)
g.putcells(gun2T)
g.putcells(gun1AT)
g.putcells(gun2AT)
self.glds.append((gld1, gld2))
else:
g.putcells(gun1T, 0, 0, -1, 0, 0, 1)
g.putcells(gun2T, 0, 0, -1, 0, 0, 1)
g.putcells(gun1AT, 0, 0, -1, 0, 0, 1)
g.putcells(gun2AT, 0, 0, -1, 0, 0, 1)
gld1 = g.transform(gld1, 0, 0, -1, 0, 0, 1)
gld2 = g.transform(gld2, 0, 0, -1, 0, 0, 1)
self.gldsRef.append((gld1, gld2))
def PlaceGld(self, x, y, i, dgun = 0):
dxyi = [(-1,1,3), (-2,0,0), (-1,1,1), (-1,1,2), (0,0,0), (-1,1,1), (0,1,2), (0,1,3)]
dx, dy, di = dxyi[i - 6]
if i < 10:
x = -x
x += dx
y += dy
if (y - x) % 2 == 0:
if i > 9:
gld1, gld2 = self.glds[dgun]
else:
gld1, gld2 = self.gldsRef[dgun]
else:
if i > 9:
gld1, gld2 = self.glds[1 + dgun]
else:
gld1, gld2 = self.gldsRef[1 + dgun]
gld1 = g.evolve(gld1, di)
gld2 = g.evolve(gld2, di)
parity = (y - x) % 2
if parity == -1:
parity = 1
direction = 1
if i < 10:
direction = -1
dist = 0
if y >= x:
g.putcells(gld1, direction*(self.d + x - parity), self.d + x - parity)
g.putcells(gld2, direction*(self.d + y), self.d + y)
dist = y
else:
g.putcells(gld1, direction*(self.d + x - parity), self.d + x - parity)
g.putcells(gld2, direction*(self.d + y), self.d + y)
dist = x
if dist < 100:
dist = 100
return dist
def PlaceRecipe(self, recipe, dx = 0, dy = 0):
dlgun = 0
drgun = 0
dist = 0
for x, y, i in recipe:
if i < 10:
d = self.PlaceGld(x + dx, y + dy, i, drgun)
drgun += 2
else:
d = self.PlaceGld(x + dx, y + dy, i, dlgun)
dlgun += 2
if d > dist:
dist = d
self.d += 3500
#gunMan.PlaceGld(2,1,6)
#gunMan.PlaceGld(1,2,13)
#gunMan.PlaceGld(2,2,8)
#gunMan.PlaceGld(6,0,10)
gun = []
gunRef = g.evolve(g.transform(gun, 1, 1, -1, 0, 0, 1), 3)
Define = "SYNTH"#"GUN"
def SLToListXY(cells):
list = []
for i in xrange(0, len(cells), 2):
list.append((cells[i], cells[i + 1]))
list.sort(key=lambda tup: 1000000 * tup[1] + tup[0])
x0, y0 = list[0]
return [(x - x0, y - y0) for x, y in list]
def IsSL(x, y, slXY):
for xi, yi in slXY:
if g.getcell(x + xi, y + yi) != 1:
return False
return True
def DeleteSL(x, y, slXY):
for xi, yi in slXY:
g.setcell(x + xi, y + yi, 0)
def PutSL(x, y, slXY):
for xi, yi in slXY:
g.setcell(x + xi, y + yi, 1)
def PutData(data, recog):
for x, y, i in data:
PutSL(x, y, recog[i])
#0 - HB
#1 - block
#2 - ship
#3 - wide beehive
#4 - boat
#5 - rotated boat
#6-9 - NW glider
#10-13 - NE gliders
#14 - blinker
#15 - beehive standing
#16 - boat
recGolly = [g.parse("4b2o$3bo2bo$3bobo$b2obo$o2bo$obo$bo!"), g.parse("2o$2o"), g.parse("2o$obo$b2o!"), g.parse("b2o$o2bo$b2o!"), g.parse("bo$obo$2o!"), g.parse("bo$obo$b2o!")]
for i in xrange (0, 4):
recGolly.append(g.evolve(g.parse("2o$b2o$o!"), i))
for i in xrange (0, 4):
recGolly.append(g.evolve(g.parse("3o$o$bo!"), i))
recGolly.append(g.parse("3o!"))
recGolly.append(g.parse("bo$obo$obo$bo!"))
recGolly.append(g.parse("b2o$obo$bo!"))
recog = [SLToListXY(c) for c in recGolly]
def ReadNext(data, recog):
rect = g.getrect()
if rect == []:
return False
d = g.getcells([rect[0], rect[1], rect[2], 1])
x0 = d[0]
y0 = d[1]
found = False
for i in xrange(0, len(recog)):
r = recog[i]
if IsSL(x0, y0, r):
DeleteSL(x0, y0, r)
data.append((x0, y0, i))
found = True
break
return found
def ReadData(recog):
data = []
if os.path.exists('hbkR.data'):
with open('hbkR.data', 'r') as f:
return json.load(f)
while ReadNext(data, recog):
i = 1
#with open('hbkR.data', 'wb') as f:
# json.dump(data, f)
return data
recipes = []
#recipes.append([(5, 7, 13), (-4, 11, 9), (-11, 17, 8), (-5, 17, 7), (15, 22, 11)])
recipes.append([(-4, 5, 6), (10, 7, 13), (-5, 13, 8), (11, 20, 10)])
recipes.append([(2, 2, 12), (-4, 5, 9)])
recipes.append([(2, 2, 12), (-2, 3, 6), (7, 5, 10)])
recipes.append([(-1, 1, 9), (2, 4, 12)])
recipes.append([(5, 0, 10), (-3, 4, 6), (-9, 6, 9)])
recipes.append([(-9, -2, 7), (0, 2, 13), (10, 8, 12)])
for i in xrange(0, 8):
recipes.append(recog[i + 6])
recipes.append([(5, 4, 13), (0, 6, 8)])
recipes.append([(2, -4, 13), (1, 0, 9), (6, 5, 12)])
recipes.append([(6, 1, 10), (-2, 5, 6), (-8, 7, 7)])
for rec in recipes:
rec.reverse()
gunMan = GunManager()
data = ReadData(recog)
for x, y, i in data:
if i >= 6 and i <= 13:
continue
gunMan.PlaceRecipe(recipes[i], x, y)
gliders = []
recs = []
for x, y, i in data:
if i >= 6 and i <= 13:
gliders.append((x, y, i))
idx = 0
x, y, i = gliders[0]
gunMan.PlaceGld(x, y, i, 0)
x, y, i = gliders[1]
gunMan.PlaceGld(x, y, i, 0)
x, y, i = gliders[2]
gunMan.PlaceGld(x, y, i, 2)
x, y, i = gliders[3]
gunMan.PlaceGld(x, y, i, 4)
x, y, i = gliders[4]
gunMan.PlaceGld(x, y, i, 2)
x, y, i = gliders[5]
gunMan.PlaceGld(x, y, i, 2)
x, y, i = gliders[6]
gunMan.PlaceGld(x, y, i, 0)
It has a bit large period of 280,001,640, and because of the 180 degree reflection, golly runs it pretty slowly. But the pattern is there, and its working - just takes time (unlike the previous gun that couldn't even be built).
The run has failed.