Script request thread

For scripts to aid with computation or simulation in cellular automata.
yaochen2
Posts: 10
Joined: September 5th, 2018, 11:48 pm

Re: Script request thread

Post by yaochen2 » 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.

User avatar
dvgrn
Moderator
Posts: 7860
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Script request thread

Post by dvgrn » March 19th, 2021, 7:58 am

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.
Have you tried JavaLifeSearch, or the older Windows version WLS? They can perform those tasks fairly well, depending on exactly what you want.

User avatar
creeperman7002
Posts: 262
Joined: December 4th, 2018, 11:52 pm

Re: Script request thread

Post by creeperman7002 » April 1st, 2021, 6:30 pm

Can rlifesrc have a feature that skips solutions containing non-interacting objects?
B2n3-jn/S1c23-y is an interesting rule. It has a replicator, a fake glider, an OMOS and SMOS, a wide variety of oscillators, and some signals. Also this rule is omniperiodic.
viewtopic.php?f=11&t=4856

User avatar
Entity Valkyrie 2
Posts: 1050
Joined: February 26th, 2019, 7:13 pm
Location: Hijuatl, Zumaland
Contact:

Re: Script request thread

Post by Entity Valkyrie 2 » April 4th, 2021, 3:06 am

Is there a script that can turn a pattern into a static png?
Bx222 IS MY WORST ENEMY.

Please click here for my own pages.

My recent rules:
StateInvestigator 3.0
B3-kq4ej5i6ckn7e/S2-i34q6a7
B3-kq4ej5y6c/S2-i34q5e
Move the Box

User avatar
rowett
Moderator
Posts: 2356
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: Script request thread

Post by rowett » April 4th, 2021, 4:58 am

Entity Valkyrie 2 wrote:
April 4th, 2021, 3:06 am
Is there a script that can turn a pattern into a static png?
This Lua script will save the current pattern into Golly's temp folder as "pattern.png". Maximum pattern size is 4096 x 4096.

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

User avatar
GUYTU6J
Posts: 1374
Joined: August 5th, 2016, 10:27 am
Location: 拆哪!I repeat, CHINA! (a.k.a. 种花家)
Contact:

Re: Script request thread

Post by GUYTU6J » April 4th, 2021, 4:59 am

Entity Valkyrie 2 wrote:
April 4th, 2021, 3:06 am
Is there a script that can turn a pattern into a static png?
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.
BTW in Special:UnusedFiles you can see lots of blur gray-background images (both static and animated) by exactly you. Would you mind deleting them so as to save storage space?
Lifequote:
In the drama The Peony Pavilion, Tang Xianzu wrote: 原来姹紫嫣红开遍,似这般都付与断井颓垣。
(Here multiflorate splendour blooms forlorn
Midst broken fountains, mouldering walls.)
I'm afraid there's arrival but no departure.
Stop Japan from dumping nuclear waste!

Cyclotrons
Posts: 27
Joined: January 26th, 2021, 12:19 am

Re: Script request thread

Post by Cyclotrons » April 6th, 2021, 11:25 am

Would anyone mind writing a script that enumerates every collision of 2 of a given ship?
I wrote random rule generators for 3-State Outer-Totalistic rules and for 2-State Isotropic Non-Totalistic rules!

I created a notation for the 3-State Isotropic Non-Totalistic rulespace and wrote a generator for it!

User avatar
yujh
Posts: 2173
Joined: February 27th, 2020, 11:23 pm
Location: 我不觉得我迷路了,但是我不知道我在哪里
Contact:

Re: Script request thread

Post by yujh » April 6th, 2021, 6:42 pm

Cyclotrons wrote:
April 6th, 2021, 11:25 am
Would anyone mind writing a script that enumerates every collision of 2 of a given ship?
I think there was one; but I can’t remember what it is.

User avatar
goldenratio
Posts: 291
Joined: July 26th, 2020, 10:39 pm

Re: Script request thread

Post by goldenratio » April 8th, 2021, 1:41 pm

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.

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()
Note that this makes a lot of layers, so hopefully you don't have too many open before running the script.

For larger ships, lines 45, 46, and 51 might need to be modified to allow later interactions.
Will be mostly inactive until June

excessively staging syntheses is bad, don't question it

Help expand or create new tutorials on LifeWiki!

User avatar
PC101
Posts: 135
Joined: May 9th, 2019, 11:32 pm
Location: :uoᴉʇɐɔo˥

Re: Script request thread

Post by PC101 » April 8th, 2021, 4:49 pm

Can someone make a script that generates collisions between a NW travelling glider and 2 upward travelling LWSSs? And before it generates those collisions it

Can someone make a script that does this?
Step 1: Generate all combinations of 2 upward LWSSs at a certain distance from each other (they can also be different phases from each other).
Step 2: Generate all combinations of a NW travelling glider colliding with all the combinations of the upward LWSS generated from the previous step.
Step 3: Filter the output of step 2 so the only combinations left from step 2are ones where a NW glider collides with an LWSS pair, then gets reflected into a NE travelling glider without any leftover ash.

Example of a combination of 2 Upward LWSSs + NW glider = NE glider:

Code: Select all

x = 9, y = 17, rule = B3/S23
7b2o$6b2o$8bo$bo$3o$ob2o$b3o$b2o5$3bo$2b3o$2bob2o$3b3o$3b2o!

EDIT March 12: I was finally able to get gencols working so I will use gencols for each step.
Puffer Suppressor
Would we be able to know when we know everything there is to know?
How would we know what we don’t know that we don’t know?

Still working on the (34,7)c/156 caterpillar <- HELP WANTED!

User avatar
LaundryPizza03
Posts: 1276
Joined: December 15th, 2017, 12:05 am
Location: Unidentified location "https://en.wikipedia.org/wiki/Texas"

Re: Script request thread

Post by LaundryPizza03 » April 13th, 2021, 12:43 am

A script to convert EnumPattEvo output to an sss file. Attached is a partial sample run which found 373 ships in a B2a rulespace.
Output - EnumPattEvo.txt
(32.02 KiB) Downloaded 13 times

Code: Select all

x = 4, y = 3, rule = B3-q4z5y/S234k5j
2b2o$b2o$2o!
LaundryPizza03 at Wikipedia

The latest edition of new-gliders.db.txt and oscillators.db.txt have 31531 spaceships and 1293 oscillators from outer-totalistic rules. You are invited to help!

User avatar
muzik
Posts: 4184
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Script request thread

Post by muzik » April 21st, 2021, 1:51 am

Could a script for generating n-state margolus ruletables be made?

For example, inputting 2 would result in a rule with this behaviour:

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!
3 would result in this:

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!
and 5 this:

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!

User avatar
muzik
Posts: 4184
Joined: January 28th, 2016, 2:47 pm
Location: Scotland

Re: Script request thread

Post by muzik » April 21st, 2021, 3:06 pm

muzik wrote:
April 21st, 2021, 1:51 am
Could a script for generating n-state margolus ruletables be made?
Specifically for the commonly seen "modulo of overlapping rectangles" rules, on the checkerboard medium.

For clarity, (probably with a simpler name) this would be the table generated for n=2:

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
this for n=3:

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,0
this for n=5

Code: Select all

@RULE marg5diag
@TABLE
n_states:5
neighborhood:vonNeumann
symmetries:rotate4reflect

0,0,0,1,1,1
0,0,2,1,4,1
0,0,3,1,3,1
0,2,3,4,3,1
0,2,2,4,4,1
0,3,3,3,3,1
0,0,0,2,2,2
0,0,4,2,3,2
0,0,1,2,1,2
0,4,1,3,1,2
0,4,4,3,3,2
0,1,1,1,1,2
0,0,0,3,3,3
0,0,1,3,2,3
0,0,4,3,4,3
0,1,4,2,4,3
0,1,1,2,2,3
0,4,4,4,4,3
0,0,0,4,4,4
0,0,3,4,1,4
0,0,2,4,2,4
0,3,2,1,2,4
0,3,3,1,1,4
0,2,2,2,2,4
1,0,0,0,0,0
2,0,0,0,0,0
3,0,0,0,0,0
4,0,0,0,0,0
and this for n=7:

Code: Select all

@RULE marg7diag
@TABLE
n_states:7
neighborhood:vonNeumann
symmetries:rotate4reflect

0,0,0,1,1,1
0,0,2,1,6,1
0,0,3,1,5,1
0,0,4,1,4,1
0,2,3,6,5,1
0,3,4,5,4,1
0,2,4,6,4,1
0,3,3,5,5,1
0,2,2,6,6,1
0,4,4,4,4,1
0,0,0,2,2,2
0,0,4,2,5,2
0,0,6,2,3,2
0,0,1,2,1,2
0,4,6,5,3,2
0,6,1,3,1,2
0,4,1,5,1,2
0,6,6,3,3,2
0,4,4,5,5,2
0,1,1,1,1,2
0,0,0,3,3,3
0,0,6,3,4,3
0,0,2,3,1,3
0,0,5,3,5,3
0,6,2,4,1,3
0,2,5,1,5,3
0,6,5,4,5,3
0,2,2,1,1,3
0,6,6,4,4,3
0,5,5,5,5,3
0,0,0,4,4,4
0,0,1,4,3,4
0,0,5,4,6,4
0,0,2,4,2,4
0,1,5,3,6,4
0,5,2,6,2,4
0,1,2,3,2,4
0,5,5,6,6,4
0,1,1,3,3,4
0,2,2,2,2,4
0,0,0,5,5,5
0,0,3,5,2,5
0,0,1,5,4,5
0,0,6,5,6,5
0,3,1,2,4,5
0,1,6,4,6,5
0,3,6,2,6,5
0,1,1,4,4,5
0,3,3,2,2,5
0,6,6,6,6,5
0,0,0,6,6,6
0,0,5,6,1,6
0,0,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,0
Note that these are the most basic ruletables designed for single oscillators and that two cells being orthogonally adjacent causes undefined behaviour. Allowing oscillators to weave in and out of each other and exist on two different checkerboards, while preferable, would result in a much larger ruletable.

User avatar
cgoler2
Posts: 147
Joined: March 10th, 2021, 2:32 pm

Re: Script request thread

Post by cgoler2 » April 29th, 2021, 4:03 pm

Can there be a Lua script which shows all objects inside a Ctrl+5 soup?

Post Reply