Thread for your script-related questions

For scripts to aid with computation or simulation in cellular automata.
Post Reply
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 » December 4th, 2020, 8:54 pm

Code: Select all

def canonise(duration):

    representation = "#"

    # We need to compare each phase to find the one with the smallest
    # description:
    for t in xrange(duration):

        rect = g.getrect()
        if (len(rect) == 0):
            return "0"

        if ((rect[2] <= 40) & (rect[3] <= 40)):
            # Fits within a 40-by-40 bounding box, so eligible to be canonised.
            # Choose the orientation which results in the smallest description:
            representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0], rect[1], 1, 0, 0, 1))
            representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0]+rect[2]-1, rect[1], -1, 0, 0, 1))
            representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0], rect[1]+rect[3]-1, 1, 0, 0, -1))
            representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0]+rect[2]-1, rect[1]+rect[3]-1, -1, 0, 0, -1))
            representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0], rect[1], 0, 1, 1, 0))
            representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0]+rect[2]-1, rect[1], 0, -1, 1, 0))
            representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0], rect[1]+rect[3]-1, 0, 1, -1, 0))
            representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0]+rect[2]-1, rect[1]+rect[3]-1, 0, -1, -1, 0))

        g.run(1)

    return representation

# A subroutine used by canonise:
def canonise_orientation(length, breadth, ox, oy, a, b, c, d):

    representation = ""

    chars = "0123456789abcdefghijklmnopqrstuvwxyz"

    for v in xrange(int((breadth-1)/5)+1):
        zeroes = 0
        if (v != 0):
            representation += "z"
        for u in xrange(length):
            baudot = 0
            for w in xrange(5):
                x = ox + a*u + b*(5*v + w)
                y = oy + c*u + d*(5*v + w)
                baudot = (baudot >> 1) + 16*g.getcell(x, y)
            if (baudot == 0):
                zeroes += 1
            else:
                if (zeroes > 0):
                    if (zeroes == 1):
                        representation += "0"
                    elif (zeroes == 2):
                        representation += "w"
                    elif (zeroes == 3):
                        representation += "x"
                    else:
                        representation += "y"
                        representation += chars[zeroes - 4]
                zeroes = 0
                representation += chars[baudot]
    return representation
Is there a way to get apgcodes of bigger natural objects, like 100*100?(sometimes it kills the search)
Rule modifier

B34kz5e7c8/S23-a4ityz5k
b2n3-q5y6cn7s23-k4c8
B3-kq6cn8/S2-i3-a4ciyz8
B3-kq4z5e7c8/S2-ci3-a4ciq5ek6eik7

Bored of Conway's Game of Life? Try Pedestrian Life -- not pedestrian at all!

Hunting
Posts: 4395
Joined: September 11th, 2017, 2:54 am

Re: Thread for your script-related questions

Post by Hunting » December 4th, 2020, 9:51 pm

yujh wrote:
December 4th, 2020, 8:54 pm
Is there a way to get apgcodes of bigger natural objects, like 100*100?(sometimes it kills the search)
There are no apgcodes for 100*100 objects.

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 » December 4th, 2020, 10:49 pm

yujh wrote:
December 4th, 2020, 8:54 pm
Is there a way to get apgcodes of bigger natural objects, like 100*100?(sometimes it kills the search)
Here's a script for finding "greedy" apgcodes; is this what you're looking for?

Code: Select all

import golly as g
import webbrowser

# Golly selection to apgcode (in clipboard)
# stolen shamelessly from apgsearch.  Thanks Adam!

def bijoscar(maxsteps):

    initpop = int(g.getpop())
    initrect = g.getrect()
    if (len(initrect) == 0):
        return 0
    inithash = g.hash(initrect)

    for i in range(maxsteps):

        g.run(1)

        if (int(g.getpop()) == initpop):

            prect = g.getrect()
            phash = g.hash(prect)

            if (phash == inithash):

                period = i + 1

                if (prect == initrect):
                    return period
                else:
                    return -period
    return -1


def canonise():
   
    p = bijoscar(1000000)

    representation = "#"
    for i in range(abs(p)):
        rect = g.getrect()
        representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0], rect[1], 1, 0, 0, 1))
        representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0]+rect[2]-1, rect[1], -1, 0, 0, 1))
        representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0], rect[1]+rect[3]-1, 1, 0, 0, -1))
        representation = compare_representations(representation, canonise_orientation(rect[2], rect[3], rect[0]+rect[2]-1, rect[1]+rect[3]-1, -1, 0, 0, -1))
        representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0], rect[1], 0, 1, 1, 0))
        representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0]+rect[2]-1, rect[1], 0, -1, 1, 0))
        representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0], rect[1]+rect[3]-1, 0, 1, -1, 0))
        representation = compare_representations(representation, canonise_orientation(rect[3], rect[2], rect[0]+rect[2]-1, rect[1]+rect[3]-1, 0, -1, -1, 0))
        g.run(1)
   
    if (p<0):
        prefix = "q"+str(abs(p))
    elif (p==1):
        prefix = "s"+str(g.getpop())
    else:
        prefix = "p"+str(p)

    rule = str.replace(g.getrule(),"/","").lower()
   
    webbrowser.open_new("https://catagolue.hatsya.com/object/x"+prefix+"_"+representation+"/"+rule)

# A subroutine used by canonise:
def canonise_orientation(length, breadth, ox, oy, a, b, c, d):

    representation = ""

    chars = "0123456789abcdefghijklmnopqrstuvwxyz"

    for v in range(int((breadth-1)/5)+1):
        zeroes = 0
        if (v != 0):
            representation += "z"
        for u in range(length):
            baudot = 0
            for w in range(5):
                x = ox + a*u + b*(5*v + w)
                y = oy + c*u + d*(5*v + w)
                baudot = (baudot >> 1) + 16*g.getcell(x, y)
            if (baudot == 0):
                zeroes += 1
            else:
                while zeroes > 0:
                    if (zeroes == 1):
                        representation += "0"
                    elif (zeroes == 2):
                        representation += "w"
                    elif (zeroes == 3):
                        representation += "x"
                    elif (zeroes > 39):
                        representation += "yz"
                    else:
                        representation += "y"
                        representation += chars[zeroes - 4]
                    zeroes -= 39
                zeroes = 0
                representation += chars[baudot]
    return representation

# Compares strings first by length, then by lexicographical ordering.
# A hash character is worse than anything else.
def compare_representations(a, b):

    if (a == "#"):
        return b
    elif (b == "#"):
        return a
    elif (len(a) < len(b)):
        return a
    elif (len(b) < len(a)):
        return b
    elif (a < b):
        return a
    else:
        return b

g.duplicate()
g.clear(1)
canonise()

g.dellayer()
Originally from here, with some modifications to work with Python 3.x.
Hunting wrote:
December 4th, 2020, 9:51 pm
There are no apgcodes for 100*100 objects.
You sure about that?

User avatar
otismo
Posts: 1201
Joined: August 18th, 2010, 1:41 pm
Location: Florida
Contact:

Re: Thread for your script-related questions

Post by otismo » December 5th, 2020, 9:38 am

I would like a script that makes a Loafer Bitmap Printer

out of this memory register, which uses P46 technology
P322MEMtape-G-to-L-Converter-with-P322gun-NOT.rle
p46 tech xcept 4 snarking around to kill loafers
(24.77 KiB) Downloaded 149 times
is this possible?

@ anybody?

Thank You !

Cheers !
"One picture is worth 1000 words; but one thousand words, carefully crafted, can paint an infinite number of pictures."
- autonomic writing
forFUN : http://viropet.com
Art Gallery : http://cgolart.com
Video WebSite : http://conway.life

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

Re: Thread for your script-related questions

Post by creeperman7002 » December 9th, 2020, 9:21 pm

How can I prevent JLS from outputting solutions with non-interacting cells?
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

wwei23

Re: Thread for your script-related questions

Post by wwei23 » December 10th, 2020, 1:11 am

creeperman7002 wrote:
December 9th, 2020, 9:21 pm
How can I prevent JLS from outputting solutions with non-interacting cells?
Examples? :P

wildmyron
Posts: 1542
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: Thread for your script-related questions

Post by wildmyron » December 10th, 2020, 5:54 am

creeperman7002 wrote:
December 9th, 2020, 9:21 pm
How can I prevent JLS from outputting solutions with non-interacting cells?
This is not something JLS is capable of doing automatically. The best you could do is manually divide the search and set cells in ways that either force an area off or cause it to interact with the existing partials.

If you have use Windows you could try Nicolau Beluchenko's version of WLS. It has options to detect non-interacting solutions and then backtrack when they are found again. This greatly improves search speed for those searches where non-interacting solutions are a problem. https://conwaylife.com/forums/viewtopic ... 433#p98433
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by AforAmpere. The latest collection is hosted on GitHub and contains well over 1,000,000 spaceships.

Semi-active here - recovering from a severe case of LWTDS.

volcanrb
Posts: 9
Joined: August 7th, 2020, 8:10 pm

Re: Thread for your script-related questions

Post by volcanrb » December 13th, 2020, 1:44 pm

Are there any search programs capable of searching for spaceships in chaotic LTL rules that don't necessarily stabilize?

Specifically, I want to search for diagonal spaceships in the rule R2,C0,S4,B4. It's a very interesting rule with a number of common orthogonal spaceships, however there is one somewhat common pattern which causes chaotic exploding behaviour. In any large enough soup, the pattern will almost definitely show up, ensuring the soup doesn't stabilize. I tried running apgsearch on this rule, and the program seemed to just freeze immediately and never outputted anything, I assume because of the non-stabilizing behaviour of the rule.

Is there some program that could handle searching such a non-stabilizing LTL rule?

Hunting
Posts: 4395
Joined: September 11th, 2017, 2:54 am

Re: Thread for your script-related questions

Post by Hunting » December 13th, 2020, 8:36 pm

volcanrb wrote:
December 13th, 2020, 1:44 pm
Are there any search programs capable of searching for spaceships in chaotic LTL rules that don't necessarily stabilize?

Specifically, I want to search for diagonal spaceships in the rule R2,C0,S4,B4. It's a very interesting rule with a number of common orthogonal spaceships, however there is one somewhat common pattern which causes chaotic exploding behaviour. In any large enough soup, the pattern will almost definitely show up, ensuring the soup doesn't stabilize. I tried running apgsearch on this rule, and the program seemed to just freeze immediately and never outputted anything, I assume because of the non-stabilizing behaviour of the rule.

Is there some program that could handle searching such a non-stabilizing LTL rule?
PlutoniumSearch can, but let me clean up the code first.

(Sry for selfpromoting, but I can't think of any other search program that supports LTL offhand.)

lemon41625
Posts: 344
Joined: January 24th, 2020, 7:39 am
Location: 小红点 (if you know where that is)

Re: Thread for your script-related questions

Post by lemon41625 » December 13th, 2020, 11:35 pm

volcanrb wrote:
December 13th, 2020, 1:44 pm
Are there any search programs capable of searching for spaceships in chaotic LTL rules that don't necessarily stabilize?

Specifically, I want to search for diagonal spaceships in the rule R2,C0,S4,B4. It's a very interesting rule with a number of common orthogonal spaceships, however there is one somewhat common pattern which causes chaotic exploding behaviour. In any large enough soup, the pattern will almost definitely show up, ensuring the soup doesn't stabilize. I tried running apgsearch on this rule, and the program seemed to just freeze immediately and never outputted anything, I assume because of the non-stabilizing behaviour of the rule.

Is there some program that could handle searching such a non-stabilizing LTL rule?
Yes, that would be Logic Cellular Automaton Search (LCAS).

See viewtopic.php?f=9&t=4569 and follow the instructions to set it up.
Download CAViewer: https://github.com/jedlimlx/Cellular-Automaton-Viewer

Supports:
BSFKL, Extended Generations, Regenerating Generations, Naive Rules, R1 Moore, R2 Cross and R2 Von Neumann INT
And some others...

HelicopterCat3
Posts: 258
Joined: October 16th, 2020, 10:27 am

Re: Thread for your script-related questions

Post by HelicopterCat3 » December 26th, 2020, 7:11 pm

I recently got python 3.9 and 2.7.13 and when I tried to run apgsearch it came up with this error message:

I don't know if this is a script problem or a python/Golly problem
Attachments
Image.PNG
Image.PNG (15.03 KiB) Viewed 4964 times

goldenratio
Posts: 295
Joined: July 26th, 2020, 10:39 pm
Location: Texas, USA

Re: Thread for your script-related questions

Post by goldenratio » December 26th, 2020, 7:41 pm

HelicopterCat3 wrote:
December 26th, 2020, 7:11 pm
I recently got python 3.9 and 2.7.13 and when I tried to run apgsearch it came up with this error message:
Don't know but you should be better off running the much faster 5.x version of apgsearch, considering you'll need to know how to use the terminal anyways if you want to use gfind (which is currently very user-unfriendly for INT afaik just to warn you, ntzfind/qfind/ikpx2 are better options but I'm probably not the best person to ask about this sort of thing).
Oscillator discussion is boring me out. I'll return when the cgol community switches to something else.

Me on LifeWiki

HelicopterCat3
Posts: 258
Joined: October 16th, 2020, 10:27 am

Re: Thread for your script-related questions

Post by HelicopterCat3 » December 26th, 2020, 8:12 pm

goldenratio wrote:
December 26th, 2020, 7:41 pm
Don't know but you should be better off running the much faster 5.x version of apgsearch, considering you'll need to know how to use the terminal anyways if you want to use gfind (which is currently very user-unfriendly for INT afaik just to warn you, ntzfind/qfind/ikpx2 are better options but I'm probably not the best person to ask about this sort of thing).
What kind of features does qfind have? What does it need to function?
I'll consider getting 5.x then. The tutorial on the wiki said to use the hacked one for INT rules, so I did that.

User avatar
bubblegum
Posts: 959
Joined: August 25th, 2019, 11:59 pm
Location: click here to do nothing

Re: Thread for your script-related questions

Post by bubblegum » December 27th, 2020, 12:10 am

HelicopterCat3 wrote:
December 26th, 2020, 8:12 pm
I'll consider getting 5.x then. The tutorial on the wiki said to use the hacked one for INT rules, so I did that.
Aidan's hacked apgsearch 1.x is for apgsearch 1.x, apgsearch 5.x has built-in support for INT.

Wow, the tutorials are outdated.
Each day is a hidden opportunity, a frozen waterfall that's waiting to be realised, and one that I'll probably be ignoring
sonata wrote:
July 2nd, 2020, 8:33 pm
conwaylife signatures are amazing[citation needed]
anything

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 » December 27th, 2020, 2:24 am

I think they are probably trying to use apgsearch but with golly 4.0?

(Hacked versions only work with python 2.x if nobody wants to update them)
Rule modifier

B34kz5e7c8/S23-a4ityz5k
b2n3-q5y6cn7s23-k4c8
B3-kq6cn8/S2-i3-a4ciyz8
B3-kq4z5e7c8/S2-ci3-a4ciq5ek6eik7

Bored of Conway's Game of Life? Try Pedestrian Life -- not pedestrian at all!

HelicopterCat3
Posts: 258
Joined: October 16th, 2020, 10:27 am

Re: Thread for your script-related questions

Post by HelicopterCat3 » December 30th, 2020, 3:01 pm

Funny story, that error message I received shows up for any script I "execute" so I think my python library is incomplete somehow. I tried to uninstall and reinstall python but came up with the same message. I don't think I'm gonna be using scripts for a while until I can figure out what's going on.
If you all have any advice, please share it

User avatar
bubblegum
Posts: 959
Joined: August 25th, 2019, 11:59 pm
Location: click here to do nothing

Re: Thread for your script-related questions

Post by bubblegum » December 30th, 2020, 7:43 pm

HelicopterCat3 wrote:
December 30th, 2020, 3:01 pm
Funny story, that error message I received shows up for any script I "execute" so I think my python library is incomplete somehow. I tried to uninstall and reinstall python but came up with the same message. I don't think I'm gonna be using scripts for a while until I can figure out what's going on.
If you all have any advice, please share it
It seems that PyModule_Create2() is part of the C API. Either:
1) you have a debug version which will include a different symbol, or
2) (more likely) you're trying to use Python 2.x with Golly 4.x (these are incompatible), PyModule_Create2() is new in Python 3.1.
Each day is a hidden opportunity, a frozen waterfall that's waiting to be realised, and one that I'll probably be ignoring
sonata wrote:
July 2nd, 2020, 8:33 pm
conwaylife signatures are amazing[citation needed]
anything

Hunting
Posts: 4395
Joined: September 11th, 2017, 2:54 am

Re: Thread for your script-related questions

Post by Hunting » December 31st, 2020, 1:33 am

bubblegum wrote:
December 27th, 2020, 12:10 am
HelicopterCat3 wrote:
December 26th, 2020, 8:12 pm
I'll consider getting 5.x then. The tutorial on the wiki said to use the hacked one for INT rules, so I did that.
Aidan's hacked apgsearch 1.x is for apgsearch 1.x, apgsearch 5.x has built-in support for INT.

Wow, the tutorials are outdated.
The tutorial is not - it says to use the hacked one for INT rules if you decided to use 1.x, otherwise 5.x. The "INT rules" section is under the 1.x section.

User avatar
bubblegum
Posts: 959
Joined: August 25th, 2019, 11:59 pm
Location: click here to do nothing

Re: Thread for your script-related questions

Post by bubblegum » December 31st, 2020, 2:50 am

Hunting wrote:
December 31st, 2020, 1:33 am
The tutorial is not - it says to use the hacked one for INT rules if you decided to use 1.x, otherwise 5.x. The "INT rules" section is under the 1.x section.
No, the tutorials in general are outdated, that part (updated recently) is fine.
Each day is a hidden opportunity, a frozen waterfall that's waiting to be realised, and one that I'll probably be ignoring
sonata wrote:
July 2nd, 2020, 8:33 pm
conwaylife signatures are amazing[citation needed]
anything

HelicopterCat3
Posts: 258
Joined: October 16th, 2020, 10:27 am

Re: Thread for your script-related questions

Post by HelicopterCat3 » December 31st, 2020, 5:58 pm

bubblegum wrote:
December 30th, 2020, 7:43 pm
HelicopterCat3 wrote:
December 30th, 2020, 3:01 pm
Funny story, that error message I received shows up for any script I "execute" so I think my python library is incomplete somehow. I tried to uninstall and reinstall python but came up with the same message. I don't think I'm gonna be using scripts for a while until I can figure out what's going on.
If you all have any advice, please share it
It seems that PyModule_Create2() is part of the C API. Either:
1) you have a debug version which will include a different symbol, or
2) (more likely) you're trying to use Python 2.x with Golly 4.x (these are incompatible), PyModule_Create2() is new in Python 3.1.
Ah ok thank you so much

Edit: A couple of questions,
1. Where do I download apgsearch 5.x?
2. Do I need a unix-like command line for it (I'm on windows) like it says on the wiki?
3. Where do I download qfind or a spaceship searcher like lifesrc?

User avatar
bubblegum
Posts: 959
Joined: August 25th, 2019, 11:59 pm
Location: click here to do nothing

Re: Thread for your script-related questions

Post by bubblegum » December 31st, 2020, 8:59 pm

HelicopterCat3 wrote:
December 31st, 2020, 5:58 pm
1. Where do I download apgsearch 5.x?
2. Do I need a unix-like command line for it (I'm on windows) like it says on the wiki?
3. Where do I download qfind or a spaceship searcher like lifesrc?
1) Follow the instructions at https://gitlab.com/apgoucher/apgmera.
2) Yes, try Cygwin64 as mentioned (WSL is probably overkill).
3) Just browse the Scripts subforum until you find one you like (I prefer ikpx2).

EDIT: Oh no.

Code: Select all

b3s23/5Glider_stdin: 6305879 soups completed (inf soups/second current, 405.126 overall).
Each day is a hidden opportunity, a frozen waterfall that's waiting to be realised, and one that I'll probably be ignoring
sonata wrote:
July 2nd, 2020, 8:33 pm
conwaylife signatures are amazing[citation needed]
anything

Hunting
Posts: 4395
Joined: September 11th, 2017, 2:54 am

Re: Thread for your script-related questions

Post by Hunting » January 1st, 2021, 6:31 am

bubblegum wrote:
December 31st, 2020, 8:59 pm
2) Yes, try Cygwin64 as mentioned (WSL is probably overkill).
WSL is a built-in tool while Cygwin requires a lot of installation and so on, I never figured out how to install it. So no, use WSL.

User avatar
bubblegum
Posts: 959
Joined: August 25th, 2019, 11:59 pm
Location: click here to do nothing

Re: Thread for your script-related questions

Post by bubblegum » January 1st, 2021, 5:26 pm

Hunting wrote:
January 1st, 2021, 6:31 am
WSL is a built-in tool while Cygwin requires a lot of installation and so on, I never figured out how to install it. So no, use WSL.
How about this: use whatever you want.
Each day is a hidden opportunity, a frozen waterfall that's waiting to be realised, and one that I'll probably be ignoring
sonata wrote:
July 2nd, 2020, 8:33 pm
conwaylife signatures are amazing[citation needed]
anything

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: Thread for your script-related questions

Post by Scorbie » January 2nd, 2021, 7:43 am

HelicopterCat3 wrote:
December 31st, 2020, 5:58 pm
3. Where do I download qfind or a spaceship searcher like lifesrc?
Some programs can be found in LifeWiki. (e.g. lifesrc)

HelicopterCat3
Posts: 258
Joined: October 16th, 2020, 10:27 am

Re: Thread for your script-related questions

Post by HelicopterCat3 » January 7th, 2021, 9:39 pm

bubblegum wrote:
December 31st, 2020, 8:59 pm
HelicopterCat3 wrote:
December 31st, 2020, 5:58 pm
1. Where do I download apgsearch 5.x?
2. Do I need a unix-like command line for it (I'm on windows) like it says on the wiki?
3. Where do I download qfind or a spaceship searcher like lifesrc?
1) Follow the instructions at https://gitlab.com/apgoucher/apgmera.
2) Yes, try Cygwin64 as mentioned (WSL is probably overkill).
3) Just browse the Scripts subforum until you find one you like (I prefer ikpx2).

EDIT: Oh no.

Code: Select all

b3s23/5Glider_stdin: 6305879 soups completed (inf soups/second current, 405.126 overall).
I'm sorry I have one last question. What do you recommend as a good c++ compiler? Or does WSL/Cygwin come with a c++ compiler built in?

Post Reply