Random rule script

A forum for topics that don't fit elsewhere. Introduce yourselves to other members of the forums, discuss how your name evolves when written out in the Game of Life, or just tell us how you found it. Forum rules still apply.
Post Reply
User avatar
NoAyeBeardo
Posts: 261
Joined: June 16th, 2020, 12:38 pm
Location: A house, or a flat, or a [click to expand]

Random rule script

Post by NoAyeBeardo »

So the purpose of this is to make a Python script that can generate a rule. I've made a (bad) one that requires manual inspecting as duplicates can often happen(also, for some reason it prints up to a certain number:

Code: Select all

#Random rule
#Not Including Hensel notation
#0-8:
import random
basic_notation = ['0','1','2','3','4','5','6','7','8']
for y in range(1,10):
    B = []
    S = []
    for x in range(0, random.randint(1,8)):
        B.append(basic_notation[random.randint(0,8)]) 
    for x in range(0, random.randint(1,8)):
        S.append(basic_notation[random.randint(0,8)])
    print('B')
    for BItem in range(0, len(B)):
        print(BItem)
    print('S')
    for SItem in range(0, len(S)):
        print(SItem)
    print('==============================')
And I posted this in the Sandbox forum because the Scripts forum says 'For scripts to aid with computation or simulation in cellular automata.' which doesn't fit a random rule generator...
Not inactive any more! :D
User avatar
gameoflifemaniac
Posts: 1249
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: Random rule script

Post by gameoflifemaniac »

NoAyeBeardo wrote: September 14th, 2020, 1:14 pm So the purpose of this is to make a Python script that can generate a rule. I've made a (bad) one that requires manual inspecting as duplicates can often happen(also, for some reason it prints up to a certain number:

Code: Select all

#Random rule
#Not Including Hensel notation
#0-8:
import random
basic_notation = ['0','1','2','3','4','5','6','7','8']
for y in range(1,10):
    B = []
    S = []
    for x in range(0, random.randint(1,8)):
        B.append(basic_notation[random.randint(0,8)]) 
    for x in range(0, random.randint(1,8)):
        S.append(basic_notation[random.randint(0,8)])
    print('B')
    for BItem in range(0, len(B)):
        print(BItem)
    print('S')
    for SItem in range(0, len(S)):
        print(SItem)
    print('==============================')
And I posted this in the Sandbox forum because the Scripts forum says 'For scripts to aid with computation or simulation in cellular automata.' which doesn't fit a random rule generator...
it doesn't do anything when I run it
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!
goldenratio
Posts: 295
Joined: July 26th, 2020, 10:39 pm
Location: Connecticut, USA

Re: Random rule script

Post by goldenratio »

Something is seriously wrong; this is what I get when I run it (not in Golly):

Code: Select all

B
0
1
2
S
0
1
2
3
4
5
6
7
==============================
B
0
1
2
3
4
S
0
1
2
3
4
5
==============================
B
0
S
0
1
2
3
4
5
==============================
B
0
1
2
3
4
5
6
S
0
1
2
3
4
5
6
7
==============================
B
0
1
2
3
4
S
0
1
==============================
B
0
1
2
3
4
S
0
1
2
3
4
==============================
B
0
1
2
3
4
S
0
1
2
3
4
5
6
==============================
B
0
1
S
0
1
2
3
==============================
B
0
1
2
3
S
0
1
2
==============================
EDIT: My attempt at fixing it up:

Code: Select all

#Random rule
#Not Including Hensel notation
import golly as g
import random
birth_letters = ("3", "4", "5", "6", "7", "8")
survival_letters = ("0", "1", "2", "3", "4", "5", "6", "7", "8")
rulestr = "B"
for y in range (0, random.randint(1, 6)):
    rulestr += random.choice(birth_letters)
rulestr += "/S"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(survival_letters)
g.setrule(rulestr)
    
I might return someday. Don't count on it though.
User avatar
NoAyeBeardo
Posts: 261
Joined: June 16th, 2020, 12:38 pm
Location: A house, or a flat, or a [click to expand]

Re: Random rule script

Post by NoAyeBeardo »

Well the thing is that (I didn't mention this) I wanted to do it without the 'import golly as g' thing, as my python doesn't recognise it. However, I did change goldenratio's script to be without Golly commands(and truly random):

Code: Select all

#Random rule
#Not Including Hensel notation
import random
birth_letters = ("0","1","2","3", "4", "5", "6", "7", "8")
survival_letters = ("0", "1", "2", "3", "4", "5", "6", "7", "8")
rulestr = "B"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(birth_letters)
rulestr += "/S"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(survival_letters)
print(rulestr)
But by the end of this, I want to have a completely random rule generator with Hensel notation and without repeats.
Not inactive any more! :D
User avatar
gameoflifemaniac
Posts: 1249
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: Random rule script

Post by gameoflifemaniac »

NoAyeBeardo wrote: September 15th, 2020, 12:27 pm Well the thing is that (I didn't mention this) I wanted to do it without the 'import golly as g' thing, as my python doesn't recognise it. However, I did change goldenratio's script to be without Golly commands(and truly random):

Code: Select all

#Random rule
#Not Including Hensel notation
import random
birth_letters = ("0","1","2","3", "4", "5", "6", "7", "8")
survival_letters = ("0", "1", "2", "3", "4", "5", "6", "7", "8")
rulestr = "B"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(birth_letters)
rulestr += "/S"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(survival_letters)
print(rulestr)
But by the end of this, I want to have a completely random rule generator with Hensel notation and without repeats.
it exits immediately after i run it
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!
User avatar
NoAyeBeardo
Posts: 261
Joined: June 16th, 2020, 12:38 pm
Location: A house, or a flat, or a [click to expand]

Re: Random rule script

Post by NoAyeBeardo »

gameoflifemaniac wrote: September 15th, 2020, 1:08 pm
NoAyeBeardo wrote: September 15th, 2020, 12:27 pm Well the thing is that (I didn't mention this) I wanted to do it without the 'import golly as g' thing, as my python doesn't recognise it. However, I did change goldenratio's script to be without Golly commands(and truly random):

Code: Select all

#Random rule
#Not Including Hensel notation
import random
birth_letters = ("0","1","2","3", "4", "5", "6", "7", "8")
survival_letters = ("0", "1", "2", "3", "4", "5", "6", "7", "8")
rulestr = "B"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(birth_letters)
rulestr += "/S"
for y in range (0, random.randint(1, 8)):
    rulestr += random.choice(survival_letters)
print(rulestr)
But by the end of this, I want to have a completely random rule generator with Hensel notation and without repeats.
it exits immediately after i run it
It doesn't for me, check if it does this with every program.
Not inactive any more! :D
User avatar
gameoflifemaniac
Posts: 1249
Joined: January 22nd, 2017, 11:17 am
Location: There too

Re: Random rule script

Post by gameoflifemaniac »

NoAyeBeardo wrote: September 15th, 2020, 1:16 pm check if it does this with every program.
?
I was so socially awkward in the past and it will haunt me for the rest of my life.

Code: Select all

b4o25bo$o29bo$b3o3b3o2bob2o2bob2o2bo3bobo$4bobo3bob2o2bob2o2bobo3bobo$
4bobo3bobo5bo5bo3bobo$o3bobo3bobo5bo6b4o$b3o3b3o2bo5bo9bobo$24b4o!
Post Reply