Thread for your script-related questions

For scripts to aid with computation or simulation in cellular automata.
Post Reply
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 7th, 2021, 9:46 pm

HelicopterCat3 wrote:
January 7th, 2021, 9:39 pm
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?
Try gcc-g++, it's pretty much the standard C/C++ compiler.
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 » January 7th, 2021, 9:50 pm

bubblegum wrote:
January 7th, 2021, 9:46 pm
HelicopterCat3 wrote:
January 7th, 2021, 9:39 pm
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?
Try gcc-g++, it's pretty much the standard C/C++ compiler.
Alright thanks! Once I get the c compiler and apgsearch itself, I should be able to contribute.

Edit: Never mind I am not doing this. I'm going to throw my computer. I'm just gonna be content manual searching.

wwei23

Re: Thread for your script-related questions

Post by wwei23 » January 11th, 2021, 11:21 am

Can someone please explain to me how JLS works? I'm trying to modify the code, but it's hard to figure out what does what. I have basic Java knowledge.

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

Re: Thread for your script-related questions

Post by creeperman7002 » January 15th, 2021, 9:33 pm

Can rlifesrc have a min-pop feature and an algorithm to weed out non-interacting solutions?
This is especially useful when enumerating patterns of a certain size.
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
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 » January 16th, 2021, 2:09 am

creeperman7002 wrote:
January 15th, 2021, 9:33 pm
rlifesrc have a min-pop feature
Yes
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!

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 » February 9th, 2021, 12:15 am

How do I exactly search for slow salvo recipes or elbow operations with one or two two input lanes in OCA with or without the glider and block? Existing descriptions for various scripts, including HoneySearch, seem opaque to me, so I'd like a comprehensive walkthrough.

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

Re: Thread for your script-related questions

Post by Hunting » February 9th, 2021, 3:32 am

creeperman7002 wrote:
January 15th, 2021, 9:33 pm
Can rlifesrc have a min-pop feature and an algorithm to weed out non-interacting solutions?
This is especially useful when enumerating patterns of a certain size.
How would you weed out non-interacting solutions?

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

Re: Thread for your script-related questions

Post by wwei47 » March 3rd, 2021, 11:10 am

How do I fix this error?

Code: Select all

$ java -jar SeedsOfDestruction.v0-5.jar
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String; ([Ljava.lang.Object; and [Ljava.lang.String; are in module java.base of loader 'bootstrap')
    at sphi.igblan.seedsOfDestruction.Nouns.<init>(Nouns.java:62)
    at sphi.igblan.seedsOfDestruction.PuzzleTree.<init>(PuzzleTree.java:115)
    at sphi.igblan.seedsOfDestruction.ui.Frame.<init>(Frame.java:38)
    at sphi.igblan.seedsOfDestruction.ui.Frame$4.run(Frame.java:307)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
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
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your script-related questions

Post by dvgrn » March 3rd, 2021, 11:59 am

wwei47 wrote:
March 3rd, 2021, 11:10 am
How do I fix this error?
No idea -- but please start with this: what is your OS, and what version of Java do you have installed?

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

Re: Thread for your script-related questions

Post by wwei47 » March 3rd, 2021, 12:02 pm

dvgrn wrote:
March 3rd, 2021, 11:59 am
No idea -- but please start with this: what is your OS, and what version of Java do you have installed?

Code: Select all

$ java --version
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
I don't know how to get the OS on repl.it, but it seems to be Ubuntu, based off of how it says "Ubuntu" in the build version.
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
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Thread for your script-related questions

Post by dvgrn » March 3rd, 2021, 12:19 pm

wwei47 wrote:
March 3rd, 2021, 12:02 pm
I don't know how to get the OS on repl.it, but it seems to be Ubuntu, based off of how it says "Ubuntu" in the build version.
Repl.it, aha, that's another kettle of *WSSes entirely. Do you happen to have a repl where you're trying this, that you could make public and post a link to?

I have zero experience in trying to get Java with pop-up GUIs to run in a repl. Have tried some equivalent things in Python and have run into mysterious and interesting problems. Like, in Python, just see what happens with the single line 'import antigravity'... Not sure that if the repl.it system has really been designed to support this kind of thing -- but it might certainly be possible to make it work, for all I know.

User avatar
Macbi
Posts: 903
Joined: March 29th, 2009, 4:58 am

Re: Thread for your script-related questions

Post by Macbi » March 18th, 2021, 8:17 pm

Could we speed up oscar.py by only looking at generations from a sparse ruler, and using hash life to jump between them?

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

Re: Thread for your script-related questions

Post by dvgrn » March 18th, 2021, 8:46 pm

Macbi wrote:
March 18th, 2021, 8:17 pm
Could we speed up oscar.py by only looking at generations from a sparse ruler, and using hash life to jump between them?
I don't think that's likely to work, because oscar.py/oscar.lua relies on the idea of keeping track of a list of just the lowest hash values in a range of tested generations. For a period-P pattern I don't see how you can be sure that you're going to find the matching hash value until you've tested P different generations -- no matter how cleverly you pick the ticks to check.

Then, also, changing the step in Golly is computationally expensive, so it seems like you'd actually be at a serious disadvantage over just keeping the step size at 1. Sometimes you'd definitely luck out and find the period faster with a sparse-ruler approach, but I would guess it would be slower more often than it was faster. (But quite possibly I'm just not understanding the suggestion.)

That Doesn't Mean Oscar's The Best, Though
Really oscar.py is often very far from the fastest approach for finding the period of some totally unknown new high-period thing. I've often had to write my own code to figure out exactly when a mystery pattern becomes a high-period oscillator, because oscar.py would pretty much never have gotten to the answer. Those period-finder scripts basically amounted to

1) Run the pattern with HashLife, for long enough to be reasonably sure that it has settled into an oscillator;
2) Take the hash value, H, of that far-advanced pattern, and set the generation count back to T=0;
3) Run one tick at a time in whatever the fastest algo is, taking the hash at each tick and comparing against H until a match is found.

This ends up being several orders of magnitude faster than oscar.py/.lua for difficult cases like this, because of no messing around with Python lists, bounding boxes, or population counts.

User avatar
calcyman
Moderator
Posts: 2932
Joined: June 1st, 2009, 4:32 pm

Re: Thread for your script-related questions

Post by calcyman » March 19th, 2021, 6:57 pm

Macbi wrote:
March 18th, 2021, 8:17 pm
Could we speed up oscar.py by only looking at generations from a sparse ruler, and using hash life to jump between them?
Yes, that's exactly what lifelib does. The pdetect algorithm in lifelib accepts an upper limit N as a parameter, and it constructs a finite sparse ruler of size O(sqrt(N) log(N)).

https://gitlab.com/apgoucher/lifelib/-/ ... rn2.h#L392
dvgrn wrote:
March 18th, 2021, 8:46 pm
I don't think that's likely to work, because oscar.py/oscar.lua relies on the idea of keeping track of a list of just the lowest hash values in a range of tested generations. For a period-P pattern I don't see how you can be sure that you're going to find the matching hash value until you've tested P different generations -- no matter how cleverly you pick the ticks to check.
Indeed -- that's why lifelib can't use the Nivasch cycle detection algorithm; it instead stores the (hash --> generation) mapping in an associative array.
Then, also, changing the step in Golly is computationally expensive, so it seems like you'd actually be at a serious disadvantage over just keeping the step size at 1. Sometimes you'd definitely luck out and find the period faster with a sparse-ruler approach, but I would guess it would be slower more often than it was faster. (But quite possibly I'm just not understanding the suggestion.)
In lifelib's periodicity detection code, the number of times that the step size is increased (specifically doubled) is only log_4(N), where N is the maximum period to consider.

Finally, once a multiple of the period is determined, we try dividing it by each of its prime factors until we find the minimal period:

https://gitlab.com/apgoucher/lifelib/-/ ... rn2.h#L484
What do you do with ill crystallographers? Take them to the mono-clinic!

User avatar
Macbi
Posts: 903
Joined: March 29th, 2009, 4:58 am

Re: Thread for your script-related questions

Post by Macbi » March 20th, 2021, 3:39 am

dvgrn wrote:
March 18th, 2021, 8:46 pm
I don't think that's likely to work, because oscar.py/oscar.lua relies on the idea of keeping track of a list of just the lowest hash values in a range of tested generations. For a period-P pattern I don't see how you can be sure that you're going to find the matching hash value until you've tested P different generations -- no matter how cleverly you pick the ticks to check.
I've always thought that getting the space usage down to log(N) at the expense of doubling the running time was a false economy. On any modern computer one will run out of time to evolve generations long before one runs out of space to store hashes.
calcyman wrote:
March 19th, 2021, 6:57 pm
Yes, that's exactly what lifelib does. The pdetect algorithm in lifelib accepts an upper limit N as a parameter, and it constructs a finite sparse ruler of size O(sqrt(N) log(N)).
It seems like lifelib is better than Golly in a lot of resepects. Would it be possible to take Golly's GUI and graft it onto a lifelib backend? What would be the main obstructions?

User avatar
calcyman
Moderator
Posts: 2932
Joined: June 1st, 2009, 4:32 pm

Re: Thread for your script-related questions

Post by calcyman » March 20th, 2021, 7:25 am

Macbi wrote:
March 20th, 2021, 3:39 am
dvgrn wrote:
March 18th, 2021, 8:46 pm
I don't think that's likely to work, because oscar.py/oscar.lua relies on the idea of keeping track of a list of just the lowest hash values in a range of tested generations. For a period-P pattern I don't see how you can be sure that you're going to find the matching hash value until you've tested P different generations -- no matter how cleverly you pick the ticks to check.
I've always thought that getting the space usage down to log(N) at the expense of doubling the running time was a false economy. On any modern computer one will run out of time to evolve generations long before one runs out of space to store hashes.
Gabriel Nivasch also describes a multi-stack generalisation on the same webpage, which allows you to increase the memory usage and decrease the running time:

http://www.gabrielnivasch.org/fun/cycle-detection

(Essentially, the N-stack algorithm works the same way as the 1-stack algorithm but uses a separate stack for each residue class of hashes modulo N.)
calcyman wrote:
March 19th, 2021, 6:57 pm
Yes, that's exactly what lifelib does. The pdetect algorithm in lifelib accepts an upper limit N as a parameter, and it constructs a finite sparse ruler of size O(sqrt(N) log(N)).
It seems like lifelib is better than Golly in a lot of resepects. Would it be possible to take Golly's GUI and graft it onto a lifelib backend? What would be the main obstructions?
The main disadvantages of lifelib are:
  • Requires recompiling when you change rule;
  • Only works on x86_64 machines (whereas Golly is cross-platform);
so these would need to be addressed before it could be used as a native Golly backend. On the other hand, you can already 'import lifelib' in a Golly Python script, and of course move patterns between Golly layers and lifelib (loading/saving macrocell files being more efficient than cell lists), so there's already a reasonable amount of interoperability.
What do you do with ill crystallographers? Take them to the mono-clinic!

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 » March 21st, 2021, 7:40 pm

getting this error message :
error-msg.png
error-msg.png (22.53 KiB) Viewed 4235 times
with this script :

Code: Select all

# Golly Python script. Written by PM 2Ring, March 2009. Updated August 2009.
# Modified for Golly 2.0+ by Andrew Trevorrow.

''' Create a 'bitmap printer'.

    Print a bitmap in LWSSs, using the current selection as the bitmap source.
'''

import golly
from glife import *

def get_bitmap():
    ''' Get current selection & turn it into a bitmap. '''
    selrect = golly.getselrect()
    if len(selrect) == 0: golly.exit("There is no selection, aborting.")

    #Get bitmap size
    w, h = selrect[2:]
    #Adjust width, so it's in the form of 4m, m>1
    w = (w + 3) // 4 * 4
    w = max(8, w)

    #Initialize empty bitmap
    row = w * [0]
    bm = [row[:] for i in xrange(h)]

    #Populate bitmap with cell data
    u, v = selrect[:2]
    cells = golly.getcells(selrect)
    cellsxy = [(cells[i] - u, cells[i+1] - v) for i in xrange(0, len(cells), 2)]
    for x, y in cellsxy:
        bm[y][x] = 1
    return bm

def linemaker(loopm):
    ''' Create an empty LineMaker '''
    LM = pattern('''
34b2o$34bo$25b2o5bobo$24b3o5b2o$12bo8bob2o$12bobo6bo2bo$2o11bobo5bob2o
$2o11bo2bo7b3o21b2o$13bobo9b2o21b2o$12bobo$12bo9bo$23b2o$22b2o6$47b3o$
24b2o20bo3bo$24b2o19bo5bo$46bo3bo$47b3o$47b3o5$49b3o$44bo3b2ob2o$42b2o
4b2ob2o$35b2o6b2o3b5o$35b2o10b2o3b2o7$45b2o5b2o$45bo6bo$46b3o4b3o$48bo
6bo!''')
    LMTop = LM + pattern('2b2o$2bo$obo$2o!', 32, 7)
    LMBase = pattern('''
11bo$10bo$10b3o12$23b2o$23bobo$10bobo13bo$9bo2bo2b2o6bo2bo12b2o$8b2o5b
obo8bo11b3o$2o4b2o3bo3bo3bo3bobo9bob2o15bo$2o6b2o5b3ob2o2b2o10bo2bo8b
3o4bobo$9bo2bo3b2o17bob2o16bobo$10bobo25b3o2b2o2bo7bo2bo3b2o$39b2o2bo
3bo7bobo4b2o$44bo2bo6bobo$26bo17b2o8bo$24bobo$25b2o2$36bo$36bobo$36b2o
7$33bo7bo$32b4o5bobo$27b2o2bo2b2o8b2o4b2o$27b2o2b2o11b2o4b2o$16b2o6b2o
10bo7b2o$16b2o5b3o10bo4bobo$24b2o10bo4bo$27b2o$27b2o!''', 14, 29)
    LMBase += LM(55, 42, flip) 
    return LMTop(8 + loopm, -21 - loopm) + LMBase

def dmprinter(pdy, copies=1):
    ''' Generate & display a dot matrix printer for named bitmap pattern '''
    #Horizontal pixel separation between LineMakers. minimum = 5
    LMsx = 5

    #Horizontal distance between bitmap pixels. Constant, due to LineMaker period
    pdx = 15

    #Distance between LineMakers
    LMdx, LMdy = -LMsx * pdx, pdy

    #Get bitmap pattern from current selection.
    bm = get_bitmap()

    #Make printer in a new layer
    golly.duplicate()
    golly.setoption("syncviews", False)

    #Build new window title from old
    title = golly.getname().split('.')[0]
    title = '%s_Printer [%d] v0.10' % (title, pdy)
    golly.new(title)

    #Make sure we're using the standard Life generation rule
    golly.setrule("B3/S23")

    #Bitmap dimensions. Width MUST be of form 4m, for m >=1
    bmheight = len(bm)
    bmwidth = len(bm[0])
    mid = (bmheight + 1) // 2

    loopw = (bmwidth - 8) // 4
    loopm = pdx * loopw

    #Gliders, heading north-east
    g0 = pattern('2bo$2o$b2o!')
    g1 = pattern('obo$2o$bo!')
    gliders = [g0, g1, g1(0, 2, rccw), g0(0, 2, rccw),
        g0(2, 2, flip), g1(2, 2, flip), g1(2, 0, rcw), g0(2, 0, rcw)]
        
    #Create full Glider loop.
    gg = []
    ox, oy = 35, 23
    for j in xrange(loopw + 1):
        dd = pdx * j
        gg += [gliders[0](ox + dd, oy - dd), gliders[1](ox + 8 + dd, oy - 7 - dd)]
    dd = loopm
    gg += [gliders[2](45 + dd, 4 - dd), gliders[3](37 + dd, -3 - dd)]

    ox, oy = 26 + loopm, -4 - loopm
    for j in xrange(loopw + 1):
        dd = pdx * j
        gg += [gliders[4](ox - dd, oy + dd), gliders[5](ox - 8 - dd, oy + 7 + dd)]
    dd = loopm
    gg += [gliders[6](16, 15), gliders[7](24, 22)]
    parity = 2*((loopw + 1)*(0, 0) + (1, 1))

    def buildLM():
        ''' Build a complete LineMaker '''
        #Populate glider loop. (jj, ii) are bitmap coords
        gloop = pattern()
        for j in xrange(bmwidth):
            jj = (j - delta + bmwidth - 1) % bmwidth

            #Is there a pixel at this location?
            if bm[ii][jj] == parity[j]:                
                gloop += gg[j]  #Add glider to the loop

        #Only put LineMaker if glider loop isn't empty
        if len(gloop) > 0:
            (LMBlank + gloop).put(Lx, Ly, trans)

    #Assemble blank LineMaker
    LMBlank = linemaker(loopm)

    #Do upper LineMakers
    trans = identity
    for i in xrange(mid):
        ii = mid - (i + 1)
        io = mid + (i + 1)
        Lx, Ly = io * LMdx, ii * LMdy
        delta = LMsx * io
        buildLM()

    #Do lower LineMakers
    trans = flip_y
    for i in xrange(mid, bmheight):
        ii = i
        io = i + 2
        Lx, Ly = io * LMdx + pdx, ii * LMdy + 128
        delta = LMsx * io - 1
        buildLM()

    #Eaters facing south-east & north-east
    eaterSE = pattern('2o$bo$bobo$2b2o!')
    eaterNE = eaterSE(0, 10, flip_y)
    eY = 59
    eaters = (eaterNE(0, eY), eaterSE(0, eY))
    
    #Eater horizontal displacement. Must be odd
    #bmwidth muliplier determines number of copies visible 'outside' printer.
    eX = (bmheight + 1) * LMdx - (copies * bmwidth - 1) * pdx   
    eX = 1 + eX // 2 * 2    #Adjust parity
    all = pattern()
    for i in xrange(bmheight):
        all += eaters[i % (1 + LMsx % 2)](eX, i * LMdy)
    all.put()   

    #Centre view over bitmap output area
    golly.setpos(str(-pdx * bmwidth // 2 + (bmheight - 1) * LMdx), str(Ly//2))
    #golly.setmag(-2)    #Aliasing effects happen at smaller scales than -2 :(
    golly.fit()

def main():
    #Vertical distance between pixels. Maybe get this from user. minimum = 16
    pdy = 16

    #Generate & display a dot matrix printer from current selection
    dmprinter(pdy, copies=1)

    golly.setcursor("Zoom In")
    golly.setalgo("HashLife")
    golly.setbase(2)
    golly.setstep(6)

main()
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
Macbi
Posts: 903
Joined: March 29th, 2009, 4:58 am

Re: Thread for your script-related questions

Post by Macbi » March 22nd, 2021, 4:08 am

This is a problem caused by the update from Python 2 to Python 3, which are slightly incompatible languages. In this case all that is needed is to replace all copies of 'xrange' with 'range'.

Code: Select all

# Golly Python script. Written by PM 2Ring, March 2009. Updated August 2009.
# Modified for Golly 2.0+ by Andrew Trevorrow. and for Python 3+ by Oscar Cunningham.

''' Create a 'bitmap printer'.

    Print a bitmap in LWSSs, using the current selection as the bitmap source.
'''

import golly
from glife import *

def get_bitmap():
    ''' Get current selection & turn it into a bitmap. '''
    selrect = golly.getselrect()
    if len(selrect) == 0: golly.exit("There is no selection, aborting.")

    #Get bitmap size
    w, h = selrect[2:]
    #Adjust width, so it's in the form of 4m, m>1
    w = (w + 3) // 4 * 4
    w = max(8, w)

    #Initialize empty bitmap
    row = w * [0]
    bm = [row[:] for i in range(h)]

    #Populate bitmap with cell data
    u, v = selrect[:2]
    cells = golly.getcells(selrect)
    cellsxy = [(cells[i] - u, cells[i+1] - v) for i in range(0, len(cells), 2)]
    for x, y in cellsxy:
        bm[y][x] = 1
    return bm

def linemaker(loopm):
    ''' Create an empty LineMaker '''
    LM = pattern('''
34b2o$34bo$25b2o5bobo$24b3o5b2o$12bo8bob2o$12bobo6bo2bo$2o11bobo5bob2o
$2o11bo2bo7b3o21b2o$13bobo9b2o21b2o$12bobo$12bo9bo$23b2o$22b2o6$47b3o$
24b2o20bo3bo$24b2o19bo5bo$46bo3bo$47b3o$47b3o5$49b3o$44bo3b2ob2o$42b2o
4b2ob2o$35b2o6b2o3b5o$35b2o10b2o3b2o7$45b2o5b2o$45bo6bo$46b3o4b3o$48bo
6bo!''')
    LMTop = LM + pattern('2b2o$2bo$obo$2o!', 32, 7)
    LMBase = pattern('''
11bo$10bo$10b3o12$23b2o$23bobo$10bobo13bo$9bo2bo2b2o6bo2bo12b2o$8b2o5b
obo8bo11b3o$2o4b2o3bo3bo3bo3bobo9bob2o15bo$2o6b2o5b3ob2o2b2o10bo2bo8b
3o4bobo$9bo2bo3b2o17bob2o16bobo$10bobo25b3o2b2o2bo7bo2bo3b2o$39b2o2bo
3bo7bobo4b2o$44bo2bo6bobo$26bo17b2o8bo$24bobo$25b2o2$36bo$36bobo$36b2o
7$33bo7bo$32b4o5bobo$27b2o2bo2b2o8b2o4b2o$27b2o2b2o11b2o4b2o$16b2o6b2o
10bo7b2o$16b2o5b3o10bo4bobo$24b2o10bo4bo$27b2o$27b2o!''', 14, 29)
    LMBase += LM(55, 42, flip) 
    return LMTop(8 + loopm, -21 - loopm) + LMBase

def dmprinter(pdy, copies=1):
    ''' Generate & display a dot matrix printer for named bitmap pattern '''
    #Horizontal pixel separation between LineMakers. minimum = 5
    LMsx = 5

    #Horizontal distance between bitmap pixels. Constant, due to LineMaker period
    pdx = 15

    #Distance between LineMakers
    LMdx, LMdy = -LMsx * pdx, pdy

    #Get bitmap pattern from current selection.
    bm = get_bitmap()

    #Make printer in a new layer
    golly.duplicate()
    golly.setoption("syncviews", False)

    #Build new window title from old
    title = golly.getname().split('.')[0]
    title = '%s_Printer [%d] v0.10' % (title, pdy)
    golly.new(title)

    #Make sure we're using the standard Life generation rule
    golly.setrule("B3/S23")

    #Bitmap dimensions. Width MUST be of form 4m, for m >=1
    bmheight = len(bm)
    bmwidth = len(bm[0])
    mid = (bmheight + 1) // 2

    loopw = (bmwidth - 8) // 4
    loopm = pdx * loopw

    #Gliders, heading north-east
    g0 = pattern('2bo$2o$b2o!')
    g1 = pattern('obo$2o$bo!')
    gliders = [g0, g1, g1(0, 2, rccw), g0(0, 2, rccw),
        g0(2, 2, flip), g1(2, 2, flip), g1(2, 0, rcw), g0(2, 0, rcw)]
        
    #Create full Glider loop.
    gg = []
    ox, oy = 35, 23
    for j in range(loopw + 1):
        dd = pdx * j
        gg += [gliders[0](ox + dd, oy - dd), gliders[1](ox + 8 + dd, oy - 7 - dd)]
    dd = loopm
    gg += [gliders[2](45 + dd, 4 - dd), gliders[3](37 + dd, -3 - dd)]

    ox, oy = 26 + loopm, -4 - loopm
    for j in range(loopw + 1):
        dd = pdx * j
        gg += [gliders[4](ox - dd, oy + dd), gliders[5](ox - 8 - dd, oy + 7 + dd)]
    dd = loopm
    gg += [gliders[6](16, 15), gliders[7](24, 22)]
    parity = 2*((loopw + 1)*(0, 0) + (1, 1))

    def buildLM():
        ''' Build a complete LineMaker '''
        #Populate glider loop. (jj, ii) are bitmap coords
        gloop = pattern()
        for j in range(bmwidth):
            jj = (j - delta + bmwidth - 1) % bmwidth

            #Is there a pixel at this location?
            if bm[ii][jj] == parity[j]:                
                gloop += gg[j]  #Add glider to the loop

        #Only put LineMaker if glider loop isn't empty
        if len(gloop) > 0:
            (LMBlank + gloop).put(Lx, Ly, trans)

    #Assemble blank LineMaker
    LMBlank = linemaker(loopm)

    #Do upper LineMakers
    trans = identity
    for i in range(mid):
        ii = mid - (i + 1)
        io = mid + (i + 1)
        Lx, Ly = io * LMdx, ii * LMdy
        delta = LMsx * io
        buildLM()

    #Do lower LineMakers
    trans = flip_y
    for i in range(mid, bmheight):
        ii = i
        io = i + 2
        Lx, Ly = io * LMdx + pdx, ii * LMdy + 128
        delta = LMsx * io - 1
        buildLM()

    #Eaters facing south-east & north-east
    eaterSE = pattern('2o$bo$bobo$2b2o!')
    eaterNE = eaterSE(0, 10, flip_y)
    eY = 59
    eaters = (eaterNE(0, eY), eaterSE(0, eY))
    
    #Eater horizontal displacement. Must be odd
    #bmwidth muliplier determines number of copies visible 'outside' printer.
    eX = (bmheight + 1) * LMdx - (copies * bmwidth - 1) * pdx   
    eX = 1 + eX // 2 * 2    #Adjust parity
    all = pattern()
    for i in range(bmheight):
        all += eaters[i % (1 + LMsx % 2)](eX, i * LMdy)
    all.put()   

    #Centre view over bitmap output area
    golly.setpos(str(-pdx * bmwidth // 2 + (bmheight - 1) * LMdx), str(Ly//2))
    #golly.setmag(-2)    #Aliasing effects happen at smaller scales than -2 :(
    golly.fit()

def main():
    #Vertical distance between pixels. Maybe get this from user. minimum = 16
    pdy = 16

    #Generate & display a dot matrix printer from current selection
    dmprinter(pdy, copies=1)

    golly.setcursor("Zoom In")
    golly.setalgo("HashLife")
    golly.setbase(2)
    golly.setstep(6)

main()

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 » March 23rd, 2021, 5:34 pm

YaY !

Thank You Macbi !

how about a script for Loafer Bitmap Printers ?
"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
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 question

Post by yujh » March 25th, 2021, 7:14 am

GitHub connection bad(probably banned in other places, as tested), so I’ll report a bug of rlifesrc here

Code: Select all

 Rule:B2/S
Width:13
Height:20
Period:6
dx:0
dy:6
Diagonal width:0
Transformation:flip|
Symmetry:C1
Max cell count:0
Search order:automatic 
Choice of state for unknown cells:alive
Skip patterns with subperiod.
@alephalpha it makes this result

Code: Select all

x = 13, y = 20, rule = B2/S
.............$
.............$
.............$
.............$
.............$
.oo.......oo.$
o..o.....o..o$
.............$
.............$
.oo.......oo.$
o...........o$
...o.....o...$
....o...o....$
..o.......o..$
........o....$
..........o..$
.....o.......$
.o...........$
.............$
.............!
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 question

Post by Hunting » March 25th, 2021, 11:17 am

yujh wrote:
March 25th, 2021, 7:14 am
GitHub connection bad(probably banned in other places, as tested), so I’ll report a bug of rlifesrc here

Code: Select all

 Rule:B2/S
Width:13
Height:20
Period:6
dx:0
dy:6
Diagonal width:0
Transformation:flip|
Symmetry:C1
Max cell count:0
Search order:automatic 
Choice of state for unknown cells:alive
Skip patterns with subperiod.
@alephalpha it makes this result

Code: Select all

x = 13, y = 20, rule = B2/S
.............$
.............$
.............$
.............$
.............$
.oo.......oo.$
o..o.....o..o$
.............$
.............$
.oo.......oo.$
o...........o$
...o.....o...$
....o...o....$
..o.......o..$
........o....$
..........o..$
.....o.......$
.o...........$
.............$
.............!
That's not a bug. It flips itself every 6 gens.

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

Re: Thread for your script-related question

Post by wwei47 » March 25th, 2021, 8:14 pm

yujh wrote:
March 25th, 2021, 7:14 am
GitHub connection bad(probably banned in other places, as tested), so I’ll report a bug of rlifesrc here
Hunting wrote:
March 25th, 2021, 11:17 am
That's not a bug. It flips itself every 6 gens.
Unfortunately, this "glitch" also affects gfind and JLS-I don't know of a single spaceship search program that this "glitch" doesn't affect.
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

AlephAlpha
Posts: 66
Joined: October 6th, 2017, 1:50 am

Re: Thread for your script-related question

Post by AlephAlpha » March 26th, 2021, 9:36 am

yujh wrote:
March 25th, 2021, 7:14 am
GitHub connection bad(probably banned in other places, as tested), so I’ll report a bug of rlifesrc here

Code: Select all

 Rule:B2/S
Width:13
Height:20
Period:6
dx:0
dy:6
Diagonal width:0
Transformation:flip|
Symmetry:C1
Max cell count:0
Search order:automatic 
Choice of state for unknown cells:alive
Skip patterns with subperiod.
@alephalpha it makes this result

Code: Select all

x = 13, y = 20, rule = B2/S
.............$
.............$
.............$
.............$
.............$
.oo.......oo.$
o..o.....o..o$
.............$
.............$
.oo.......oo.$
o...........o$
...o.....o...$
....o...o....$
..o.......o..$
........o....$
..........o..$
.....o.......$
.o...........$
.............$
.............!
So I wrote a issue for this: https://github.com/AlephAlpha/rlifesrc/issues/48

Will try to fix it when I have time.

AlephAlpha
Posts: 66
Joined: October 6th, 2017, 1:50 am

Re: Thread for your script-related question

Post by AlephAlpha » March 26th, 2021, 9:59 am

yujh wrote:
March 25th, 2021, 7:14 am
GitHub connection bad(probably banned in other places, as tested), so I’ll report a bug of rlifesrc here

Code: Select all

 Rule:B2/S
Width:13
Height:20
Period:6
dx:0
dy:6
Diagonal width:0
Transformation:flip|
Symmetry:C1
Max cell count:0
Search order:automatic 
Choice of state for unknown cells:alive
Skip patterns with subperiod.
@alephalpha it makes this result

Code: Select all

x = 13, y = 20, rule = B2/S
.............$
.............$
.............$
.............$
.............$
.oo.......oo.$
o..o.....o..o$
.............$
.............$
.oo.......oo.$
o...........o$
...o.....o...$
....o...o....$
..o.......o..$
........o....$
..........o..$
.....o.......$
.o...........$
.............$
.............!
I think it is fixed now. But I'm not sure if there are new bugs.

User avatar
PkmnQ
Posts: 1137
Joined: September 24th, 2018, 6:35 am
Location: Server antipode

Re: Thread for your script-related questions

Post by PkmnQ » March 29th, 2021, 7:37 am

I know of a script that turns patterns to apgcodes, but is there a script that turns apgcodes to patterns?

Post Reply