Re: Script request thread
Posted: March 18th, 2021, 6:53 pm
A program for searching for ancestors of a certain pattern that fit within a certain bounding box or have fewer than a certain amount of cells.
Have you tried JavaLifeSearch, or the older Windows version WLS? They can perform those tasks fairly well, depending on exactly what you want.yaochen2 wrote: March 18th, 2021, 6:53 pm A program for searching for ancestors of a certain pattern that fit within a certain bounding box or have fewer than a certain amount of cells.
This Lua script will save the current pattern into Golly's temp folder as "pattern.png". Maximum pattern size is 4096 x 4096.Entity Valkyrie 2 wrote: April 4th, 2021, 3:06 am Is there a script that can turn a pattern into a static png?
Code: Select all
-- Save current pattern as a PNG
--
-- Author:
-- Chris Rowett (crowett@gmail.com)
local g = golly()
local gp = require "gplus"
require "gplus.strict"
-- overlay
local ov = g.overlay
local overlaycreated = false
-- temporary file path
local temppath = g.getdir("temp")
--------------------------------------------------------------------------------
local function savepng()
-- get the bounding box of the pattern
local box = g.getrect()
if #box == 0 then
g.note("There is no pattern.")
else
-- get the size of the pattern
local x, y, wd, ht = table.unpack(box)
local cwd = wd
local cht = ht
-- cellview width and height must be multiples of 16
if cwd & 15 ~= 0 then
cwd = ((cwd // 16) + 1) * 16
end
if cht & 15 ~= 0 then
cht = ((cht // 16) + 1) * 16
end
-- check the width or height are not bigger than the cellview maximum
if wd > 4096 or ht > 4096 then
g.note("Pattern too big! Maximum is 4096x4096.")
else
-- create the overlay
ov("create "..cwd.. " "..cht)
overlaycreated = true
-- draw the pattern onto the overlay
ov("cellview "..x.." "..y.." "..cwd.." "..cht)
ov("drawcells")
ov("update")
-- save the overlay as a PNG
local savefile = temppath.."pattern.png"
ov("save 0 0 "..wd.." "..ht.." "..savefile)
-- delete overlay
ov("delete")
g.update()
overlaycreated = false
g.note("Saved pattern of size "..wd.."x"..ht.." to "..savefile)
end
end
end
--------------------------------------------------------------------------------
local status, err = xpcall(savepng, gp.trace)
if err then g.continue(err) end
-- this code is always executed, even after escape/error;
-- clear message line in case there was no escape/error
g.check(false)
if overlaycreated then ov("delete") end
LifeWiki Help:Images says that you can just use the standard giffer.py with Number of generations = 1, then open the resulting .gif in any image-editing program and save as .png.Entity Valkyrie 2 wrote: April 4th, 2021, 3:06 am Is there a script that can turn a pattern into a static png?
I think there was one; but I can’t remember what it is.Cyclotrons wrote: April 6th, 2021, 11:25 am Would anyone mind writing a script that enumerates every collision of 2 of a given ship?
Here you go! Note that this only works on diagonal ships. (I'm making one for orthogonal ships.) Before using, make a layer with the ship you want to collide traveling southwest.Cyclotrons wrote: April 6th, 2021, 11:25 am Would anyone mind writing a script that enumerates every collision of 2 of a given ship?
Code: Select all
import golly as g
shippattern = g.getcells(g.getrect())
layerindex = g.getlayer()
collideship = []
popseq1 = []
popseq2 = []
g.addlayer()
g.setname("Ship collider space")
g.putcells(shippattern)
box = g.getrect()
g.select(g.getrect())
g.flip(1)
# For perpendicular collisions
flipship = g.getcells(g.getrect())
g.addlayer()
g.setname("Ship evolving space")
g.putcells(flipship)
g.addlayer()
g.setname("Collisions")
g.setlayer(layerindex + 2)
# Find the spaceship period
shiphash = g.hash(g.getrect())
period = 0
while True:
g.run(1)
period += 1
if g.hash(g.getrect()) == shiphash:
break
if period > 500:
g.exit("Period is too large! Are you sure the pattern is a spaceship?")
g.reset()
shipseq = [0] * period
def clear_layer():
r = g.getrect()
if r:
g.select(r)
g.clear(0)
return
# Checks if two spaceships interact.
def interact():
popseq = [[0] * 10] * period
for j in range(10):
for i in range(period):
g.run(1)
popseq[i][j] = int(g.getpop())
notequal = False
for j in range(10):
for i in range(period):
if popseq[i][j] != shipseq[i]:
notequal = True
if notequal == False:
return False
else:
return True
g.reset()
# Enumerating collisions
def putcollision(orientation, i, j):
if interact() == True:
g.reset()
collision = g.getcells(g.getrect())
g.setlayer(layerindex + 3)
if orientation == 0:
g.putcells(collision, 100 * j, - 100 * i)
else:
g.putcells(collision, 100 * j, 100 * i + 100)
g.setlayer(layerindex + 1)
g.reset()
def makecollision():
g.setlayer(layerindex + 1)
for i in range(period):
g.setlayer(layerindex + 2)
g.run(1)
collideship = g.getcells(g.getrect())
g.setlayer(layerindex + 1)
clear_layer()
g.putcells(shippattern)
g.putcells(collideship, 500, 500)
for k in range(period):
shipseq[k] = int(g.getpop())
for j in range(box[2] * 8):
g.reset()
clear_layer()
# Perpendicular collisions
g.putcells(shippattern, 0, 0)
g.putcells(collideship, j - 3 * box[2], box[3] + 3)
putcollision(0, i, j)
# Head-on collisions
g.select(box)
g.flip(0)
putcollision(1, i, j)
def deletelayers():
g.setlayer(layerindex + 1)
g.dellayer()
g.setlayer(layerindex + 1)
g.dellayer()
makecollision()
deletelayers()
Code: Select all
x = 9, y = 17, rule = B3/S23
7b2o$6b2o$8bo$bo$3o$ob2o$b3o$b2o5$3bo$2b3o$2bob2o$3b3o$3b2o!
Code: Select all
x = 96, y = 95, rule = B2e/S
14$14bobo57bo$13bo3bo21bobo33bo$12bo5bo19bo3bo33bo$11bo7bo17bo5bo33bo$
10bo9bo15bo7bo33bo$9bo11bo13bo9bo33bo$8bo13bo11bo11bo33bo$7bo15bo9bo
13bo33bo$6bo17bo7bo15bo33bo$5bo19bo5bo17bo33bo$4bo21bo3bo19bo33bo$3bo
23bobo55bo$2bo47bo35bo$49bo37bo$2bo45bo39bo$3bo43bo41bo$4bo41bo43bo$5b
o39bo45bo$6bo37bo47bo$7bo35bo49bo$8bo33bo51bo$9bo17bobo$10bo15bo3bo9bo
53bo$11bo13bo5bo7bo53bo$12bo11bo13bo53bo$13bo17bo5bo53bo$14bo7bo7bo5bo
53bo$15bo5bo13bo53bo$20bo7bo5bo53bo$15bo3bo13bo53bo$14bo3bo67bo$13bo
17bo53bo$12bo5bo11bo53bo$11bo7bo9bo53bo$10bo9bo7bo53bo$9bo11bo5bo53bo$
8bo13bo3bo53bo$7bo15bobo53bo$6bo71bo$5bo71bo$4bo71bo$3bo71bo$2bo$bo71b
o$34bobo35bo$bo31bo3bo33bo$2bo29bo5bo31bo$3bo27bo7bo29bo$4bo25bo9bo27b
o$5bo23bo11bo25bo$6bo21bo13bo23bo$7bo19bo15bo21bo$8bo17bo17bo19bo$9bo
15bo19bo17bo$10bo13bo21bo15bo$11bo11bo23bo13bo$12bo9bo25bo11bo$13bo7bo
27bo9bo$14bo5bo29bo7bo$15bo3bo31bo5bo$16bobo33bo3bo$53bobo!
Code: Select all
x = 94, y = 62, rule = marg3diag
13.A.A57.A$12.A3.A21.A.A33.A$11.A5.A19.A3.A33.A$10.A7.A17.A5.A33.A$9.
A9.A15.A7.A33.A$8.A11.A13.A9.A33.A$7.A13.A11.A11.A33.A$6.A15.A9.A13.A
33.A$5.A17.A7.A15.A33.A$4.A19.A5.A17.A33.A$3.A21.A3.A19.A33.A$2.A23.A
.A55.A$.A47.A35.A$48.A37.A$.A45.A39.A$2.A43.A41.A$3.A41.A43.A$4.A39.A
45.A$5.A37.A47.A$6.A35.A49.A$7.A33.A51.A$8.A17.A.A$9.A15.A3.A9.A53.A$
10.A13.A5.A7.A53.A$11.A11.A13.A53.A$12.A17.A5.A53.A$13.A7.A7.A5.A53.A
$14.A5.A13.A53.A$19.A7.A5.A53.A$14.A3.A13.A53.A$13.A3.A67.A$12.A17.A
53.A$11.A5.A11.A53.A$10.A7.A9.A53.A$9.A9.A7.A53.A$8.A11.A5.A53.A$7.A
13.A3.A53.A$6.A15.A.A53.A$5.A71.A$4.A71.A$3.A71.A$2.A71.A$.A$A71.A$
33.A.A35.A$A31.A3.A33.A$.A29.A5.A31.A$2.A27.A7.A29.A$3.A25.A9.A27.A$
4.A23.A11.A25.A$5.A21.A13.A23.A$6.A19.A15.A21.A$7.A17.A17.A19.A$8.A
15.A19.A17.A$9.A13.A21.A15.A$10.A11.A23.A13.A$11.A9.A25.A11.A$12.A7.A
27.A9.A$13.A5.A29.A7.A$14.A3.A31.A5.A$15.A.A33.A3.A$52.A.A!
Code: Select all
x = 94, y = 62, rule = marg5diag
13.A.A57.A$12.A3.A21.A.A33.A$11.A5.A19.A3.A33.A$10.A7.A17.A5.A33.A$9.
A9.A15.A7.A33.A$8.A11.A13.A9.A33.A$7.A13.A11.A11.A33.A$6.A15.A9.A13.A
33.A$5.A17.A7.A15.A33.A$4.A19.A5.A17.A33.A$3.A21.A3.A19.A33.A$2.A23.A
.A55.A$.A47.A35.A$48.A37.A$.A45.A39.A$2.A43.A41.A$3.A41.A43.A$4.A39.A
45.A$5.A37.A47.A$6.A35.A49.A$7.A33.A51.A$8.A17.A.A$9.A15.A3.A9.A53.A$
10.A13.A5.A7.A53.A$11.A11.A13.A53.A$12.A17.A5.A53.A$13.A7.A7.A5.A53.A
$14.A5.A13.A53.A$19.A7.A5.A53.A$14.A3.A13.A53.A$13.A3.A67.A$12.A17.A
53.A$11.A5.A11.A53.A$10.A7.A9.A53.A$9.A9.A7.A53.A$8.A11.A5.A53.A$7.A
13.A3.A53.A$6.A15.A.A53.A$5.A71.A$4.A71.A$3.A71.A$2.A71.A$.A$A71.A$
33.A.A35.A$A31.A3.A33.A$.A29.A5.A31.A$2.A27.A7.A29.A$3.A25.A9.A27.A$
4.A23.A11.A25.A$5.A21.A13.A23.A$6.A19.A15.A21.A$7.A17.A17.A19.A$8.A
15.A19.A17.A$9.A13.A21.A15.A$10.A11.A23.A13.A$11.A9.A25.A11.A$12.A7.A
27.A9.A$13.A5.A29.A7.A$14.A3.A31.A5.A$15.A.A33.A3.A$52.A.A!
Specifically for the commonly seen "modulo of overlapping rectangles" rules, on the checkerboard medium.muzik wrote: April 21st, 2021, 1:51 amCould a script for generating n-state margolus ruletables be made?
Code: Select all
@RULE marg2diag
@TABLE
n_states:2
neighborhood:vonNeumann
symmetries:rotate4reflect
0,0,0,1,1,1
1,0,0,0,0,0
Code: Select all
@RULE marg3diag
@TABLE
n_states:3
neighborhood:vonNeumann
symmetries:rotate4reflect
0,0,0,1,1,1
0,0,2,1,2,1
0,2,2,2,2,1
0,0,0,2,2,2
0,0,1,2,1,2
0,1,1,1,1,2
1,0,0,0,0,0
2,0,0,0,0,0Code: Select all
@RULE marg5diag
@TABLE
n_states:5
neighborhood:vonNeumann
symmetries:r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,4,6,2,6
0,0,3,6,3,6
0,5,4,1,2,6
0,4,3,2,3,6
0,5,3,1,3,6
0,4,4,2,2,6
0,5,5,1,1,6
0,3,3,3,3,6
1,0,0,0,0,0
2,0,0,0,0,0
3,0,0,0,0,0
4,0,0,0,0,0
5,0,0,0,0,0
6,0,0,0,0,0I think this works: https://www.conwaylife.com/forums/viewt ... les#p56734
\golly-4.0-win-64bit\Scripts\Python\Rule-Generators\make-ruletree.pyEntity Valkyrie 2 wrote: July 10th, 2021, 4:04 am Is there a script that can turn a rule @TABLE into an @TREE?
Same folder.
My memory of strobing rules is pretty vague at this point. A rule's "strobing complement" in general is two alternating rules, right?muzik wrote: August 19th, 2021, 8:51 am Are there any scripts that can turn a non-isotropic range-1 rule into its strobing complement?