idea for cool reversible 1d oca

For discussion of other cellular automata.
Post Reply
User avatar
tommyaweosme
Posts: 314
Joined: January 15th, 2024, 9:37 am

idea for cool reversible 1d oca

Post by tommyaweosme » April 27th, 2024, 1:41 pm

for my 200th post, i will show you this

three states. black, blue, and pink.

groups are in two, and move left every generation
Screenshot 2024-04-27 12.16.47 PM.png
Screenshot 2024-04-27 12.16.47 PM.png (5.95 KiB) Viewed 609 times
like margolus, but for 1D.

anyway, here is an explanation of what my idea is.

0 = black
1 = blue
2 = pink

00 > 00
01 > 12
02 > 10
10 > 01
11 > 20
12 > 21
20 > 02
21 > 11
22 > 22

here is an example:
0 0|0 2|
0|0 1|0
0 1|2 0|
1|2 0|2

if there was a way to make it in lifeviewer, i would like it.
home from sleepover

User avatar
pipsqueek
Posts: 288
Joined: September 10th, 2022, 4:42 pm
Location: Abstract mathematical space

Re: idea for cool reversible 1d oca

Post by pipsqueek » April 28th, 2024, 6:54 pm

1D Margolus rules do sound interesting, I made an emulation ruletable of this one, which is the 1D equivalent of the billiard balls rule.

Code: Select all

x = 26, y = 1, rule = 1dmargolus
DCDCDCBCDCDCDCDCDCDADCDCDC!
@RULE 1dmargolus

0 = nothing
1 = alive (even parity)
2 = alive (odd parity)
3 = dead (even parity)
4 = dead (odd parity)

red = left
blue = right

@TABLE
n_states:5
neighborhood:oneDimensional
symmetries:none

#switch parity
3,0,0,4
4,0,0,3

3,4,4,4
4,3,3,3

3,4,0,4
4,3,0,3

3,0,4,4
4,0,3,3
#rule specific transitions

#red move left
4,3,1,1
1,4,4,4
4,1,3,3

#blue move right
3,4,2,4
3,2,4,2
2,3,3,3

#bounce off eachother
2,3,1,1
1,2,4,2
1,4,2,4
2,1,3,3

#grow emulation agar
0,3,0,3
0,0,3,3
0,4,0,4
0,0,4,4
@COLORS
1 255 128 128
2 128 128 255
3 128 0 0
4 0 0 128
In fact, I wrote python implementation to simulate 1D Margolus rules. A lot of them are boring, but some of them have interesting dynamics, for example, most elementary 1D rules form down-facing triangles, however, this Margolus rule forms sideways triangles!
sidewaystriangles.png
sidewaystriangles.png (632.08 KiB) Viewed 541 times
Which follows this rule
00 -> 10
01 -> 01
10 -> 00
11 -> 11

As for the rule you described, it shouldn't be too hard to make, however, I don't think you specified enough transitions to make into a rule. But if someone were to try, I would be curious to see the results.

EDIT: I made a mistake, you actually did specify enough transitions to complete the rule. I put it into the python implementation and ran it on a random torus of size 512. Here is the result:
1dmargolus.png
1dmargolus.png (1.15 MiB) Viewed 534 times

Code: Select all

x=17,y=16,rule=B3/S23
3bo3bobo2bob2o$bobo4bo4b4o$bobo5bobo2b3o$b2obob2o3b2o$3o4b2ob2o2b2o$4b
o4bo$4b2obobob2ob3o$3ob3o2b2o$b3o2bobobo5bo$o3b2o3bobo2b2o$4bo3bob2o3b
o$2obo2bobobo2b2o$3b3o5bo2b2o$2obo4bo2bob2o$o3bob2obo3b2o$2bo8bobobo![[ STOP 3 GPS 4 ]]

User avatar
tommyaweosme
Posts: 314
Joined: January 15th, 2024, 9:37 am

Re: idea for cool reversible 1d oca

Post by tommyaweosme » April 28th, 2024, 7:55 pm

could you provide the code needed for this implement?

edit: there are only 24 2-state (edit: reversible) 1d margolus rules

edit: there are actually 4^4 (edit: 256) 2-state 1d margolus rules
home from sleepover

User avatar
pipsqueek
Posts: 288
Joined: September 10th, 2022, 4:42 pm
Location: Abstract mathematical space

Re: idea for cool reversible 1d oca

Post by pipsqueek » April 28th, 2024, 8:13 pm

Here is the code, currently configured to run the described rule. Press E to randomize the pattern, space to pause, and R to randomize the rule. Other parameters can be changed in the code.

Code: Select all

from random import randint

#parameters

cellnum = 512
cellwidth = 1024/cellnum
cellheight = 1024/cellnum
height = 320/cellheight #number of generations to show at once
states = 3 #number of cell states

rule = {}

def randomrule():
    global rule
    rule = {}
    for a in range(states):
        for b in range(states):
            rule[(a,b)] = (randint(0,states-1),randint(0,states-1))

#set the rule
rule[(0,0)] = (0,0)
rule[(0,1)] = (1,2)
rule[(0,2)] = (1,0)
rule[(1,0)] = (0,1)
rule[(1,1)] = (2,0)
rule[(1,2)] = (2,1)
rule[(2,0)] = (0,2)
rule[(2,1)] = (1,1)
rule[(2,2)] = (2,2)

cells = [randint(0,states-1) for c in range(cellnum)]
def step():
    global cells
    previous.append(cells)
    newcells = cells[:]
    for c in range(0,cellnum,2):
        partion = (cells[(c+parity)%cellnum],cells[(c+parity+1)%cellnum])
        newpartion = rule[(partion[0],partion[1])]
        newcells[(c+parity)%cellnum] = newpartion[0]
        newcells[(c+parity+1)%cellnum] = newpartion[1]
    cells = newcells

#store previous generations
previous = []

def draw():
    for p in range(len(previous)):
        for c in range(cellnum):
            '''if previous[p][c] == 0:
                color = (0,0,0)
            else:
                color = (255/previous[p][c],
                         255/previous[p][c],
                         255/previous[p][c])'''
            if previous[p][c] == 0:
                color = (0,0,0)
            if previous[p][c] == 1:
                color = (0,128,255)
            if previous[p][c] == 2:
                color = (255,0,255)
            pygame.draw.rect(window,color,
                             (c*cellwidth,p*cellheight,cellwidth,cellheight))
    if len(previous)>height:
        previous.pop(0)
    pygame.display.flip()
            
            
    


import pygame
window = pygame.display.set_mode((1024,320))
pygame.display.set_caption("1D Partioning Automata")

from time import sleep

#what cell to start partioning at (0 or 1)
parity = 0

running = True
paused = False
while running:
    parity = 1-parity
    if not paused:
        step()
        draw()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_r:
                #change the rule to a random one
                window.fill((0,0,0))
                randomrule()
                previous = []
                cells = [randint(0,states-1) for c in range(cellnum)]
            elif event.key == pygame.K_e:
                window.fill((0,0,0))
                previous = []
                cells = [randint(0,states-1) for c in range(cellnum)]
            elif event.key == pygame.K_SPACE:
                #paused the simulation
                paused = not paused
            
pygame.quit()

Code: Select all

x=17,y=16,rule=B3/S23
3bo3bobo2bob2o$bobo4bo4b4o$bobo5bobo2b3o$b2obob2o3b2o$3o4b2ob2o2b2o$4b
o4bo$4b2obobob2ob3o$3ob3o2b2o$b3o2bobobo5bo$o3b2o3bobo2b2o$4bo3bob2o3b
o$2obo2bobobo2b2o$3b3o5bo2b2o$2obo4bo2bob2o$o3bob2obo3b2o$2bo8bobobo![[ STOP 3 GPS 4 ]]

iddi01
Posts: 133
Joined: January 24th, 2024, 5:14 am
Location: B3-n/S1e2-a3-e4e

Re: 1D margolus rules

Post by iddi01 » April 29th, 2024, 10:58 am

I made some minor improvements to pipsqueek's code:

1. The program now prompts you for the torus size and the rule. Note: when it prompts you about "(x,x) becomes:", you should give two numbers without separators, like "02" (without the quotes)
2. Then, it prompts about whether or not to use a random starting condition. Type "yes" to start randomly, or "no" to start with an ordered pattern.
3. The colors now looks better.

Code: Select all

from random import randint

#parameters

cellnum = int(input("torus size: "))
cellwidth = 1024/cellnum
cellheight = 1024/cellnum
height = 320/cellheight #number of generations to show at once
states = 3 #number of cell states

rule = {}

def randomrule():
    global rule
    rule = {}
    for a in range(states):
        for b in range(states):
            rule[(a,b)] = (randint(0,states-1),randint(0,states-1))

#set the rule
rule[(0,0)] = [int(n) for n in tuple(input("(0,0) becomes: "))]
rule[(0,1)] = [int(n) for n in tuple(input("(0,1) becomes: "))]
rule[(0,2)] = [int(n) for n in tuple(input("(0,2) becomes: "))]
rule[(1,0)] = [int(n) for n in tuple(input("(1,0) becomes: "))]
rule[(1,1)] = [int(n) for n in tuple(input("(1,1) becomes: "))]
rule[(1,2)] = [int(n) for n in tuple(input("(1,2) becomes: "))]
rule[(2,0)] = [int(n) for n in tuple(input("(2,0) becomes: "))]
rule[(2,1)] = [int(n) for n in tuple(input("(2,1) becomes: "))]
rule[(2,2)] = [int(n) for n in tuple(input("(2,2) becomes: "))]

if input("randomize pattern? ").lower() == 'yes':
    cells = [randint(0,states-1) for c in range(cellnum)]
else:
    cells = [0] * (cellnum // 2) + [1] * (cellnum // 2) 
    
def step():
    global cells
    previous.append(cells)
    newcells = cells[:]
    for c in range(0,cellnum,2):
        partion = (cells[(c+parity)%cellnum],cells[(c+parity+1)%cellnum])
        newpartion = rule[(partion[0],partion[1])]
        newcells[(c+parity)%cellnum] = newpartion[0]
        newcells[(c+parity+1)%cellnum] = newpartion[1]
    cells = newcells

#store previous generations
previous = []

def draw():
    for p in range(len(previous)):
        for c in range(cellnum):
            '''if previous[p][c] == 0:
                color = (0,0,0)
            else:
                color = (255/previous[p][c],
                         255/previous[p][c],
                         255/previous[p][c])'''
            if previous[p][c] == 0:
                color = (0,0,0)
            if previous[p][c] == 1:
                color = (255,255,255)
            if previous[p][c] == 2:
                color = (0,255,0)
            pygame.draw.rect(window,color,
                             (c*cellwidth,p*cellheight,cellwidth,cellheight))
    if len(previous)>height:
        previous.pop(0)
    pygame.display.flip()
            
            
    


import pygame
window = pygame.display.set_mode((1024,320))
pygame.display.set_caption("1D Partioning Automata")

from time import sleep

#what cell to start partioning at (0 or 1)
parity = 0

running = True
paused = False
while running:
    parity = 1-parity
    if not paused:
        step()
        draw()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_r:
                #change the rule to a random one
                window.fill((0,0,0))
                randomrule()
                previous = []
                cells = [randint(0,states-1) for c in range(cellnum)]
            elif event.key == pygame.K_e:
                window.fill((0,0,0))
                previous = []
                cells = [randint(0,states-1) for c in range(cellnum)]
            elif event.key == pygame.K_SPACE:
                #paused the simulation
                paused = not paused
            
pygame.quit()
@tommyaweosme: According to Wolfram's classification (the classification for 1D rules), your rule is class 3.
@pipsqueek: Why does the script generate slower and slower over time?

The 3-state 1D margolus rulespace is really quite interesting, here are some rules i discovered:
Strobing, symmetrical, probably class 4:
Example class 4 3-state 1D margolus
Example class 4 3-state 1D margolus
1dmarg1.png (45.98 KiB) Viewed 471 times
Strobing, class 3:
Example class 3 3-state 1D margolus
Example class 3 3-state 1D margolus
1dmarg2.png (28.53 KiB) Viewed 471 times
Class 2 (uninteresting, just an example of class 2 rules):
Attachments
Example class 2 3-state 1D margolus
Example class 2 3-state 1D margolus
1dmarg3.png (21.89 KiB) Viewed 471 times
Wiki: User:iddi01

I'm making a poll. please contribute.

First gun i constructed:

Code: Select all

x = 69, y = 69, rule = B3-n/S1e2-a3-e4e
2$32b3o$32bobo$32bobo$32b3o27$63b4o$b4o58bo2bo$bo2bo23bo4b2o28b4o$b4o
21bobo$28bo21$35bo$34b3o6$33b3o$33bobo$33bobo$33b3o!

User avatar
pipsqueek
Posts: 288
Joined: September 10th, 2022, 4:42 pm
Location: Abstract mathematical space

Re: 1D margolus rules

Post by pipsqueek » April 29th, 2024, 5:10 pm

iddi01 wrote:
April 29th, 2024, 10:58 am
Why does the script generate slower and slower over time?
Each row on screen is 1 generation of the pattern. These generations are stored in one big array and displayed on the screen. When the program first starts, it doesn't have many rows in the array, so it draws it quickly. But when the entire screen is filled, it gets slow (it shouldn't get any slower, as the top row is removed when it's out of view). It could be made faster by storing the generations as pixels on the screen. Make the following modifications to the code to do so:

Code: Select all


cells = [randint(0,states-1) for c in range(cellnum)]
def step():
    global cells
    newcells = cells[:]
    for c in range(0,cellnum,2):
        partion = (cells[(c+parity)%cellnum],cells[(c+parity+1)%cellnum])
        newpartion = rule[(partion[0],partion[1])]
        newcells[(c+parity)%cellnum] = newpartion[0]
        newcells[(c+parity+1)%cellnum] = newpartion[1]
    cells = newcells

def draw():
    window.scroll(dy=-int(cellheight))
    #for p in range(len(previous)):
    for c in range(cellnum):
        if cells[c] == 0:
            color = (0,0,0)
        else:
            color = (255/cells[c],
                     255/cells[c],
                     255/cells[c])
        pygame.draw.rect(window,color,
                         (c*cellwidth,320-int(cellheight),cellwidth,cellheight))

    pygame.display.flip()
Also, I propose we dedicate this thread to 1D Margolus rules in general, rather than the one that it was originally suppose to be about. And that we change the thread's name to "1D Margolus rules".

Code: Select all

x=17,y=16,rule=B3/S23
3bo3bobo2bob2o$bobo4bo4b4o$bobo5bobo2b3o$b2obob2o3b2o$3o4b2ob2o2b2o$4b
o4bo$4b2obobob2ob3o$3ob3o2b2o$b3o2bobobo5bo$o3b2o3bobo2b2o$4bo3bob2o3b
o$2obo2bobobo2b2o$3b3o5bo2b2o$2obo4bo2bob2o$o3bob2obo3b2o$2bo8bobobo![[ STOP 3 GPS 4 ]]

User avatar
tommyaweosme
Posts: 314
Joined: January 15th, 2024, 9:37 am

Re: idea for cool reversible 1d oca

Post by tommyaweosme » April 30th, 2024, 4:41 pm

the code has random end of line markers. can you fix that please?
home from sleepover

User avatar
pipsqueek
Posts: 288
Joined: September 10th, 2022, 4:42 pm
Location: Abstract mathematical space

Re: idea for cool reversible 1d oca

Post by pipsqueek » April 30th, 2024, 6:26 pm

tommyaweosme wrote:
April 30th, 2024, 4:41 pm
the code has random end of line markers. can you fix that please?
Do you mean the newline character? Those are just for readability. The code runs fine with or without them. Without them it would be this:

Code: Select all

cells = [randint(0,states-1) for c in range(cellnum)]
def step():
    global cells
    newcells = cells[:]
    for c in range(0,cellnum,2):
        partion = (cells[(c+parity)%cellnum],cells[(c+parity+1)%cellnum])
        newpartion = rule[(partion[0],partion[1])]
        newcells[(c+parity)%cellnum] = newpartion[0]
        newcells[(c+parity+1)%cellnum] = newpartion[1]
    cells = newcells
def draw():
    window.scroll(dy=-int(cellheight))
    for c in range(cellnum):
        if cells[c] == 0:
            color = (0,0,0)
        else:
            color = (255/cells[c],255/cells[c],255/cells[c])
        pygame.draw.rect(window,color,(c*cellwidth,320-int(cellheight),cellwidth,cellheight))
    pygame.display.flip()
Just plug that in where the previous step() and draw() functions were and it should work.

Code: Select all

x=17,y=16,rule=B3/S23
3bo3bobo2bob2o$bobo4bo4b4o$bobo5bobo2b3o$b2obob2o3b2o$3o4b2ob2o2b2o$4b
o4bo$4b2obobob2ob3o$3ob3o2b2o$b3o2bobobo5bo$o3b2o3bobo2b2o$4bo3bob2o3b
o$2obo2bobobo2b2o$3b3o5bo2b2o$2obo4bo2bob2o$o3bob2obo3b2o$2bo8bobobo![[ STOP 3 GPS 4 ]]

User avatar
tommyaweosme
Posts: 314
Joined: January 15th, 2024, 9:37 am

Re: idea for cool reversible 1d oca

Post by tommyaweosme » April 30th, 2024, 8:18 pm

i meant the first two scripts posted here
edit: i mean end of file
edit: it was a problem with the compiler i was using
home from sleepover

User avatar
b-engine
Posts: 1536
Joined: October 26th, 2023, 4:11 am
Location: Somewhere on earth

Re: idea for cool reversible 1d oca

Post by b-engine » April 30th, 2024, 11:16 pm

When I run the script in Python 3.11 it gives this error:

Code: Select all

Traceback (most recent call last):
 File "wxpython.cpp", line 3, in <module>
 File "C:\Users\User\AppData\Roaming\Golly\golly_clip.py", line 5, in <module>
  cellnum = int(input("torus size: "))
            ^^^^^^^^^^^^^^^^^^^^^
RuntimeError: input(): lost sys.stdin
Can someone update the script for Python 3?
My rules
-
100th post: 18 November 2023
1000th post: 8 March 2024
10000th post:
-
Warning: This user has grammar issues, and auto-capitalize everything he clicked.

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

Re: idea for cool reversible 1d oca

Post by wildmyron » May 1st, 2024, 7:52 am

b-engine wrote:
April 30th, 2024, 11:16 pm
When I run the script in Python 3.11 it gives this error:

Code: Select all

Traceback (most recent call last):
 File "wxpython.cpp", line 3, in <module>
 File "C:\Users\User\AppData\Roaming\Golly\golly_clip.py", line 5, in <module>
  cellnum = int(input("torus size: "))
            ^^^^^^^^^^^^^^^^^^^^^
RuntimeError: input(): lost sys.stdin
Can someone update the script for Python 3?
The script should run fine in python 3, but it's not intended to be run in Golly. Instead, you should run the script with Python from a command line or using IDLE, or whichever IDE you have/use for Python. You will also need the pygame module installed.
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.

User avatar
pipsqueek
Posts: 288
Joined: September 10th, 2022, 4:42 pm
Location: Abstract mathematical space

Re: idea for cool reversible 1d oca

Post by pipsqueek » May 1st, 2024, 4:53 pm

I made a small error in the code, the parity switches when it is paused. Which means the evolution of a pattern changes when you pause. To prevent this, just replace this:

Code: Select all

parity = 1-parity
    if not paused:
        step()
        draw()
with this:

Code: Select all

if not paused:
    parity = 1-parity
    step()
    draw()

Code: Select all

x=17,y=16,rule=B3/S23
3bo3bobo2bob2o$bobo4bo4b4o$bobo5bobo2b3o$b2obob2o3b2o$3o4b2ob2o2b2o$4b
o4bo$4b2obobob2ob3o$3ob3o2b2o$b3o2bobobo5bo$o3b2o3bobo2b2o$4bo3bob2o3b
o$2obo2bobobo2b2o$3b3o5bo2b2o$2obo4bo2bob2o$o3bob2obo3b2o$2bo8bobobo![[ STOP 3 GPS 4 ]]

User avatar
tommyaweosme
Posts: 314
Joined: January 15th, 2024, 9:37 am

Re: idea for cool reversible 1d oca

Post by tommyaweosme » May 4th, 2024, 1:59 pm

thats ok. im not planning to pause on a m-
tommyaweosme j.16.24. wrote:-OPEN, CL-
that was weird

anyway, im not planning to pause on a margolus 1d oca, so that doesnt matter

any script for 2-state 1d margolus oca?
home from sleepover

User avatar
unname4798
Posts: 553
Joined: July 15th, 2023, 10:27 am

Re: idea for cool reversible 1d oca

Post by unname4798 » May 4th, 2024, 2:13 pm

tommyaweosme wrote:
May 4th, 2024, 1:59 pm
thats ok. im not planning to pause on a m-
tommyaweosme j.16.24. wrote:-OPEN, CL-
that was weird

anyway, im not planning to pause on a margolus 1d oca, so that doesnt matter

any script for 2-state 1d margolus oca?
Too complex for me.

User avatar
tommyaweosme
Posts: 314
Joined: January 15th, 2024, 9:37 am

Re: idea for cool reversible 1d oca

Post by tommyaweosme » May 4th, 2024, 2:16 pm

unname4798 wrote:
May 4th, 2024, 2:13 pm
tommyaweosme wrote:
May 4th, 2024, 1:59 pm
thats ok. im not planning to pause on a m-
tommyaweosme j.16.24. wrote:-OPEN, CL-
that was weird

anyway, im not planning to pause on a margolus 1d oca, so that doesnt matter

any script for 2-state 1d margolus oca?
Too complex for me.
IM JUST ASKING YOU TO REMOVE A STATE. AND I AM ASKING THE ENTIRE POPULATION OF CONWAYLIFE.COM, NOT JUST YOU!

sorry for snaping. im just really tired of this.
hidden lore tinley wrote:tommyaweosme, you should probably move this to a sandbox thread
ok, i will move the tommyaweosme lore clues to a sandbox thread. unless january 16 tommyaweosme comes back...

back on topic, it seems like someone already made it, so if someone could please post it please do! :D
home from sleepover

User avatar
pipsqueek
Posts: 288
Joined: September 10th, 2022, 4:42 pm
Location: Abstract mathematical space

Re: idea for cool reversible 1d oca

Post by pipsqueek » May 4th, 2024, 4:58 pm

tommyaweosme wrote:
May 4th, 2024, 2:16 pm
back on topic, it seems like someone already made it, so if someone could please post it please do! :D
You didn't notice this part of the code?

Code: Select all

states = 3 #number of cell states
Just change it to 2 and the code should work. I designed it to work with any number of states. Also, if you're using iddi01's version, you might have to change these parts too:

Code: Select all

#old coloring
if cells[c] == 0:
            color = (0,0,0)
        else:
            color = (255/cells[c],
                     255/cells[c],
                     255/cells[c])

Code: Select all

#same thing, but for 2 states
rule[(0,0)] = [int(n) for n in tuple(input("(0,0) becomes: "))]
rule[(0,1)] = [int(n) for n in tuple(input("(0,1) becomes: "))]
rule[(1,0)] = [int(n) for n in tuple(input("(1,0) becomes: "))]
rule[(1,1)] = [int(n) for n in tuple(input("(1,1) becomes: "))]
EDIT: Actually, for that last code snippet, use this instead, it works with any number of states (don't use parenthesis when inputting)

Code: Select all

for a in range(states):
    for b in range(states):
        i = input(f"({a},{b}) becomes:")
        c,d = i.split(',')
        c,d = int(c),int(d)
        rule[(a,b)] = (c,d) 

Code: Select all

x=17,y=16,rule=B3/S23
3bo3bobo2bob2o$bobo4bo4b4o$bobo5bobo2b3o$b2obob2o3b2o$3o4b2ob2o2b2o$4b
o4bo$4b2obobob2ob3o$3ob3o2b2o$b3o2bobobo5bo$o3b2o3bobo2b2o$4bo3bob2o3b
o$2obo2bobobo2b2o$3b3o5bo2b2o$2obo4bo2bob2o$o3bob2obo3b2o$2bo8bobobo![[ STOP 3 GPS 4 ]]

iddi01
Posts: 133
Joined: January 24th, 2024, 5:14 am
Location: B3-n/S1e2-a3-e4e

Re: 1D margolus rules

Post by iddi01 » May 5th, 2024, 10:47 am

I made 2 scripts which would allow the exploration of 3-state 1D margolus rules in Golly:

1. This script generates a ruletable like this one, It can be run in shell or Golly.
Type a rulestring using a simple notation: For each 2-cell configuration, type what it becomes using 2 numbers without separators, type a comma, then type what the next configuration becomes in the same way. The order for initial configurations are 00,01,02,10,11,12,20,21,22.
Example: tommyaweosme's rule would be encoded as "00,12,10,01,20,21,02,11,22".
You can choose to generate a true 1D rule or a 2D emulation.

Code: Select all

def gen1dmargtable(rulestring):
    transitions = [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
    x = 0
    y = 0
    for char in rulestring:
        if char == ' ':
            pass
        elif char == ',':
            x = 0
            y += 1
        else:
            transitions[y][x] = int(char)
            x += 1

    if __name__ == '__main__':
        emulation = input("True 1D or emulation by 2D (1D/2D)? ").upper() == "2D"
    else:
        emulation = golly.getstring("True 1D or emulation by 2D (1D/2D)? ", "1D").upper() == "2D"

    if emulation:
        temp = "0,%s,%s,0,0,0,0,0,%s,%s\n"
    else:
        temp = "%s,%s,%s,%s\n"
    table = """@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:%s
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

""" % ("Moore" if emulation else "oneDimensional")

    for n in range(9):
        table += temp % (n // 3, 'a', n % 3 + 3, transitions[n][0] + 3)
        if n % 3 == 2:
            table += temp % (n // 3, 'a', 'b', transitions[n-2][0] + 3)
            if n == 2:
                table += temp % ('0','b','a',transitions[0][0] + 3)
    for n in range(9):
        table += temp % (n % 3 + 3, n // 3, 'a', transitions[n][1])
        if n >= 6:
            table += temp % (n % 3 + 3, 'b', 'a', transitions[n-6][1])
    table += """
@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
"""
    return table

if __name__ == '__main__':
    rulestring = input('Type a rulestring, in the format "xx,xx,xx,xx,xx,xx,xx,xx,xx": ')
    print(gen1dmargtable(rulestring))
else:
    import golly
    rulestring = golly.getstring('Type a rulestring, in the format "xx,xx,xx,xx,xx,xx,xx,xx,xx": ','00,01,02,10,11,12,20,21,22')
    try:
        f = open(golly.getdir('rules') + "1dmargtest.rule", 'r')
        golly.warn("""1dmargtest.rule already exists.
Please rename the file and try again.""")
        golly.exit()
    except FileNotFoundError:
        f = open(golly.getdir('rules') + "1dmargtest.rule", 'w')
        f.write(gen1dmargtable(rulestring))
        f.close()
        golly.setrule('1dmargtest')
2. This script generates a 512x1 3-state margolus soup. It can be run in shell or Golly.

Code: Select all

import random

def gen1dmargsoup():
    char = ['.', 'A', 'B', 'C', 'D', 'E']
    rle = "x = 512, y = 1, rule = 1dmargtest\n"
    for n in range(512):
        rle += char[n % 2 * 3 + random.randrange(3)]
    return rle

if __name__ == '__main__':
    print(gen1dmargsoup())
else:
    import golly
    golly.setclipstr(gen1dmargsoup())
    golly.paste(0,0,"or")
This rulespace turned out to be more interesting than i thought. I've discovered a bunch of interesting rules, which are likely all class 4:
(Note that the ruletables below are all 2D emulation.)

00,21,02,20,00,21,10,12,22 generates adjustable-speed spaceships that interact in complex ways:

Code: Select all

x = 513, y = 1, rule = 1dmargtest
BDBC.EADADBEBDBDACBEAEBC.EAC.DACBDADAEBDADBEACBEADADBEAEACADAEADAEAD.
DBEBDBDAEBDBDBCBEAEBEBCACBCACACACBE.E.DBEACBDBEACBE.EACBCBCAEACAEBCBC
BDACAE.EBCBDADACBCACADAEBEBCBDAEBC.EBDADBEBEBEBEAC.CBEBDADBEACADBEAC.
DBEBCBEACACADBCACBDACBEACAEAEAEACACBCBDAD.EAEAEAEAEACAEACBD.EACBEBCBC
BE.EBDAEACBDBDBEBDBDBEAEAEBEBCADACBCADBEACAC.CACACBCBDACBDAEBDBCBDBEB
DAEBE.CBCBDBC.D.DAEADADBCBEBCBDAEBDBEBDBCBEACBCADBC.DBDAEBDACAEACADBE
AEADBCBCADAEBCBCBCADBDADBDBDBCBCAEBCBEBCBD.DAEADBEBEADBEADADAE.EBCBEA
EBDBDACBEAE.E.EBD.EADBEBEBCAD!

@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:Moore
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

0,0,a,0,0,0,0,0,3,3
0,0,a,0,0,0,0,0,4,5
0,0,a,0,0,0,0,0,5,3
0,0,a,0,0,0,0,0,b,3
0,0,b,0,0,0,0,0,a,3
0,1,a,0,0,0,0,0,3,5
0,1,a,0,0,0,0,0,4,3
0,1,a,0,0,0,0,0,5,5
0,1,a,0,0,0,0,0,b,5
0,2,a,0,0,0,0,0,3,4
0,2,a,0,0,0,0,0,4,4
0,2,a,0,0,0,0,0,5,5
0,2,a,0,0,0,0,0,b,4
0,3,0,0,0,0,0,0,a,0
0,4,0,0,0,0,0,0,a,1
0,5,0,0,0,0,0,0,a,2
0,3,1,0,0,0,0,0,a,0
0,4,1,0,0,0,0,0,a,0
0,5,1,0,0,0,0,0,a,1
0,3,2,0,0,0,0,0,a,0
0,3,b,0,0,0,0,0,a,0
0,4,2,0,0,0,0,0,a,2
0,4,b,0,0,0,0,0,a,1
0,5,2,0,0,0,0,0,a,2
0,5,b,0,0,0,0,0,a,2

@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
#C [[ ZOOM 1 ]]
00,20,01,02,11,12,10,21,11 has small reflectors and overall complex behavior:

Code: Select all

x = 513, y = 1, rule = 1dmargtest
BDBC.EADADBEBDBDACBEAEBC.EAC.DACBDADAEBDADBEACBEADADBEAEACADAEADAEAD.
DBEBDBDAEBDBDBCBEAEBEBCACBCACACACBE.E.DBEACBDBEACBE.EACBCBCAEACAEBCBC
BDACAE.EBCBDADACBCACADAEBEBCBDAEBC.EBDADBEBEBEBEAC.CBEBDADBEACADBEAC.
DBEBCBEACACADBCACBDACBEACAEAEAEACACBCBDAD.EAEAEAEAEACAEACBD.EACBEBCBC
BE.EBDAEACBDBDBEBDBDBEAEAEBEBCADACBCADBEACAC.CACACBCBDACBDAEBDBCBDBEB
DAEBE.CBCBDBC.D.DAEADADBCBEBCBDAEBDBEBDBCBEACBCADBC.DBDAEBDACAEACADBE
AEADBCBCADAEBCBCBCADBDADBDBDBCBCAEBCBEBCBD.DAEADBEBEADBEADADAE.EBCBEA
EBDBDACBEAE.E.EBD.EADBEBEBCAD!
@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:Moore
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

0,0,a,0,0,0,0,0,3,3
0,0,a,0,0,0,0,0,4,5
0,0,a,0,0,0,0,0,5,3
0,0,a,0,0,0,0,0,b,3
0,0,b,0,0,0,0,0,a,3
0,1,a,0,0,0,0,0,3,3
0,1,a,0,0,0,0,0,4,4
0,1,a,0,0,0,0,0,5,4
0,1,a,0,0,0,0,0,b,3
0,2,a,0,0,0,0,0,3,4
0,2,a,0,0,0,0,0,4,5
0,2,a,0,0,0,0,0,5,4
0,2,a,0,0,0,0,0,b,4
0,3,0,0,0,0,0,0,a,0
0,4,0,0,0,0,0,0,a,0
0,5,0,0,0,0,0,0,a,1
0,3,1,0,0,0,0,0,a,2
0,4,1,0,0,0,0,0,a,1
0,5,1,0,0,0,0,0,a,2
0,3,2,0,0,0,0,0,a,0
0,3,b,0,0,0,0,0,a,0
0,4,2,0,0,0,0,0,a,1
0,4,b,0,0,0,0,0,a,0
0,5,2,0,0,0,0,0,a,1
0,5,b,0,0,0,0,0,a,1

@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
#C [[ ZOOM 1 ]]
Even though nothing changes every generation except same-color blocks in 11,01,02,10,22,12,20,21,00, it still has complex behavior:

Code: Select all

x = 513, y = 1, rule = 1dmargtest
BDBC.EADADBEBDBDACBEAEBC.EAC.DACBDADAEBDADBEACBEADADBEAEACADAEADAEAD.
DBEBDBDAEBDBDBCBEAEBEBCACBCACACACBE.E.DBEACBDBEACBE.EACBCBCAEACAEBCBC
BDACAE.EBCBDADACBCACADAEBEBCBDAEBC.EBDADBEBEBEBEAC.CBEBDADBEACADBEAC.
DBEBCBEACACADBCACBDACBEACAEAEAEACACBCBDAD.EAEAEAEAEACAEACBD.EACBEBCBC
BE.EBDAEACBDBDBEBDBDBEAEAEBEBCADACBCADBEACAC.CACACBCBDACBDAEBDBCBDBEB
DAEBE.CBCBDBC.D.DAEADADBCBEBCBDAEBDBEBDBCBEACBCADBC.DBDAEBDACAEACADBE
AEADBCBCADAEBCBCBCADBDADBDBDBCBCAEBCBEBCBD.DAEADBEBEADBEADADAE.EBCBEA
EBDBDACBEAE.E.EBD.EADBEBEBCAD!
@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:Moore
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

0,0,a,0,0,0,0,0,3,4
0,0,a,0,0,0,0,0,4,3
0,0,a,0,0,0,0,0,5,3
0,0,a,0,0,0,0,0,b,4
0,0,b,0,0,0,0,0,a,4
0,1,a,0,0,0,0,0,3,4
0,1,a,0,0,0,0,0,4,5
0,1,a,0,0,0,0,0,5,4
0,1,a,0,0,0,0,0,b,4
0,2,a,0,0,0,0,0,3,5
0,2,a,0,0,0,0,0,4,5
0,2,a,0,0,0,0,0,5,3
0,2,a,0,0,0,0,0,b,5
0,3,0,0,0,0,0,0,a,1
0,4,0,0,0,0,0,0,a,1
0,5,0,0,0,0,0,0,a,2
0,3,1,0,0,0,0,0,a,0
0,4,1,0,0,0,0,0,a,2
0,5,1,0,0,0,0,0,a,2
0,3,2,0,0,0,0,0,a,0
0,3,b,0,0,0,0,0,a,1
0,4,2,0,0,0,0,0,a,1
0,4,b,0,0,0,0,0,a,1
0,5,2,0,0,0,0,0,a,0
0,5,b,0,0,0,0,0,a,2

@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
#C [[ ZOOM 1 ]]
00,12,10,21,02,12,01,21,00 may look explosive at first, but it's still class 4:

Code: Select all

x = 513, y = 1, rule = 1dmargtest
BDBC.EADADBEBDBDACBEAEBC.EAC.DACBDADAEBDADBEACBEADADBEAEACADAEADAEAD.
DBEBDBDAEBDBDBCBEAEBEBCACBCACACACBE.E.DBEACBDBEACBE.EACBCBCAEACAEBCBC
BDACAE.EBCBDADACBCACADAEBEBCBDAEBC.EBDADBEBEBEBEAC.CBEBDADBEACADBEAC.
DBEBCBEACACADBCACBDACBEACAEAEAEACACBCBDAD.EAEAEAEAEACAEACBD.EACBEBCBC
BE.EBDAEACBDBDBEBDBDBEAEAEBEBCADACBCADBEACAC.CACACBCBDACBDAEBDBCBDBEB
DAEBE.CBCBDBC.D.DAEADADBCBEBCBDAEBDBEBDBCBEACBCADBC.DBDAEBDACAEACADBE
AEADBCBCADAEBCBCBCADBDADBDBDBCBCAEBCBEBCBD.DAEADBEBEADBEADADAE.EBCBEA
EBDBDACBEAE.E.EBD.EADBEBEBCAD!
@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:Moore
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

0,0,a,0,0,0,0,0,3,3
0,0,a,0,0,0,0,0,4,4
0,0,a,0,0,0,0,0,5,4
0,0,a,0,0,0,0,0,b,3
0,0,b,0,0,0,0,0,a,3
0,1,a,0,0,0,0,0,3,5
0,1,a,0,0,0,0,0,4,3
0,1,a,0,0,0,0,0,5,4
0,1,a,0,0,0,0,0,b,5
0,2,a,0,0,0,0,0,3,3
0,2,a,0,0,0,0,0,4,5
0,2,a,0,0,0,0,0,5,3
0,2,a,0,0,0,0,0,b,3
0,3,0,0,0,0,0,0,a,0
0,4,0,0,0,0,0,0,a,2
0,5,0,0,0,0,0,0,a,0
0,3,1,0,0,0,0,0,a,1
0,4,1,0,0,0,0,0,a,2
0,5,1,0,0,0,0,0,a,2
0,3,2,0,0,0,0,0,a,1
0,3,b,0,0,0,0,0,a,0
0,4,2,0,0,0,0,0,a,1
0,4,b,0,0,0,0,0,a,2
0,5,2,0,0,0,0,0,a,0
0,5,b,0,0,0,0,0,a,0

@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
#C [[ ZOOM 1 ]]
00,10,02,01,22,12,20,21,11 is population-conserving, but the behavior seems to be more complex than the aforementioned rules:

Code: Select all

x = 513, y = 1, rule = 1dmargtest
BDBC.EADADBEBDBDACBEAEBC.EAC.DACBDADAEBDADBEACBEADADBEAEACADAEADAEAD.
DBEBDBDAEBDBDBCBEAEBEBCACBCACACACBE.E.DBEACBDBEACBE.EACBCBCAEACAEBCBC
BDACAE.EBCBDADACBCACADAEBEBCBDAEBC.EBDADBEBEBEBEAC.CBEBDADBEACADBEAC.
DBEBCBEACACADBCACBDACBEACAEAEAEACACBCBDAD.EAEAEAEAEACAEACBD.EACBEBCBC
BE.EBDAEACBDBDBEBDBDBEAEAEBEBCADACBCADBEACAC.CACACBCBDACBDAEBDBCBDBEB
DAEBE.CBCBDBC.D.DAEADADBCBEBCBDAEBDBEBDBCBEACBCADBC.DBDAEBDACAEACADBE
AEADBCBCADAEBCBCBCADBDADBDBDBCBCAEBCBEBCBD.DAEADBEBEADBEADADAE.EBCBEA
EBDBDACBEAE.E.EBD.EADBEBEBCAD!
@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:Moore
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

0,0,a,0,0,0,0,0,3,3
0,0,a,0,0,0,0,0,4,4
0,0,a,0,0,0,0,0,5,3
0,0,a,0,0,0,0,0,b,3
0,0,b,0,0,0,0,0,a,3
0,1,a,0,0,0,0,0,3,3
0,1,a,0,0,0,0,0,4,5
0,1,a,0,0,0,0,0,5,4
0,1,a,0,0,0,0,0,b,3
0,2,a,0,0,0,0,0,3,5
0,2,a,0,0,0,0,0,4,5
0,2,a,0,0,0,0,0,5,4
0,2,a,0,0,0,0,0,b,5
0,3,0,0,0,0,0,0,a,0
0,4,0,0,0,0,0,0,a,0
0,5,0,0,0,0,0,0,a,2
0,3,1,0,0,0,0,0,a,1
0,4,1,0,0,0,0,0,a,2
0,5,1,0,0,0,0,0,a,2
0,3,2,0,0,0,0,0,a,0
0,3,b,0,0,0,0,0,a,0
0,4,2,0,0,0,0,0,a,1
0,4,b,0,0,0,0,0,a,0
0,5,2,0,0,0,0,0,a,1
0,5,b,0,0,0,0,0,a,2

@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
#C [[ ZOOM 1 ]]
00,11,12,10,12,21,22,21,02 is one of the sideways triangles rules, and not explosive:

Code: Select all

x = 513, y = 1, rule = 1dmargtest
BDBC.EADADBEBDBDACBEAEBC.EAC.DACBDADAEBDADBEACBEADADBEAEACADAEADAEAD.
DBEBDBDAEBDBDBCBEAEBEBCACBCACACACBE.E.DBEACBDBEACBE.EACBCBCAEACAEBCBC
BDACAE.EBCBDADACBCACADAEBEBCBDAEBC.EBDADBEBEBEBEAC.CBEBDADBEACADBEAC.
DBEBCBEACACADBCACBDACBEACAEAEAEACACBCBDAD.EAEAEAEAEACAEACBD.EACBEBCBC
BE.EBDAEACBDBDBEBDBDBEAEAEBEBCADACBCADBEACAC.CACACBCBDACBDAEBDBCBDBEB
DAEBE.CBCBDBC.D.DAEADADBCBEBCBDAEBDBEBDBCBEACBCADBC.DBDAEBDACAEACADBE
AEADBCBCADAEBCBCBCADBDADBDBDBCBCAEBCBEBCBD.DAEADBEBEADBEADADAE.EBCBEA
EBDBDACBEAE.E.EBD.EADBEBEBCAD!
@RULE 1dmargtest

@TABLE
n_states:6
neighborhood:Moore
symmetries:none
var a = {0,1,2,3,4,5}
var b = {1,2,3,4,5}

0,0,a,0,0,0,0,0,3,3
0,0,a,0,0,0,0,0,4,4
0,0,a,0,0,0,0,0,5,4
0,0,a,0,0,0,0,0,b,3
0,0,b,0,0,0,0,0,a,3
0,1,a,0,0,0,0,0,3,4
0,1,a,0,0,0,0,0,4,4
0,1,a,0,0,0,0,0,5,5
0,1,a,0,0,0,0,0,b,4
0,2,a,0,0,0,0,0,3,5
0,2,a,0,0,0,0,0,4,5
0,2,a,0,0,0,0,0,5,3
0,2,a,0,0,0,0,0,b,5
0,3,0,0,0,0,0,0,a,0
0,4,0,0,0,0,0,0,a,1
0,5,0,0,0,0,0,0,a,2
0,3,1,0,0,0,0,0,a,0
0,4,1,0,0,0,0,0,a,2
0,5,1,0,0,0,0,0,a,1
0,3,2,0,0,0,0,0,a,2
0,3,b,0,0,0,0,0,a,0
0,4,2,0,0,0,0,0,a,1
0,4,b,0,0,0,0,0,a,1
0,5,2,0,0,0,0,0,a,2
0,5,b,0,0,0,0,0,a,2

@COLORS
0 62 62 62
1 220 220 220
2 0 220 0
3 90 90 90
4 255 255 255
5 0 255 0
#C [[ ZOOM 1 ]]
pipsqueek wrote:
April 29th, 2024, 5:10 pm
Also, I propose we dedicate this thread to 1D Margolus rules in general, rather than the one that it was originally suppose to be about. And that we change the thread's name to "1D Margolus rules".
I totally agree. If you look at my last post in here (and this post), you'll see that it says "Re: 1D margolus rules".
Wiki: User:iddi01

I'm making a poll. please contribute.

First gun i constructed:

Code: Select all

x = 69, y = 69, rule = B3-n/S1e2-a3-e4e
2$32b3o$32bobo$32bobo$32b3o27$63b4o$b4o58bo2bo$bo2bo23bo4b2o28b4o$b4o
21bobo$28bo21$35bo$34b3o6$33b3o$33bobo$33bobo$33b3o!

Post Reply