Page 1 of 1
Random rule script
Posted: September 14th, 2020, 1:14 pm
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...
Re: Random rule script
Posted: September 14th, 2020, 1:45 pm
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
Re: Random rule script
Posted: September 14th, 2020, 2:14 pm
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)
Re: Random rule script
Posted: September 15th, 2020, 12:27 pm
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.
Re: Random rule script
Posted: September 15th, 2020, 1:08 pm
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
Re: Random rule script
Posted: September 15th, 2020, 1:16 pm
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.
Re: Random rule script
Posted: September 15th, 2020, 1:22 pm
by gameoflifemaniac
NoAyeBeardo wrote: September 15th, 2020, 1:16 pm
check if it does this with every program.
?