Thread for your script-related questions

For scripts to aid with computation or simulation in cellular automata.
User avatar
wwei47
Posts: 1648
Joined: February 18th, 2021, 11:18 am

Re: Thread for your script-related questions

Post by wwei47 » April 30th, 2022, 10:21 am

LLAMASKYWALKER wrote:
April 30th, 2022, 1:38 am
I literally am not changing anything at all. I just hit start.
Try this.
Press Ctrl-P. This will bring up the "Properties" box under the "Edit field" tab. In the top left, there will be a panel labeled "Dimensions". You will see three numbers set to 35, 15, and 4 respectively. Change the first one to 5 and the second one to 6. Now, click the "Tiling/translation" tab. See the "After the last generation is..." panel? There are two numbers set to 0 and 0 by default. Change the second one to -2.

Now, you want to set the search order to make the search faster. It won't matter here when the box is so small, but it will make a HUGE difference with larger searches. Press Ctrl-T to open the "Options..." box. Go to the "Sorting" tab. The "Area" panel is our interest this time. Observe that one box is yellow-the one labeled "Horizontal". Click the one labeled "Vertical" to make it yellow instead.

Now, let's specify a cell for JLS to start from. In generation 0, click the cell in column 2 and cell 1 to set it to "on"; this tells JLS to look for ships where this cell is on.

Now, press Ctrl-G. If all went well, you've just found the LWSS!
Help me find high-period c/2 technology!
My guide: https://bit.ly/3uJtzu9
My c/2 tech collection: https://bit.ly/3qUJg0u
Overview of periods: https://bit.ly/3LwE0I5
Most wanted periods: 76,116

User avatar
LLAMASKYWALKER
Posts: 168
Joined: December 2nd, 2021, 1:02 pm

Re: Thread for your script-related questions

Post by LLAMASKYWALKER » April 30th, 2022, 11:09 am

wwei47 wrote:
April 30th, 2022, 10:21 am
LLAMASKYWALKER wrote:
April 30th, 2022, 1:38 am
I literally am not changing anything at all. I just hit start.
Try this.
Press Ctrl-P. This will bring up the "Properties" box under the "Edit field" tab. In the top left, there will be a panel labeled "Dimensions". You will see three numbers set to 35, 15, and 4 respectively. Change the first one to 5 and the second one to 6. Now, click the "Tiling/translation" tab. See the "After the last generation is..." panel? There are two numbers set to 0 and 0 by default. Change the second one to -2.

Now, you want to set the search order to make the search faster. It won't matter here when the box is so small, but it will make a HUGE difference with larger searches. Press Ctrl-T to open the "Options..." box. Go to the "Sorting" tab. The "Area" panel is our interest this time. Observe that one box is yellow-the one labeled "Horizontal". Click the one labeled "Vertical" to make it yellow instead.

Now, let's specify a cell for JLS to start from. In generation 0, click the cell in column 2 and cell 1 to set it to "on"; this tells JLS to look for ships where this cell is on.

Now, press Ctrl-G. If all went well, you've just found the LWSS!

thx! wait can it find puffers and how do i make a .lif file?

Code: Select all

x = 5, y = 5, rule = B3/S12o3H
bo$2obo$3bo$b2obo$3bo!

Code: Select all

x = 15, y = 11, rule = 23/34/10
2$6.F.B$5.GICDA$4.H3I2D2A$4.I3.GF2A$7.FAD2A$8.2A!

Code: Select all

x = 8, y = 14, rule = B3-q4z5y/S234k5j
4b2o$4bo2bo$5b3o7$2o2b3o$2obo3bo$3bo3bo$3bo3bo$4b3o!
CGoL is my hobby

User avatar
wwei47
Posts: 1648
Joined: February 18th, 2021, 11:18 am

Re: Thread for your script-related questions

Post by wwei47 » April 30th, 2022, 11:47 am

LLAMASKYWALKER wrote:
April 30th, 2022, 11:09 am
thx! wait can it find puffers and how do i make a .lif file?
Ctrl-T again. This time check the "Append solutions to file" box and click the "Browse..." button, and type in the name of the file you want. If it doesn't exist, JLS will create it for you once it finds a solution.

JLS isn't exactly for puffers. I have found a few puffers with it, but I've almost always done so by running a spaceship search for a stabilization of an engine that I found with some other method. The few exceptions were "I was watching JLS and saw a thin connection so I tried pausing (Esc key), taking off the back, and it started puffing on me.".
Help me find high-period c/2 technology!
My guide: https://bit.ly/3uJtzu9
My c/2 tech collection: https://bit.ly/3qUJg0u
Overview of periods: https://bit.ly/3LwE0I5
Most wanted periods: 76,116

User avatar
LLAMASKYWALKER
Posts: 168
Joined: December 2nd, 2021, 1:02 pm

Re: Thread for your script-related questions

Post by LLAMASKYWALKER » April 30th, 2022, 11:51 am

wwei47 wrote:
April 30th, 2022, 11:47 am
LLAMASKYWALKER wrote:
April 30th, 2022, 11:09 am
thx! wait can it find puffers and how do i make a .lif file?
Ctrl-T again. This time check the "Append solutions to file" box and click the "Browse..." button, and type in the name of the file you want. If it doesn't exist, JLS will create it for you once it finds a solution.

JLS isn't exactly for puffers. I have found a few puffers with it, but I've almost always done so by running a spaceship search for a stabilization of an engine that I found with some other method. The few exceptions were "I was watching JLS and saw a thin connection so I tried pausing (Esc key), taking off the back, and it started puffing on me.".
ok thx

Code: Select all

x = 5, y = 5, rule = B3/S12o3H
bo$2obo$3bo$b2obo$3bo!

Code: Select all

x = 15, y = 11, rule = 23/34/10
2$6.F.B$5.GICDA$4.H3I2D2A$4.I3.GF2A$7.FAD2A$8.2A!

Code: Select all

x = 8, y = 14, rule = B3-q4z5y/S234k5j
4b2o$4bo2bo$5b3o7$2o2b3o$2obo3bo$3bo3bo$3bo3bo$4b3o!
CGoL is my hobby

User avatar
LLAMASKYWALKER
Posts: 168
Joined: December 2nd, 2021, 1:02 pm

Re: Thread for your script-related questions

Post by LLAMASKYWALKER » April 30th, 2022, 11:52 am

might not belong here but how do i change my username on catagolue

Code: Select all

x = 5, y = 5, rule = B3/S12o3H
bo$2obo$3bo$b2obo$3bo!

Code: Select all

x = 15, y = 11, rule = 23/34/10
2$6.F.B$5.GICDA$4.H3I2D2A$4.I3.GF2A$7.FAD2A$8.2A!

Code: Select all

x = 8, y = 14, rule = B3-q4z5y/S234k5j
4b2o$4bo2bo$5b3o7$2o2b3o$2obo3bo$3bo3bo$3bo3bo$4b3o!
CGoL is my hobby

User avatar
yujh
Posts: 3066
Joined: February 27th, 2020, 11:23 pm
Location: I'm not sure where I am, so please tell me if you know
Contact:

Re: Thread for your script-related questions

Post by yujh » April 30th, 2022, 12:07 pm

LLAMASKYWALKER wrote:
April 30th, 2022, 11:52 am
might not belong here but how do i change my username on catagolue
your key or your username on the comments section?

User avatar
LLAMASKYWALKER
Posts: 168
Joined: December 2nd, 2021, 1:02 pm

Re: Thread for your script-related questions

Post by LLAMASKYWALKER » April 30th, 2022, 12:08 pm

yujh wrote:
April 30th, 2022, 12:07 pm
LLAMASKYWALKER wrote:
April 30th, 2022, 11:52 am
might not belong here but how do i change my username on catagolue
your key or your username on the comments section?
username, it will not let me log into my new key

Code: Select all

x = 5, y = 5, rule = B3/S12o3H
bo$2obo$3bo$b2obo$3bo!

Code: Select all

x = 15, y = 11, rule = 23/34/10
2$6.F.B$5.GICDA$4.H3I2D2A$4.I3.GF2A$7.FAD2A$8.2A!

Code: Select all

x = 8, y = 14, rule = B3-q4z5y/S234k5j
4b2o$4bo2bo$5b3o7$2o2b3o$2obo3bo$3bo3bo$3bo3bo$4b3o!
CGoL is my hobby

User avatar
LLAMASKYWALKER
Posts: 168
Joined: December 2nd, 2021, 1:02 pm

Re: Thread for your script-related questions

Post by LLAMASKYWALKER » May 2nd, 2022, 5:47 pm

Is there a way to simulate 3d ca?

Code: Select all

x = 5, y = 5, rule = B3/S12o3H
bo$2obo$3bo$b2obo$3bo!

Code: Select all

x = 15, y = 11, rule = 23/34/10
2$6.F.B$5.GICDA$4.H3I2D2A$4.I3.GF2A$7.FAD2A$8.2A!

Code: Select all

x = 8, y = 14, rule = B3-q4z5y/S234k5j
4b2o$4bo2bo$5b3o7$2o2b3o$2obo3bo$3bo3bo$3bo3bo$4b3o!
CGoL is my hobby

User avatar
ClippyCosmologist
Posts: 22
Joined: May 7th, 2022, 5:24 pm

Re: Thread for your script-related questions

Post by ClippyCosmologist » May 16th, 2022, 5:43 pm

On the LifeWiki page for the x66, it says
Its name refers to the fact that every cell (alive or dead) has at most 6 live neighbours (in contrast to spaceships based on lightweight spaceships, middleweight spaceships, or heavyweight spaceships). In fact, this spaceship was found via a search with this restriction. From this follows that the spaceship is stable also in Life-like rules allowing birth or survival for a cell with 7 or 8 neighbors.
What scripts can perform such restricted searches?
"Human beings, five hundred years after the Scientific Revolution, are only just starting to match their wits against the billion-year heritage of biology." -- E. Yudkowsky

User avatar
NimbleRogue
Posts: 524
Joined: January 11th, 2021, 11:48 pm

Re: Thread for your script-related questions

Post by NimbleRogue » May 17th, 2022, 1:10 am

I'm finally getting around to using the command line for apgmera, ikpx, and the like. I built the command line in visual studio and I'm wondering how to get the programs to start running. Any help? Thanks.

Code: Select all

x = 4, y = 3, rule = B3-cnqy4e5kr6n7c/S2-i3-ay4einrtyz5cejn6cin78
bo$3o$ob2o!

Code: Select all

#14c/85265o
x = 10, y = 4, rule = B2-an3-iqy4iknrtz5aijqy6aei78/S02ck3nqy4eiqrtwy5-ekq6-i78
2bo4bo$3b4o$ob6obo$2b6o!

User avatar
silversmith
Posts: 323
Joined: June 15th, 2020, 6:20 pm
Location: Pennsylvania, USA, Earth, Sector 5ff63D6
Contact:

Re: Thread for your script-related questions

Post by silversmith » May 17th, 2022, 6:56 pm

To start off the simplest way to get the program is to setup git on your command line environment. You can do so by typing the “git” command and see if it is recognized. Then you would clone the repo, which is done by navigating to the folder where you want to put the program, and then running the command to actually clone the repo. For apgmera the command would be:

Code: Select all

./git clone ‘https://gitlab.com/apgoucher/apgmera’
To clone other projects replace the url with the url of another git-based repository.

The front page of most program repos includes information on how to run it, for example:
https://gitlab.com/apgoucher/ikpx2
https://gitlab.com/apgoucher/apgmera

If you want to be credited with contributions to the catagolue website, first log in with a google account, then setup a payosha256 key to be used with your ikpx2 or apgmera searches. For more info goto https://conwaylife.com/wiki/Tutorials/C ... _Catagolue.

Examples
Ikpx2

Code: Select all

./recompile.sh --rule b38s23
./ikpx2 --velocity 'c/3'
Apgmera

Code: Select all

./apgluxe -n 20000000 --rule b38s23
A simulator with the tools I couldn’t find elsewhere: https://www.silversimulations.com/caplayer/
Documentation:https://github.com/teraxtech/caplayer

User avatar
NimbleRogue
Posts: 524
Joined: January 11th, 2021, 11:48 pm

Re: Thread for your script-related questions

Post by NimbleRogue » May 19th, 2022, 11:32 pm

I realized that the root of my problem was that I needed to build Clang, when I tried to I got this error, any help?

Code: Select all

CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Code: Select all

x = 4, y = 3, rule = B3-cnqy4e5kr6n7c/S2-i3-ay4einrtyz5cejn6cin78
bo$3o$ob2o!

Code: Select all

#14c/85265o
x = 10, y = 4, rule = B2-an3-iqy4iknrtz5aijqy6aei78/S02ck3nqy4eiqrtwy5-ekq6-i78
2bo4bo$3b4o$ob6obo$2b6o!

User avatar
pzq_alex
Posts: 792
Joined: May 1st, 2021, 9:00 pm
Location: tell me if you know

Re: Thread for your script-related questions

Post by pzq_alex » May 20th, 2022, 6:11 am

ClippyCosmologist wrote:
May 16th, 2022, 5:43 pm
On the LifeWiki page for the x66, it says
Its name refers to the fact that every cell (alive or dead) has at most 6 live neighbours (in contrast to spaceships based on lightweight spaceships, middleweight spaceships, or heavyweight spaceships). In fact, this spaceship was found via a search with this restriction. From this follows that the spaceship is stable also in Life-like rules allowing birth or survival for a cell with 7 or 8 neighbors.
What scripts can perform such restricted searches?
gfind has parameters called /xN and /zN. The former disallows BN, and the latter disallows SN.

None of its descendants (zfind, qfind, etc.) have this capability, though.
\sum_{n=1}^\infty H_n/n^2 = \zeta(3)

How much of current CA technology can I redevelop "on a desert island"?

AlbertArmStain
Posts: 1228
Joined: January 28th, 2022, 7:18 pm
Location: Planet Z

Re: Thread for your script-related questions

Post by AlbertArmStain » May 20th, 2022, 5:04 pm

Where do you run scripts on the computer?

User avatar
silversmith
Posts: 323
Joined: June 15th, 2020, 6:20 pm
Location: Pennsylvania, USA, Earth, Sector 5ff63D6
Contact:

Re: Thread for your script-related questions

Post by silversmith » May 21st, 2022, 8:34 am

AlbertArmStain wrote:
May 20th, 2022, 5:04 pm
Where do you run scripts on the computer?
Usually through a terminal/command line application. Sometimes through golly.

It depends on what script I am trying to run.
A simulator with the tools I couldn’t find elsewhere: https://www.silversimulations.com/caplayer/
Documentation:https://github.com/teraxtech/caplayer

User avatar
pzq_alex
Posts: 792
Joined: May 1st, 2021, 9:00 pm
Location: tell me if you know

Re: Thread for your script-related questions

Post by pzq_alex » June 6th, 2022, 8:03 am

affamatodidio wrote:
June 6th, 2022, 7:57 am
pzq_alex wrote:
June 6th, 2022, 7:52 am
(my previous post)
You can try LLS.
I have attempted to set up LLS before, and failed. I followed every step to a tee a second time, and it still failed. If LLS is the only way to accomplish the question I have posited in my original post, then I will take my requests to the ¨Requests - Non-APGsearch¨ thread.
What’s the problem, precisely? Also, these posts should better fit the “Thread for your script related questions”.

LLS is pretty standard for these kind of problems, and I’m currently unaware of other methods.
\sum_{n=1}^\infty H_n/n^2 = \zeta(3)

How much of current CA technology can I redevelop "on a desert island"?

User avatar
NimbleRogue
Posts: 524
Joined: January 11th, 2021, 11:48 pm

Re: Thread for your script-related questions

Post by NimbleRogue » June 16th, 2022, 9:13 pm

What's a good script for extending oscillator(specifically sparker) partials?

Code: Select all

x = 4, y = 3, rule = B3-cnqy4e5kr6n7c/S2-i3-ay4einrtyz5cejn6cin78
bo$3o$ob2o!

Code: Select all

#14c/85265o
x = 10, y = 4, rule = B2-an3-iqy4iknrtz5aijqy6aei78/S02ck3nqy4eiqrtwy5-ekq6-i78
2bo4bo$3b4o$ob6obo$2b6o!

atavoidirc
Posts: 49
Joined: April 14th, 2022, 3:09 pm

Re: Thread for your script-related questions

Post by atavoidirc » June 22nd, 2022, 5:13 pm

How do you apgsearch custom rules?

User avatar
Ian07
Moderator
Posts: 891
Joined: September 22nd, 2018, 8:48 am
Location: New Jersey, US

Re: Thread for your script-related questions

Post by Ian07 » June 22nd, 2022, 6:18 pm

atavoidirc wrote:
June 22nd, 2022, 5:13 pm
How do you apgsearch custom rules?
First, copy the rule file into somewhere in the apgmera folder, ideally in /lifelib/rules/source. Then, it can be invoked like so:

Code: Select all

./apgluxe --rule 'lifelib/rules/source/KnightGoL.table'
.rule, .tree, .table, and .ruel (i.e. Nutshell) files are all supported.

Some caveats:
  • apgsearch is only able to generate soups with state 0 and 1 cells. If the rule is designed such that a pattern consisting entirely of those states can never produce states 2+, you may need to modify it by moving all the states over by one and creating a new state 1 that turns itself into other states based on neighbor count. EDIT: Actually, a better way to do this might be using a stdin symmetry to input custom soups which can, in fact, start off with multiple states. Luckily, there's a tutorial on the wiki for this. A practical example can be found here - notice how the sample occurrences do not look like typical RLEs generated by SHA-256.
  • apgsearch assumes when making apgcodes that the rule is isotropic, so the symmetry should be either "rotate4reflect" or "permute".
The resulting census on Catagolue will start with an "x" and may or may not contain additional numbers at the beginning to indicate capitals in the rule name, as seen here.

User avatar
confocaloid
Posts: 2723
Joined: February 8th, 2022, 3:15 pm

Re: Thread for your script-related questions

Post by confocaloid » June 29th, 2022, 5:46 am

Is there a tool that can be used to determine and display the minimum repeat time/best compression of a spaceship - something that outputs 14 for the glider and the LWSS, 16 for the MWSS and 196 for Sir Robin? E.g. neither LifeViewer nor Catagolue provide this information (although I understand this might be in general prohibitively costly to compute).
127:1 B3/S234c User:Confocal/R (isotropic rules, incomplete)
Unlikely events happen.
My silence does not imply agreement, nor indifference. If I disagreed with something in the past, then please do not construe my silence as something that could change that.

User avatar
Ian07
Moderator
Posts: 891
Joined: September 22nd, 2018, 8:48 am
Location: New Jersey, US

Re: Thread for your script-related questions

Post by Ian07 » June 29th, 2022, 1:50 pm

confocaloid wrote:
June 29th, 2022, 5:46 am
Is there a tool that can be used to determine and display the minimum repeat time/best compression of a spaceship - something that outputs 14 for the glider and the LWSS, 16 for the MWSS and 196 for Sir Robin? E.g. neither LifeViewer nor Catagolue provide this information (although I understand this might be in general prohibitively costly to compute).
Another script I made years ago (June 26, 2020) and never bothered to publish until now:

Code: Select all

import golly as g
from glife import rect, pattern
from time import time

# --------------------------------------------------------------------

# initialize lists
hashlist = []        # for pattern hash values
genlist = []         # corresponding generation counts
poplist = []         # corresponding population counts
boxlist = []         # corresponding bounding boxes

# --------------------------------------------------------------------

pat = g.getcells(g.getrect())
p = 0

# --------------------------------------------------------------------

def oscillating():
    # return True if the pattern is empty, stable or oscillating

    # first get current pattern's bounding box
    prect = g.getrect()
    pbox = rect(prect)
    if pbox.empty:
        g.show("The pattern is empty.")
        return True

    # get current pattern and create hash of "normalized" version -- ie. shift
    # its top left corner to 0,0 -- so we can detect spaceships and knightships
    ## currpatt = pattern( g.getcells(prect) )
    ## h = hash( tuple( currpatt(-pbox.left, -pbox.top) ) )

    # use Golly's hash command (3 times faster than above code)
    h = g.hash(prect)

    # check if outer-totalistic rule has B0 but not S8
    rule = g.getrule().split(":")[0]
    hasB0notS8 = rule.startswith("B0") and (rule.find("/") > 1) and not rule.endswith("8")

    # determine where to insert h into hashlist
    pos = 0
    listlen = len(hashlist)
    while pos < listlen:
        if h > hashlist[pos]:
            pos += 1
        elif h < hashlist[pos]:
            # shorten lists and append info below
            del hashlist[pos : listlen]
            del genlist[pos : listlen]
            del poplist[pos : listlen]
            del boxlist[pos : listlen]
            break
        else:
            # h == hashlist[pos] so pattern is probably oscillating, but just in
            # case this is a hash collision we also compare pop count and box size
            if (int(g.getpop()) == poplist[pos]) and \
               (pbox.wd == boxlist[pos].wd) and \
               (pbox.ht == boxlist[pos].ht):
                period = int(g.getgen()) - genlist[pos]

                if hasB0notS8 and (period % 2 > 0) and (pbox == boxlist[pos]):
                    # ignore this hash value because B0-and-not-S8 rules are
                    # emulated by using different rules for odd and even gens,
                    # so it's possible to have identical patterns at gen G and
                    # gen G+p if p is odd
                    return False

                if pbox == boxlist[pos]:
                    # pattern hasn't moved
                    if period == 1:
                        g.show("The pattern is stable.")
                    else:
                        g.show("Oscillator detected (period = " + str(period) + ")")
                else:
                    global p
                    p = period
                return True
            else:
                # look at next matching hash value or insert if no more
                pos += 1

    # store hash/gen/pop/box info at same position in various lists
    hashlist.insert(pos, h)
    genlist.insert(pos, int(g.getgen()))
    poplist.insert(pos, int(g.getpop()))
    boxlist.insert(pos, pbox)

    return False

# --------------------------------------------------------------------

def fit_if_not_visible():
    # fit pattern in viewport if not empty and not completely visible
    r = rect(g.getrect())
    if (not r.empty) and (not r.visible()): g.fit()

# --------------------------------------------------------------------

def check_repeat_time(n):
    g.show("Checking for repeat time " + str(n))

    g.new("test")
    g.putcells(pat)
    g.run(n)
    g.putcells(pat, 0, 0, 1, 0, 0, 1, "xor")
    test_hash = g.hash(g.getrect())

    g.run(p)

    if len(g.getrect()) == 0: return False
    current_hash = g.hash(g.getrect())

    return current_hash == test_hash


g.show("Checking for oscillation... (hit escape to abort)")

oldsecs = time()
while not oscillating():
    g.run(1)
    newsecs = time()
    if newsecs - oldsecs >= 1.0:     # show pattern every second
        oldsecs = newsecs
        fit_if_not_visible()
        g.update()

fit_if_not_visible()

i = 1
while not check_repeat_time(i):
    i += 1

g.show(str(i))
I also made a "lazy" version that essentially does a binary search instead, although as a result it's not guaranteed to output the correct answer:

Code: Select all

import golly as g
from glife import rect, pattern
from time import time

# --------------------------------------------------------------------

# initialize lists
hashlist = []        # for pattern hash values
genlist = []         # corresponding generation counts
poplist = []         # corresponding population counts
boxlist = []         # corresponding bounding boxes

# --------------------------------------------------------------------

pat = g.getcells(g.getrect())
p = 0

# --------------------------------------------------------------------

def oscillating():
    # return True if the pattern is empty, stable or oscillating

    # first get current pattern's bounding box
    prect = g.getrect()
    pbox = rect(prect)
    if pbox.empty:
        g.show("The pattern is empty.")
        return True

    # get current pattern and create hash of "normalized" version -- ie. shift
    # its top left corner to 0,0 -- so we can detect spaceships and knightships
    ## currpatt = pattern( g.getcells(prect) )
    ## h = hash( tuple( currpatt(-pbox.left, -pbox.top) ) )

    # use Golly's hash command (3 times faster than above code)
    h = g.hash(prect)

    # check if outer-totalistic rule has B0 but not S8
    rule = g.getrule().split(":")[0]
    hasB0notS8 = rule.startswith("B0") and (rule.find("/") > 1) and not rule.endswith("8")

    # determine where to insert h into hashlist
    pos = 0
    listlen = len(hashlist)
    while pos < listlen:
        if h > hashlist[pos]:
            pos += 1
        elif h < hashlist[pos]:
            # shorten lists and append info below
            del hashlist[pos : listlen]
            del genlist[pos : listlen]
            del poplist[pos : listlen]
            del boxlist[pos : listlen]
            break
        else:
            # h == hashlist[pos] so pattern is probably oscillating, but just in
            # case this is a hash collision we also compare pop count and box size
            if (int(g.getpop()) == poplist[pos]) and \
               (pbox.wd == boxlist[pos].wd) and \
               (pbox.ht == boxlist[pos].ht):
                period = int(g.getgen()) - genlist[pos]

                if hasB0notS8 and (period % 2 > 0) and (pbox == boxlist[pos]):
                    # ignore this hash value because B0-and-not-S8 rules are
                    # emulated by using different rules for odd and even gens,
                    # so it's possible to have identical patterns at gen G and
                    # gen G+p if p is odd
                    return False

                if pbox == boxlist[pos]:
                    # pattern hasn't moved
                    if period == 1:
                        g.show("The pattern is stable.")
                    else:
                        g.show("Oscillator detected (period = " + str(period) + ")")
                else:
                    global p
                    p = period
                return True
            else:
                # look at next matching hash value or insert if no more
                pos += 1

    # store hash/gen/pop/box info at same position in various lists
    hashlist.insert(pos, h)
    genlist.insert(pos, int(g.getgen()))
    poplist.insert(pos, int(g.getpop()))
    boxlist.insert(pos, pbox)

    return False

# --------------------------------------------------------------------

def fit_if_not_visible():
    # fit pattern in viewport if not empty and not completely visible
    r = rect(g.getrect())
    if (not r.empty) and (not r.visible()): g.fit()

# --------------------------------------------------------------------

def check_repeat_time(n):
    g.show("Checking for repeat time " + str(n))

    g.new("test")
    g.putcells(pat)
    g.run(n)
    g.putcells(pat, 0, 0, 1, 0, 0, 1, "xor")
    test_hash = g.hash(g.getrect())

    g.run(p)

    if len(g.getrect()) == 0: return False
    current_hash = g.hash(g.getrect())

    return current_hash == test_hash


g.show("Checking for oscillation... (hit escape to abort)")

oldsecs = time()
while not oscillating():
    g.run(1)
    newsecs = time()
    if newsecs - oldsecs >= 1.0:     # show pattern every second
        oldsecs = newsecs
        fit_if_not_visible()
        g.update()

fit_if_not_visible()

i = 1
while not check_repeat_time(i):
    i *= 2

factor = i/4
i -= factor

while factor != 1:
    factor /= 2
    if check_repeat_time(int(i)):
        i -= factor
    else:
        i += factor

g.show(str(i))
In fact, it appears to be buggy. Inputting Sir Robin correctly outputs 196 with the first script, but 195 with the second one, causing the two spaceships to collide.

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

Re: Thread for your script-related questions

Post by LaundryPizza03 » July 18th, 2022, 10:13 am

Why is Golly ignoring g.show() and g.setgen() in this script? I am trying to modify sss.py to analyze rules containing B0.

Code: Select all

import itertools
import math
import golly as g

try:
    # Avoid xrange argument overflowing type C long on Python2
    if xrange(1):
        xrange = lambda stop: iter(itertools.count().next, stop)
except NameError:
    xrange = range

def testShip(rlepatt, rule, maxgen = 2000):
    # Clear the layer and place the ship
    r = g.getrect()
    if rlepatt:
        patt = g.parse(rlepatt)
        # If rlepatt is in a multistate representation then patt will be
        # a multistate cell list. testShip() only works for ships in two
        # state rules, so convert to two state cell list.
        if (len(patt)%2):
            # This assumes all cells have non-zero state - which is reasonable
            # for the results of g.parse()
            patt = [ patt[i] for j, i in enumerate(patt[:-1]) if (j+1)%3 ]
    else:
        # Use the current pattern
        if not r:
            return (0, tuple())
        patt = g.getcells(r)
        patt = g.transform(patt, -r[0], -r[1])
    # g.note(str((rlepatt, rule)))
    if r:
        g.select(r)
        g.clear(0)
    g.putcells(patt)
    g.setgen('0') #Prevent processing the wrong phase
    # g.note(str(len(patt)) + ", " + str(patt))
    # rlepatt might be different to the rle representation determined by
    # giveRLE(), so ensure we have the correct representation
    testrle = giveRLE(patt)
    if rule:
        g.setrule(rule)
    speed = ()
    startpop = int(g.getpop())
    bbox = g.getrect()
    minpop = startpop
    minbboxarea = bbox[2]*bbox[3]
    mingen = 0
    # Keep track of the total bbox
    maxx = bbox[2]
    maxy = bbox[3]
    maxpop = startpop
    # Ignore ship if rule is not a 2-state rule
    if not g.numstates()==2:
        return (minpop, speed)
    # Ignore ship if rule is not B0
    if g.getrule()[0,2] != 'B0' or g.getrule()[-1] == '8':
        return (minpop, speed)
    for ii in xrange(maxgen):
        g.run(1)
        r = g.getrect()
        if not r:
            # Pattern has died out and is therefore not a ship
            mingen = 0
            break
        pop = int(g.getpop())
        bboxarea = r[2]*r[3]
        if pop < minpop:
            # Find phase with minimimum population
            minpop = pop
            minbboxarea = r[2]*r[3]
            mingen = ii+1
        elif pop == minpop:
            # Amongst phases with min pop, find one with minimum bbox area
            # bboxarea = r[2]*r[3]
            if bboxarea < minbboxarea:
                minbboxarea = bboxarea
                mingen = ii+1
        # Track the bounding box of the pattern's evolution
        maxx = max(maxx, r[2])
        maxy = max(maxy, r[3])
        maxpop = max(maxpop, pop)
        # Every B0 pattern has even period
        if ii%2 == 0: continue

        g.show('Loser')

        if (pop == startpop and r[2:4] == bbox[2:4]):
            if (giveRLE(g.getcells(r)) == testrle):
                # Starting ship has reappeared
                speed = (r[0]-bbox[0], r[1]-bbox[1], ii+1) # displacement and period
                break
        # Check for rotated pattern 
        elif (pop == startpop and r[2:4] == bbox[3:1:-1]):
            # For 2-cell oscillators this is sufficient
            if minpop == 2:
                speed = (0, 0, 2*(ii+1))
                mingen = ii+1
                break
    g.run(mingen) # Evolve ship to generation with minimum population
    # return (minpop, speed)
    # return (minpop, speed, maxpop)
    return (minpop, speed, maxx*maxy)
# --------------------------------------------------------------------

Code: Select all

import itertools
import math
import golly as g
import sssb0

s = sssb0.testShip('obo$2bo!', 'B012c3acinq4inqwyz5ejny6i78/S01e2aek4ceijty5eny6eik')
The test pattern is:

Code: Select all

x = 3, y = 2, rule = B012c3acinq4inqwyz5ejny6i78/S01e2aek4ceijty5eny6eik
obo$2bo!

Code: Select all

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

atavoidirc
Posts: 49
Joined: April 14th, 2022, 3:09 pm

Re: Thread for your script-related questions

Post by atavoidirc » July 19th, 2022, 4:18 pm

I have been unable to get golly to use python scripts. I have downloaded and installed Python 3.9 (twice), and am on a mac. I believe this may be due to me mistakenly trying to use a Python 2.x installation in the past. The issue is that that when I input the version number, it just asks me again.
Fixed, issue was that item in gollyprefs had missing underscore

Ch91
Posts: 49
Joined: April 26th, 2019, 8:05 pm

Re: Thread for your script-related questions

Post by Ch91 » July 28th, 2022, 7:27 pm

Whenever I try to run a script, even those built into Golly, I get a "could not load the python library" error despite having a clean install of Python 3.10.5. Could it be malfunctioning? If so, how do I fix it?

I've tried to look for any trace of a "python310.dll" file, but no such thing seems to exist. Both Golly and python are the 64-bit versions so that's probably not the issue.

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

Re: Thread for your script-related questions

Post by GUYTU6J » August 20th, 2022, 12:22 pm

I threw a random stage of the R+loaf reaction from RF48H to popseq, and this is the output:

Code: Select all

Accepted pattern: 5b3o$4bo2bo$4b2o3bo$7b3o$8bo2$10bo$4bob6o$3bo8bo$4bo6bo$11bo$8bobo$2bo$bobo$o2bo$b2o!
36$38bo$27b3o7b2o$29bo7bobo$21bo6bo$21b2o$20bobo$45b2o$45bobo$45bo!
34$36bo$35b2o$35bobo$27b3o$29bo$28bo$24bo15b3o$24b2o14bo$23bobo15bo!
33$34bo$33b2o$33bobo2$27b3o$29bo$28bo2$21bo$21b2o$20bobo4$48b2o$47b2o$49bo!
33$34b2o$34bobo$34bo2$27b3o$29bo$28bo4$27b3o$29bo$28bo$41b3o$41bo$42bo!
36$38bo$27b3o7b2o$29bo7bobo$28bo3$29b2o$30b2o$29bo3$39b2o$39bobo$39bo!
34$36bo$35b2o$35bobo$27b3o$29bo$28bo7$22b3o$24bo24b2o$23bo24b2o$50bo!
36$36b3o$27b3o6bo$29bo7bo$28bo9$44b2o$21b2o21bobo$20bobo21bo$22bo!
Only the first result is correct, and the rest is for a different R+loaf collision. Their population sequence diverts at generation 18:

Code: Select all

x = 42, y = 16, rule = B3/S23
5b3o26b3o$4bo2bo25bo2bo$4b2o3bo23b2o3bo$7b3o26b3o$8bo28bo2$10bo28bo$4b
ob6o21bob6o$3bo8bo19bo8bo$4bo6bo21bo6bo$11bo28bo$8bobo26bobo$2bo28bo$b
obo26bobo$o2bo26bo2bo$b2o28b2o!
#C [[ STOP 18 ]]
So, how late should I choose the target pattern to avoid the false positive results?

Post Reply