You have 96 hours (4 days) to find the cheapest glider destruction for this pattern:
Code: Select all
x = 7, y = 5, rule = B3/S23
2o4bo$ob4o$o3bo$4bo$2b2o!
Edit: Pattern must be 16x16 or less
Code: Select all
x = 7, y = 5, rule = B3/S23
2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 5, y = 9, rule = B3-jqr/S01c2-in3
3bo$4bo$o2bo$2o2$2o$o2bo$4bo$3bo!
Code: Select all
x = 7, y = 5, rule = B3/S2-i3-y4i
4b3o$6bo$o3b3o$2o$bo!
Code: Select all
6bo$7bo$5b3o4$12b2o4bo$12bob4o$12bo3bo$16bo$14b2o28$3o$2bo$bo!
Code: Select all
x = 81, y = 96, rule = LifeHistory
58.2A$58.2A3$59.2A17.2A$59.2A17.2A3$79.2A$79.2A2$57.A$56.A$56.3A4$27.
A$27.A.A$27.2A21$3.2A$3.2A2.2A$7.2A18$7.2A$7.2A2.2A$11.2A11$2A$2A2.2A
$4.2A18$4.2A$4.2A2.2A$8.2A!
Code: Select all
x = 7, y = 10, rule = B3/S23
bo$2bo$3o3$2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 10, y = 6, rule = B3/S23
3b2o4bo$3bob4o$3bo3bo$bo5bo$b2o2b2o$obo!
Code: Select all
x = 53, y = 15, rule = B3/S23
40bo$41bo$39b3o5$2o4bo11b2o4bo7b2o4bo7b2o4bo$ob4o12bob4o8bob4o8bob4o$o
3bo10bo2bo3bo9bo3bo9bo3bo$4bo10b2o5bo13bo13bo$2b2o3b2o5bobo3b2o12b2o
12b2o$6b2o22b3o$8bo23bo$31bo!
Code: Select all
x = 12, y = 5, rule = B3/S23
5b2o4bo$o4bob4o$o4bo3bo$o8bo$7b2o!
Code: Select all
x = 7, y = 6, rule = B3/S23
bo$2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 9, y = 6, rule = B3/S23
o$2b2o4bo$2bob4o$2bo3bo$6bo$4b2o!
Code: Select all
x = 7, y = 5, rule = B34/S34
2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 7, y = 5, rule = B35678/S5678
2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 7, y = 5, rule = B368/S245
2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 17, y = 5, rule = LifeHistory
2A4.A3.2A4.A$A.4A4.A.4A$A2.FA5.A3.A$4.A5.F3.A$2.2A8.2A!
Code: Select all
x = 7, y = 5, rule = B3/S23:T10,10
2o4bo$ob4o$o3bo$4bo$2b2o!
Code: Select all
x = 7, y = 5, rule = LifeHistory
2C4.C$C.4C$C3.C$4.C$2.2C!
Code: Select all
x = 6, y = 6, rule = B3/S23
bo$2o$4bo$3b3o$b3obo$5bo!
Code: Select all
x = 5, y = 9, rule = B3-jqr/S01c2-in3
3bo$4bo$o2bo$2o2$2o$o2bo$4bo$3bo!
Code: Select all
x = 7, y = 5, rule = B3/S2-i3-y4i
4b3o$6bo$o3b3o$2o$bo!
Code: Select all
x = 20, y = 12, rule = B3/S23
18bo$17bo$17b3o4$bo$2o$4bo$3b3o$b3obo$5bo!
Code: Select all
x = 9, y = 9, rule = B3/S23
bo$2o$4bo$3b3o$b3obo$5bo$7bo$6b2o$6bobo!
I'd argue that that's too close to the pattern, it almost certainly would have interacted already in any predecessor pattern sequence. The glider should be at least be separated so it won't interact immediately I think.blah wrote:1G, but faster.
Not to make any suggestions about the rules for this game, but the above solution needn't have come from an interacting predecessor:Sphenocorona wrote:I'd argue that that's too close to the pattern, it almost certainly would have interacted already in any predecessor pattern sequence. The glider should be at least be separated so it won't interact immediately I think.blah wrote:1G, but faster.
Code: Select all
x = 12, y = 11
bbo$bboboo$4bo$3bo4bo$o4bo$boboobboo$bboobbo$bbobo$10bo$9boo$9bobo!
Code: Select all
x = 43, y = 45, rule = Life
12b2o10b2o$b2o8bobo9bo2bo$bobo6bobo6b2obob2o$4bo3b3o7bobobobo6bo$2b2o
3bo3bo6bo2bo2bo5bobo$bo6bobobo3b3o3b2o3bo2bobo2bo$b3o3b2obobo2bo11b3ob
ob3o$4bo2bo2bobobobo14bo$3bobobob2obo2bobo3b2ob2o3b2ob2o3b2o$2bobo2bo
2bobo4bo2bobobo3bo2bo2bobobo$2bo4b2o2bo5b4obo2bo2b2obob2obobob2o$b2o
20b3o5bo4bo2bo2bo$17b2o9b2obob2ob2obob2o$b2o7b2ob2o2bo5b2obo2bobob2obo
2bobo$obo6bobobo5bo2bobob2o2bo5bobo2bo$o2b2o4bobo2b6o2bobobo9b2o3b2o$b
2o2bo4b2o11bo3bo4bo$3b2o11b4o4b4o3bobo2b4o$3bo4b4o3bo3bo10bo2bo2bo2bo$
5bo2bo3bo3bo5b3ob2o2bobob2o$4b2o3b2obo2b2o4bo2bobo4b2obo$10bob2o3b2obo
bo2bo2bo5bo$2b4o4bo6bob2ob2obob2o2b2ob2o$2bo2bo5b3o9bobo6bo4bo$6b2o5bo
4b5o3b3o3bob4o$7bo9bo2bo7bo4bo$7bob2o6b2o9bobo3b2o$6b2obo9b4o3b2obobo
4bo$10bo6b2o2bobobobo2bo3b3o$11bo4bobo4bobo2b2o3bo$5bo2b4o4b2o5bobo7b
2o$5b4o13b2ob5o5bo$10b2o4b4o9bo3b2obo$5b2o4bo4bo2bo2b5o5bo3bo$5bobo3bo
b2obo2bobo4bo4bob3o$7bo2b2ob2ob4ob2o2bo5bobo$6b2obo14bob3o3bo$7bo2b2ob
2ob2ob5obo2bo$5bobo3bob2ob2obo3bo3bo$5b2o4bo8b2o2bo3b3o$10b2o10b2o6bo$
20b2o$20bo2b3o$22b2o2bo$25b2o!
GUYTU6J wrote:You need to disallow to use scripts.
Code: Select all
x = 7, y = 10, rule = B3/S23 bo$2bo$3o3$2o4bo$ob4o$o3bo$4bo$2b2o!
Rhombic wrote:GUYTU6J wrote:You need to disallow to use scripts.
Code: Select all
x = 7, y = 10, rule = B3/S23 bo$2bo$3o3$2o4bo$ob4o$o3bo$4bo$2b2o!
Could you post the script you used?
Code: Select all
# glider_destruction.py
import golly as g
from operator import mul
glider = [[-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], [-2, -2, -1, -1, 0, -1, -2, 0, -1, 0], [-1, -2, -3, -1, -1, -1, -2, 0, -1, 0], [-3, -2, -1, -2, -2, -1, -1, -1, -2, 0]]
collstatus = (10 ** 9, 0, 0, [0, 0]) #(dummy values) box_size, pattern_pos, glider_phase, [glider_x, glider_y]
def form(celllist, num):
if num not in xrange(8):
return celllist
if num >= 4:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, -1)
num -= 4
if num >= 2:
celllist = g.transform(celllist, 0, 0, 0, 1, -1, 0)
num -= 2
if num >= 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, 1)
return celllist
def trygliders(celllist, distance, num):
g.new('')
g.putcells(celllist)
rect = g.getrect()
gx = rect[0] - 3 - distance
gy = rect[1] - 3 - distance
status = collstatus
phase = 0
for gphase in glider:
for w in xrange(rect[2] + 5):
g.new('')
g.putcells(celllist)
g.putcells(gphase, gx + w, gy)
for gen in xrange(1000):
g.run(1)
if int(g.getpop()) <= 2:
return (0, num, phase, [gx + w, gy])
box = reduce(mul, g.getrect()[2:])
if box < status[0]:
status = (box, num, phase, [gx + w, gy])
phase += 1
return status
glidersexist = (g.evolve([-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], 4) == [0, -1, 1, 0, -1, 1, 0, 1, 1, 1])
if not glidersexist:
g.exit("Please choose a rule where gliders exist.")
celllist = g.getcells(g.getrect())
dist = 0
g.show("Searching for a 1-glider destruction... press any key to display smallest result found")
while True:
for num in xrange(8):
tlist = form(celllist, num)
collstatus = trygliders(tlist, dist, num)
event = g.getevent()
if collstatus[0] == 0 or event.startswith("key"):
if collstatus[0] == 0:
g.show("Found clean glider destruction.")
else:
g.show("Found result with %d-cell bounding box." % collstatus[0])
g.new('')
g.putcells(form(celllist, collstatus[1]))
g.putcells(glider[collstatus[2]], collstatus[3][0], collstatus[3][1])
g.exit()
dist += 1
Thank you! It actually works for every rule with gliders!! Very interesting... it's a shame that only one initial configuration is available, which might have trouble with period-dependent destructions (I had one in a possible pentadecathlon-containing pattern). Very interesting.GUYTU6J wrote:Code: Select all
# glider_destruction.py import golly as g from operator import mul glider = [[-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], [-2, -2, -1, -1, 0, -1, -2, 0, -1, 0], [-1, -2, -3, -1, -1, -1, -2, 0, -1, 0], [-3, -2, -1, -2, -2, -1, -1, -1, -2, 0]] collstatus = (10 ** 9, 0, 0, [0, 0]) #(dummy values) box_size, pattern_pos, glider_phase, [glider_x, glider_y] def form(celllist, num): if num not in xrange(8): return celllist if num >= 4: celllist = g.transform(celllist, 0, 0, -1, 0, 0, -1) num -= 4 if num >= 2: celllist = g.transform(celllist, 0, 0, 0, 1, -1, 0) num -= 2 if num >= 1: celllist = g.transform(celllist, 0, 0, -1, 0, 0, 1) return celllist def trygliders(celllist, distance, num): g.new('') g.putcells(celllist) rect = g.getrect() gx = rect[0] - 3 - distance gy = rect[1] - 3 - distance status = collstatus phase = 0 for gphase in glider: for w in xrange(rect[2] + 5): g.new('') g.putcells(celllist) g.putcells(gphase, gx + w, gy) for gen in xrange(1000): g.run(1) if int(g.getpop()) <= 2: return (0, num, phase, [gx + w, gy]) box = reduce(mul, g.getrect()[2:]) if box < status[0]: status = (box, num, phase, [gx + w, gy]) phase += 1 return status glidersexist = (g.evolve([-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], 4) == [0, -1, 1, 0, -1, 1, 0, 1, 1, 1]) if not glidersexist: g.exit("Please choose a rule where gliders exist.") celllist = g.getcells(g.getrect()) dist = 0 g.show("Searching for a 1-glider destruction... press any key to display smallest result found") while True: for num in xrange(8): tlist = form(celllist, num) collstatus = trygliders(tlist, dist, num) event = g.getevent() if collstatus[0] == 0 or event.startswith("key"): if collstatus[0] == 0: g.show("Found clean glider destruction.") else: g.show("Found result with %d-cell bounding box." % collstatus[0]) g.new('') g.putcells(form(celllist, collstatus[1])) g.putcells(glider[collstatus[2]], collstatus[3][0], collstatus[3][1]) g.exit() dist += 1
I was able to speed the script up by an order of magnitude or so for Life, with a few small hacks. I don't _think_ that I reduced the script's ability to find things, but I haven't checked very carefully yet.Rhombic wrote:And I have to add that it is incredibly fast in tDryLife, much more so than in Life, for some reason.
Code: Select all
x = 82, y = 45, rule = B3/S23
12b2o10b2o$b2o8bobo9bo2bo$bobo6bobo6b2obob2o$4bo3b3o7bobobobo6bo$2b2o
3bo3bo6bo2bo2bo5bobo$bo6bobobo3b3o3b2o3bo2bobo2bo$b3o3b2obobo2bo11b3ob
ob3o$4bo2bo2bobobobo14bo$3bobobob2obo2bobo3b2ob2o3b2ob2o3b2o$2bobo2bo
2bobo4bo2bobobo3bo2bo2bobobo$2bo4b2o2bo5b4obo2bo2b2obob2obobob2o$b2o
20b3o5bo4bo2bo2bo$17b2o9b2obob2ob2obob2o$b2o7b2ob2o2bo5b2obo2bobob2obo
2bobo$obo6bobobo5bo2bobob2o2bo5bobo2bo$o2b2o4bobo2b6o2bobobo9b2o3b2o$b
2o2bo4b2o11bo3bo4bo35b2o$3b2o11b4o4b4o3bobo2b4o29bo$3bo4b4o3bo3bo10bo
2bo2bo2bo28bo$5bo2bo3bo3bo5b3ob2o2bobob2o32b2o$4b2o3b2obo2b2o4bo2bobo
4b2obo36bo$10bob2o3b2obobo2bo2bo5bo33b4o$2b4o4bo6bob2ob2obob2o2b2ob2o
31bo$2bo2bo5b3o9bobo6bo4bo30b2o$6b2o5bo4b5o3b3o3bob4o32bo$7bo9bo2bo7bo
4bo34b3o8b3o$7bob2o6b2o9bobo3b2o31bo11bo$6b2obo9b4o3b2obobo4bo30b2o11b
o$10bo6b2o2bobobobo2bo3b3o8b3o$11bo4bobo4bobo2b2o3bo11bo$5bo2b4o4b2o5b
obo7b2o11bo$5b4o13b2ob5o5bo$10b2o4b4o9bo3b2obo$5b2o4bo4bo2bo2b5o5bo3bo
$5bobo3bob2obo2bobo4bo4bob3o$7bo2b2ob2ob4ob2o2bo5bobo$6b2obo14bob3o3bo
$7bo2b2ob2ob2ob5obo2bo$5bobo3bob2ob2obo3bo3bo$5b2o4bo8b2o2bo3b3o$10b2o
10b2o6bo$20b2o$20bo2b3o$22b2o2bo$25b2o!
Code: Select all
# glider_destruction_v2.py
# Enter a pattern and this script will try to find a single-glider destruction of it.
#
# Recently added features:
# -When user presses a key, copy result to clipboard instead of ending program to show it
# -Terminates script when periodicity is detected
#
# Ways to improve this script:
# -Use the bounding diamond instead of the bounding box
# -If pattern is symmetrical, not check redundant collisions
# -Change boxstatus and popstatus into a list containing a list or tuple and a tuple, and a list containing a number and a tuple respectively.
# -Find minimum population for 1000 generations instead of population after 1000 generations
import golly as g
from operator import mul
glider = [[-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], [-2, -2, -1, -1, 0, -1, -2, 0, -1, 0], [-1, -2, -3, -1, -1, -1, -2, 0, -1, 0], [-3, -2, -1, -2, -2, -1, -1, -1, -2, 0]]
boxstatus = ([10 ** 9, 10 ** 9], 0, 0, [0, 0]) #(dummy values) box_size, pattern_pos, glider_phase, [glider_x, glider_y]
popstatus = (int(g.getpop()) + 5, 0, 0, [0, 0])
# In this and the following function, "num" represents one of the eight possible transformations of the pattern, encoded as a 3-bit binary number.
# The first bit represents whether the pattern has been turned upside down from its original orientation,
# the second bit represents whether it has been rotated clockwise by 90 degrees,
# and the third bit represents whether it has been flipped about the x-axis.
def form(celllist, num):
if num not in xrange(8):
return celllist
if num >= 4:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, -1)
num -= 4
if num >= 2:
celllist = g.transform(celllist, 0, 0, 0, 1, -1, 0)
num -= 2
if num >= 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, 1)
return celllist
def deform(celllist, num):
if num not in xrange(8):
return celllist
if num % 2 == 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, 1)
num = num / 2
if num % 2 == 1:
celllist = g.transform(celllist, 0, 0, 0, -1, 1, 0)
num = num / 2
if num % 2 == 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, -1)
num -= 4
return celllist
def boxform(rect, num):
newrect = list(rect) #kludge
if num not in xrange(8):
return newrect
if num >= 4:
newrect[0] = -newrect[0] - newrect[2] + 1
newrect[1] = -newrect[1] - newrect[3] + 1
num -= 4
if num >= 2:
newrect = [newrect[1], -newrect[0] - newrect[2] + 1, newrect[3], newrect[2]]
num -= 2
if num >= 1:
newrect[0] = -newrect[0] - newrect[2] + 1
return newrect
def putcells_and_fit(celllist):
g.putcells(celllist)
g.fit()
def trygliders(ginfo):
gdistance = ginfo / 4
phase = ginfo % 4
bstatus = boxstatus
pstatus = popstatus
for num in xrange(8):
tlist = form(celllist, num)
rect = boxform(fullrect, num)
g.new('')
g.putcells(tlist)
gx = rect[0] - 3 - gdistance
gy = rect[1] - 3 - gdistance
for w in xrange(rect[2] + 5):
g.new('')
g.putcells(tlist)
g.putcells(glider[phase], gx + w, gy)
g.fit()
g.update()
for gen in xrange(1000):
g.run(1)
if int(g.getpop()) <= 2:
g.new('')
g.show("Found clean glider destruction.")
status = 0, num, phase, [gx + w, gy]
putcells_and_fit(result(celllist, status))
g.exit()
box = g.getrect()[2:]
# Checking the bounding box size and population against the current lowest found.
if reduce(mul, box) < reduce(mul, bstatus[0]):
bstatus = (box, num, phase, [gx + w, gy])
pop = int(g.getpop())
if pop < pstatus[0]:
pstatus = (pop, num, phase, [gx + w, gy])
# Show results if the user presses certain keys
event = g.getevent()
if event.startswith("key x"):
g.new('')
put_result_pair(celllist, bstatus, pstatus)
g.select(g.getrect())
g.copy()
g.select([])
g.note("Minimum bounding box and population collisions copied to clipboard.")
if event.startswith("key q"):
g.new('')
g.show("Search stopped.")
put_result_pair(celllist, bstatus, pstatus)
g.fit()
g.exit()
g.show("Searching for a 1-glider destruction... press <x> to copy minimum bounding box and population results to clipboard; press <q> to quit. Stats: minimum bounding box %dx%d, minimum population %d" % (bstatus[0][0], bstatus[0][1], pstatus[0]))
return bstatus, pstatus
def result(celllist, status):
return celllist + deform(g.transform(glider[status[2]], status[3][0], status[3][1]), status[1])
def put_result_pair(celllist, bstatus, pstatus):
g.putcells(result(celllist, bstatus) + g.transform(result(celllist, pstatus), 3*pattrect[2], 0))
def bounding_box_union(bbox1, bbox2):
bbox_union = []
if bbox2[0] > bbox1[0]:
bbox_union.append(bbox1[0])
else:
bbox_union.append(bbox2[0])
if bbox2[1] > bbox1[1]:
bbox_union.append(bbox1[1])
else:
bbox_union.append(bbox2[1])
if bbox2[0] + bbox2[2] > bbox1[0] + bbox1[2]:
bbox_union.append(bbox2[0] + bbox2[2] - bbox_union[0])
else:
bbox_union.append(bbox1[0] + bbox1[2] - bbox_union[0])
if bbox2[1] + bbox2[3] > bbox1[1] + bbox1[3]:
bbox_union.append(bbox2[1] + bbox2[3] - bbox_union[1])
else:
bbox_union.append(bbox1[1] + bbox1[3] - bbox_union[1])
return bbox_union
glidersexist = (g.evolve([-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], 4) == [0, -1, 1, 0, -1, 1, 0, 1, 1, 1])
if not glidersexist:
g.exit("Please choose a rule where gliders exist.")
# pattrect is the bounding box of the initial generation
# fullrect is the union of the bounding boxes of all the generations up to the current (specified by the variable "info" for complicated reasons)
pattrect = g.getrect()
fullrect = pattrect
celllist = g.getcells(pattrect)
currlist = celllist
gen_status_list = []
info = 0
g.addlayer()
while True:
for tup in gen_status_list:
if tup[0] == currlist:
if tup[1] == fullrect:
g.new('')
g.show("Search complete. No glider destruction found. Minimum bounding box and population results given.")
put_result_pair(celllist, boxstatus, popstatus)
g.fit()
g.exit()
boxstatus, popstatus = trygliders(info)
info += 1
gen_status_list.append((currlist, fullrect))
g.new('')
currlist = g.evolve(currlist, 1)
g.putcells(currlist)
fullrect = bounding_box_union(fullrect, g.getrect())
Code: Select all
# glider_destruction_v2_Python3.py
# Enter a pattern and this script will try to find a single-glider destruction of it.
#
# Recently added features:
# -When user presses a key, copy result to clipboard instead of ending program to show it
# -Terminates script when periodicity is detected
#
# Ways to improve this script:
# -Use the bounding diamond instead of the bounding box
# -If pattern is symmetrical, not check redundant collisions
# -Change boxstatus and popstatus into a list containing a list or tuple and a tuple, and a list containing a number and a tuple respectively.
# -Find minimum population for 1000 generations instead of population after 1000 generations
import golly as g
import functools
from operator import mul
glider = [[-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], [-2, -2, -1, -1, 0, -1, -2, 0, -1, 0], [-1, -2, -3, -1, -1, -1, -2, 0, -1, 0], [-3, -2, -1, -2, -2, -1, -1, -1, -2, 0]]
boxstatus = ([10 ** 9, 10 ** 9], 0, 0, [0, 0]) #(dummy values) box_size, pattern_pos, glider_phase, [glider_x, glider_y]
popstatus = (int(g.getpop()) + 5, 0, 0, [0, 0])
# In this and the following function, "num" represents one of the eight possible transformations of the pattern, encoded as a 3-bit binary number.
# The first bit represents whether the pattern has been turned upside down from its original orientation,
# the second bit represents whether it has been rotated clockwise by 90 degrees,
# and the third bit represents whether it has been flipped about the x-axis.
def form(celllist, num):
if num not in range(8):
return celllist
if num >= 4:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, -1)
num -= 4
if num >= 2:
celllist = g.transform(celllist, 0, 0, 0, 1, -1, 0)
num -= 2
if num >= 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, 1)
return celllist
def deform(celllist, num):
if num not in range(8):
return celllist
if num % 2 == 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, 1)
num = num / 2
if num % 2 == 1:
celllist = g.transform(celllist, 0, 0, 0, -1, 1, 0)
num = num / 2
if num % 2 == 1:
celllist = g.transform(celllist, 0, 0, -1, 0, 0, -1)
num -= 4
return celllist
def boxform(rect, num):
newrect = list(rect) #kludge
if num not in range(8):
return newrect
if num >= 4:
newrect[0] = -newrect[0] - newrect[2] + 1
newrect[1] = -newrect[1] - newrect[3] + 1
num -= 4
if num >= 2:
newrect = [newrect[1], -newrect[0] - newrect[2] + 1, newrect[3], newrect[2]]
num -= 2
if num >= 1:
newrect[0] = -newrect[0] - newrect[2] + 1
return newrect
def putcells_and_fit(celllist):
g.putcells(celllist)
g.fit()
def trygliders(ginfo):
gdistance = ginfo // 4
phase = ginfo % 4
bstatus = boxstatus
pstatus = popstatus
for num in range(8):
tlist = form(celllist, num)
rect = boxform(fullrect, num)
g.new('')
g.putcells(tlist)
gx = rect[0] - 3 - gdistance
gy = rect[1] - 3 - gdistance
for w in range(rect[2] + 5):
g.new('')
g.putcells(tlist)
g.putcells(glider[phase], gx + w, gy)
g.fit()
g.update()
for gen in range(1000):
g.run(1)
if int(g.getpop()) <= 2:
g.reset()
g.show("Found clean glider destruction.")
# g.new('')
# status = 0, num, phase, [gx + w, gy]
# putcells_and_fit(result(celllist, status))
g.exit()
box = g.getrect()[2:]
# Checking the bounding box size and population against the current lowest found.
if functools.reduce(mul, box) < functools.reduce(mul, bstatus[0]):
bstatus = (box, num, phase, [gx + w, gy])
pop = int(g.getpop())
if pop < pstatus[0]:
pstatus = (pop, num, phase, [gx + w, gy])
# Show results if the user presses certain keys
event = g.getevent()
if event.startswith("key x"):
g.new('')
put_result_pair(celllist, bstatus, pstatus)
g.select(g.getrect())
g.copy()
g.select([])
g.note("Minimum bounding box and population collisions copied to clipboard.")
if event.startswith("key q"):
g.new('')
g.show("Search stopped.")
put_result_pair(celllist, bstatus, pstatus)
g.fit()
g.exit()
g.show("Searching for a 1-glider destruction... press <x> to copy minimum bounding box and population results to clipboard; press <q> to quit. Stats: minimum bounding box %dx%d, minimum population %d" % (bstatus[0][0], bstatus[0][1], pstatus[0]))
return bstatus, pstatus
def result(celllist, status):
return celllist + deform(g.transform(glider[status[2]], status[3][0], status[3][1]), status[1])
def put_result_pair(celllist, bstatus, pstatus):
g.putcells(result(celllist, bstatus) + g.transform(result(celllist, pstatus), 3*pattrect[2], 0))
def bounding_box_union(bbox1, bbox2):
bbox_union = []
if bbox2[0] > bbox1[0]:
bbox_union.append(bbox1[0])
else:
bbox_union.append(bbox2[0])
if bbox2[1] > bbox1[1]:
bbox_union.append(bbox1[1])
else:
bbox_union.append(bbox2[1])
if bbox2[0] + bbox2[2] > bbox1[0] + bbox1[2]:
bbox_union.append(bbox2[0] + bbox2[2] - bbox_union[0])
else:
bbox_union.append(bbox1[0] + bbox1[2] - bbox_union[0])
if bbox2[1] + bbox2[3] > bbox1[1] + bbox1[3]:
bbox_union.append(bbox2[1] + bbox2[3] - bbox_union[1])
else:
bbox_union.append(bbox1[1] + bbox1[3] - bbox_union[1])
return bbox_union
glidersexist = (g.evolve([-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], 4) == [0, -1, 1, 0, -1, 1, 0, 1, 1, 1])
if not glidersexist:
g.exit("Please choose a rule where gliders exist.")
# pattrect is the bounding box of the initial generation
# fullrect is the union of the bounding boxes of all the generations up to the current (specified by the variable "info" for complicated reasons)
pattrect = g.getrect()
fullrect = pattrect
celllist = g.getcells(pattrect)
currlist = celllist
gen_status_list = []
info = 0
g.addlayer()
while True:
for tup in gen_status_list:
if tup[0] == currlist:
if tup[1] == fullrect:
g.new('')
g.show("Search complete. No glider destruction found. Minimum bounding box and population results given.")
put_result_pair(celllist, boxstatus, popstatus)
g.fit()
g.exit()
boxstatus, popstatus = trygliders(info)
info += 1
gen_status_list.append((currlist, fullrect))
g.new('')
currlist = g.evolve(currlist, 1)
g.putcells(currlist)
fullrect = bounding_box_union(fullrect, g.getrect())
Code: Select all
glider = [[-22, -35, -22, -34, -21, -34, -22, -33, -21, -33, -24, -31, -23, -31, -22, -31, -24, -30, -23, -30, -22, -30, -20, -28, -21, -27, -19, -27, -26, -26, -23, -26, -26, -25, -24, -25, -22, -25, -20, -25, -18, -25, -17, -25, -16, -25, -34, -24, -33, -24, -32, -24, -29, -24, -24, -24, -18, -24, -17, -24, -30, -23, -27, -23, -26, -23, -24, -23, -21, -23, -19, -23, -18, -23, -34, -22, -33, -22, -31, -22, -30, -22, -27, -22, -26, -22, -24, -22, -23, -22, -19, -22, -18, -22, -17, -22, -16, -22, -15, -22, -32, -21, -25, -21, -24, -21, -23, -21, -19, -21, -14, -21, -18, -20, -14, -20, -23, -19, -22, -19, -14, -19, -26, -18, -25, -18, -24, -18, -23, -18, -22, -18, -21, -18, -17, -18, -15, -18, -10, -18, -9, -18, -25, -17, -20, -17, -18, -17, -23, -16, -22, -16, -21, -16, -18, -16, -17, -16, -15, -16, -14, -16, -12, -16, -11, -16, -9, -16, -8, -16, -22, -15, -21, -15, -19, -15, -13, -15, -12, -15, -11, -15, -10, -15, -9, -15, -7, -15, -5, -15, -4, -15, -20, -14, -17, -14, -16, -14, -15, -14, -10, -14, -8, -14, -7, -14, -3, -14, -20, -13, -15, -13, -14, -13, -11, -13, -10, -13, -14, -12, -13, -12, -3, -12, -16, -11, -12, -11, -8, -11, -5, -11, -3, -11, -2, -11, -17, -10, -12, -10, -2, -10, -17, -9, -12, -9, -11, -9, -10, -9, -8, -9, -7, -9, -6, -9, -5, -9, -4, -9, -1, -9, -16, -8, -13, -8, -11, -8, -2, -8, -1, -8, -14, -7, -13, -7, -11, -7, -7, -7, -6, -7, -1, -7, -13, -6, -10, -6, -8, -6, -7, -6, -13, -5, -12, -5, -11, -5, -10, -5, -8, -5, -1, -5, -13, -4, -11, -4, -8, -4, -5, -4, -4, -4, -2, -4, -1, -4, -9, -3, -8, -3, -4, -3, -8, -2, -7, -2, -6, -2, -4, -2, -3, -2, -2, -2, -4, -1, -3, -1], [-23, -34, -22, -34, -21, -34, -20, -33, -23, -31, -21, -31, -24, -30, -23, -30, -25, -27, -24, -27, -21, -27, -20, -27, -19, -27, -17, -27, -20, -26, -19, -26, -17, -26, -30, -25, -26, -25, -25, -25, -24, -25, -22, -25, -20, -25, -18, -25, -17, -25, -16, -25, -34, -24, -32, -24, -29, -24, -26, -24, -24, -24, -23, -24, -22, -24, -21, -24, -35, -23, -33, -23, -31, -23, -30, -23, -27, -23, -26, -23, -21, -23, -20, -23, -19, -23, -33, -22, -32, -22, -31, -22, -26, -22, -24, -22, -19, -22, -18, -22, -24, -21, -23, -21, -17, -21, -16, -21, -15, -21, -14, -21, -18, -20, -17, -20, -15, -20, -14, -20, -27, -19, -17, -19, -26, -18, -24, -18, -23, -18, -22, -18, -21, -18, -17, -18, -16, -18, -15, -18, -10, -18, -9, -18, -25, -17, -22, -17, -20, -17, -15, -17, -10, -17, -9, -17, -23, -16, -22, -16, -19, -16, -17, -16, -16, -16, -15, -16, -13, -16, -9, -16, -8, -16, -17, -15, -16, -15, -12, -15, -11, -15, -7, -15, -5, -15, -4, -15, -21, -14, -20, -14, -19, -14, -16, -14, -15, -14, -14, -14, -10, -14, -7, -14, -5, -14, -4, -14, -10, -13, -7, -13, -6, -13, -5, -13, -4, -13, -13, -12, -10, -12, -8, -12, -7, -12, -5, -12, -14, -11, -13, -11, -8, -11, -7, -11, -6, -11, -5, -11, -4, -11, -3, -11, -17, -10, -16, -10, -15, -10, -14, -10, -13, -10, -10, -10, -3, -10, -2, -10, -17, -9, -16, -9, -14, -9, -13, -9, -10, -9, -8, -9, -7, -9, -6, -9, -5, -9, -4, -9, -13, -8, -10, -8, -9, -8, -4, -8, -2, -8, -1, -8, -15, -7, -14, -7, -10, -7, -9, -7, -7, -7, -6, -7, -5, -7, -4, -7, -3, -7, -1, -7, -13, -6, -10, -6, -8, -6, -5, -6, -4, -6, -3, -6, -2, -6, -13, -5, -12, -5, -11, -5, -5, -5, -4, -5, -3, -5, -9, -4, -8, -4, -4, -4, -2, -4, -1, -4, -12, -3, -7, -3, -2, -3, -10, -2, -5, -2, -3, -2, -2, -2, -8, -1, -7, -1, -4, -1], [-25, -34, -24, -34, -22, -34, -21, -34, -22, -33, -21, -33, -22, -32, -21, -32, -23, -31, -22, -31, -23, -30, -23, -29, -24, -28, -23, -28, -22, -28, -24, -27, -23, -27, -21, -27, -18, -27, -17, -27, -26, -26, -21, -26, -19, -26, -18, -26, -17, -26, -31, -25, -30, -25, -25, -25, -24, -25, -23, -25, -34, -24, -29, -24, -26, -24, -21, -24, -16, -24, -15, -24, -35, -23, -33, -23, -31, -23, -30, -23, -26, -23, -22, -23, -20, -23, -35, -22, -33, -22, -32, -22, -26, -22, -24, -22, -19, -22, -18, -22, -28, -21, -27, -21, -26, -21, -24, -21, -23, -21, -17, -21, -14, -21, -26, -20, -25, -20, -21, -20, -17, -20, -15, -20, -14, -20, -26, -19, -25, -19, -17, -19, -16, -19, -26, -18, -22, -18, -16, -18, -10, -18, -9, -18, -25, -17, -24, -17, -22, -17, -21, -17, -14, -17, -10, -17, -9, -17, -22, -16, -20, -16, -19, -16, -17, -16, -14, -16, -21, -15, -20, -15, -19, -15, -17, -15, -16, -15, -12, -15, -8, -15, -7, -15, -5, -15, -20, -14, -15, -14, -14, -14, -13, -14, -12, -14, -10, -14, -9, -14, -8, -14, -7, -14, -5, -14, -4, -14, -12, -13, -11, -13, -10, -13, -17, -12, -13, -12, -12, -12, -7, -12, -4, -12, -13, -11, -9, -11, -7, -11, -6, -11, -5, -11, -16, -10, -13, -10, -10, -10, -3, -10, -2, -10, -17, -9, -16, -9, -14, -9, -10, -9, -8, -9, -7, -9, -6, -9, -5, -9, -4, -9, -2, -9, -15, -8, -14, -8, -9, -8, -7, -8, -4, -8, -2, -8, -1, -8, -15, -7, -14, -7, -9, -7, -7, -7, -6, -7, -3, -7, -9, -6, -4, -6, -1, -6, -15, -5, -14, -5, -12, -5, -11, -5, -4, -5, -1, -5, -12, -4, -11, -4, -9, -4, -4, -4, -12, -3, -11, -3, -10, -3, -8, -3, -7, -3, -5, -3, -4, -3, -2, -3, -1, -3, -10, -2, -9, -2, -8, -2, -7, -2, -5, -2, -4, -2, -3, -2, -8, -1], [-24, -35, -22, -35, -24, -34, -22, -34, -24, -33, -21, -33, -22, -32, -23, -31, -22, -31, -24, -30, -23, -28, -22, -28, -26, -27, -25, -27, -23, -27, -22, -27, -18, -27, -21, -26, -18, -26, -17, -26, -31, -25, -30, -25, -25, -25, -24, -25, -23, -25, -22, -25, -21, -25, -18, -25, -31, -24, -30, -24, -26, -24, -22, -24, -21, -24, -19, -24, -18, -24, -16, -24, -35, -23, -34, -23, -33, -23, -31, -23, -30, -23, -25, -23, -19, -23, -18, -23, -16, -23, -15, -23, -34, -22, -33, -22, -27, -22, -23, -22, -18, -22, -16, -22, -15, -22, -28, -21, -25, -21, -17, -21, -14, -21, -13, -21, -27, -20, -23, -20, -22, -20, -21, -20, -15, -20, -25, -19, -24, -19, -23, -19, -22, -19, -20, -19, -17, -19, -16, -19, -25, -18, -24, -18, -22, -18, -18, -18, -16, -18, -14, -18, -10, -18, -9, -18, -25, -17, -22, -17, -14, -17, -11, -17, -8, -17, -22, -16, -18, -16, -16, -16, -14, -16, -13, -16, -21, -15, -20, -15, -19, -15, -16, -15, -13, -15, -12, -15, -7, -15, -15, -14, -12, -14, -8, -14, -7, -14, -6, -14, -5, -14, -4, -14, -16, -13, -15, -13, -11, -13, -10, -13, -9, -13, -5, -13, -16, -12, -15, -12, -13, -12, -9, -12, -8, -12, -7, -12, -5, -12, -4, -12, -18, -11, -15, -11, -14, -11, -13, -11, -9, -11, -6, -11, -5, -11, -18, -10, -16, -10, -15, -10, -3, -10, -16, -9, -14, -9, -11, -9, -9, -9, -6, -9, -5, -9, -4, -9, -3, -9, -2, -9, -15, -8, -14, -8, -9, -8, -7, -8, -6, -8, -2, -8, -9, -7, -7, -7, -2, -7, -15, -6, -11, -6, -9, -6, -4, -6, -15, -5, -9, -5, -4, -5, -3, -5, -2, -5, -1, -5, -14, -4, -12, -4, -11, -4, -2, -4, -1, -4, -11, -3, -10, -3, -8, -3, -4, -3, -2, -3, -9, -2, -8, -2, -7, -2, -5, -2, -4, -2], [-23, -36, -24, -35, -23, -34, -22, -34, -24, -33, -22, -33, -23, -32, -22, -32, -25, -31, -23, -31, -24, -30, -23, -28, -19, -28, -25, -27, -24, -27, -23, -27, -22, -27, -18, -27, -27, -26, -25, -26, -17, -26, -30, -25, -27, -25, -25, -25, -24, -25, -22, -25, -21, -25, -18, -25, -34, -24, -31, -24, -30, -24, -24, -24, -21, -24, -18, -24, -16, -24, -34, -23, -25, -23, -24, -23, -18, -23, -17, -23, -16, -23, -34, -22, -31, -22, -27, -22, -24, -22, -23, -22, -18, -22, -14, -22, -33, -21, -27, -21, -26, -21, -25, -21, -23, -21, -17, -21, -14, -21, -27, -20, -26, -20, -23, -20, -22, -20, -16, -20, -14, -20, -25, -19, -22, -19, -20, -19, -27, -18, -26, -18, -25, -18, -21, -18, -20, -18, -19, -18, -18, -18, -16, -18, -15, -18, -10, -18, -9, -18, -25, -17, -21, -17, -18, -17, -16, -17, -15, -17, -14, -17, -10, -17, -9, -17, -21, -16, -20, -16, -18, -16, -17, -16, -16, -16, -14, -16, -10, -16, -7, -16, -21, -15, -20, -15, -14, -15, -11, -15, -10, -15, -9, -15, -7, -15, -16, -14, -12, -14, -11, -14, -10, -14, -9, -14, -8, -14, -6, -14, -5, -14, -15, -13, -5, -13, -3, -13, -15, -12, -5, -12, -18, -11, -17, -11, -14, -11, -13, -11, -12, -11, -10, -11, -9, -11, -8, -11, -7, -11, -6, -11, -2, -11, -18, -10, -17, -10, -16, -10, -8, -10, -7, -10, -4, -10, -16, -9, -12, -9, -11, -9, -9, -9, -6, -9, -4, -9, -1, -9, -15, -8, -14, -8, -13, -8, -12, -8, -11, -8, -9, -8, -7, -8, -3, -8, -1, -8, -13, -7, -11, -7, -9, -7, -7, -7, -15, -6, -14, -6, -13, -6, -12, -6, -11, -6, -9, -6, -7, -6, -6, -6, -5, -6, -2, -6, -15, -5, -14, -5, -13, -5, -11, -5, -9, -5, -8, -5, -7, -5, -6, -5, -5, -5, -4, -5, -1, -5, -11, -4, -10, -4, -7, -4, -6, -4, -5, -4, -2, -4, -10, -3, -8, -3, -6, -3, -4, -3, -3, -3, -2, -3, -8, -2, -7, -2, -4, -2], [-23, -36, -22, -36, -24, -35, -23, -34, -22, -34, -22, -33, -25, -32, -23, -32, -25, -31, -23, -31, -24, -30, -21, -29, -21, -28, -26, -27, -24, -27, -23, -27, -22, -27, -21, -27, -20, -27, -19, -27, -18, -27, -34, -26, -25, -26, -20, -26, -19, -26, -17, -26, -34, -25, -28, -25, -27, -25, -25, -25, -22, -25, -21, -25, -17, -25, -31, -24, -30, -24, -29, -24, -28, -24, -27, -24, -25, -24, -21, -24, -34, -23, -33, -23, -32, -23, -31, -23, -28, -23, -23, -23, -18, -23, -17, -23, -16, -23, -34, -22, -33, -22, -32, -22, -27, -22, -26, -22, -24, -22, -20, -22, -17, -22, -15, -22, -23, -21, -16, -21, -15, -21, -14, -21, -26, -20, -22, -20, -16, -20, -15, -20, -27, -19, -26, -19, -22, -19, -27, -18, -26, -18, -21, -18, -20, -18, -19, -18, -16, -18, -15, -18, -12, -18, -9, -18, -24, -17, -19, -17, -18, -17, -15, -17, -10, -17, -9, -17, -24, -16, -20, -16, -14, -16, -8, -16, -7, -16, -5, -16, -21, -15, -20, -15, -17, -15, -16, -15, -14, -15, -9, -15, -8, -15, -7, -15, -5, -15, -14, -14, -12, -14, -11, -14, -10, -14, -15, -13, -14, -13, -13, -13, -12, -13, -5, -13, -4, -13, -3, -13, -13, -12, -5, -12, -4, -12, -3, -12, -18, -11, -17, -11, -14, -11, -13, -11, -10, -11, -9, -11, -3, -11, -2, -11, -18, -10, -17, -10, -14, -10, -11, -10, -8, -10, -7, -10, -6, -10, -4, -10, -2, -10, -15, -9, -14, -9, -9, -9, -3, -9, -2, -9, -1, -9, -15, -8, -14, -8, -12, -8, -11, -8, -9, -8, -8, -8, -7, -8, -3, -8, -2, -8, -11, -7, -9, -7, -7, -7, -15, -6, -14, -6, -11, -6, -9, -6, -3, -6, -2, -6, -14, -5, -12, -5, -9, -5, -8, -5, -6, -5, -5, -5, -4, -5, -3, -5, -2, -5, -10, -4, -7, -4, -2, -4, -10, -3, -9, -3, -8, -3, -3, -3, -8, -2, -6, -2, -5, -2, -3, -2]
Code: Select all
gdistance = ginfo / 4
phase = ginfo % 4
Code: Select all
gdistance = n * ginfo / p
phase = ginfo % p
Code: Select all
for w in xrange(rect[2] + 5):
Code: Select all
glidersexist = (g.evolve([-1, -2, 0, -1, -2, 0, -1, 0, 0, 0], 4) == [0, -1, 1, 0, -1, 1, 0, 1, 1, 1])
You mean g.parse()?gameoflifeboy wrote:I guess I could implement an RLE-to-cell-list converter so that the spaceship can be read from the clipboard, but I haven't done this yet.
Code: Select all
x = 17, y = 12, rule = Mirrors
7.3A$8.A$6.2A.2A$3.11A$2A4.A.A.A4.2A$A5.A3.A5.A$A15.A$.2A.3A3.3A.2A$
4.A2.A.A2.A$4.2A.A.A.2A$4.2A5.2A$4.3A3.3A!