Re: CAViewer - A Cellular Automaton Simulator written in Python
Posted: April 16th, 2020, 4:44 pm
Are Margolus neighborhoods supported?
Forums for Conway's Game of Life
https://conwaylife.com/forums/
I have added the requested information to the error message.Your 'number of states is incorrect' error message is displayed by simply loading rule '../Others/Rule_4' and then loading a pattern from that rule. To determine what is happening do the following:
After a request is made to load a rule, write the name of the requested rule together with its number of states to the cmd window.
After a request is made to load a pattern, write the name of the requested pattern together with the required number of states and the name of the current rule and the current number of states to the cmd window.
They can be supported through the use of alternating neighbourhoods.Are Margolus neighborhoods supported?
Also for this, the error dialog says that the current rule is Rule_1 while the pattern's rule is Rule_4.Here is a screen shot after loading rule ../Others/Rule_4 and then loading pattern Oscillator
Code: Select all
rule_table_string = """
0,0,0,0,0,3,1,0,0,0,3,0,0,2,0,0,0,2,0,0,0,0,0,0,0,3,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0
2,2,2,2,2,2,2,2,1,2,2,1,2,2,1,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,3,2,1,1,2,2,2,2,1,2,2,2,1,2,1,2,2,2,3,1,1,2,1,1,1,1,1,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,1,1,2,2,1,2
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"""
lst = []
rule_table = []
for i in rule_table_string.split("\n")[1:]:
lst = []
for j in i.split(",")[:-1]:
lst.append(int(j))
rule_table.append(lst)
# Information about the Rule (Must be filled)
n_states = len(rule_table) # Number of States
alternating_period = 1 # For alternating rules / neighbourhoods
colour_palette = None # Colours of the different states
rule_name = "Rule_1" # Rule Name
# Neighbourhood of the Rule (Relative Distance from Central Cell)
def get_neighbourhood(generation): # Note (y, x) not (x, y)
return [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2),
(1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
(0, -2), (0, -1), (0, 0), (0, 1), (0, 2),
(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2)]
# Transition Function of Rule, Last Element of Neighbours is the Central Cell
def transition_func(neighbours, generation):
n = 0
weights = [1, 2, 3, 2, 1,
2, 4, 6, 4, 2,
3, 6, 9, 6, 3,
2, 4, 6, 4, 2,
1, 2, 3, 2, 1]
state_weights = [0, 1, 0, 0, 0]
for i in range(len(neighbours) - 1):
n += weights[i] * state_weights[neighbours[i]]
try:
if n >= 0:
return rule_table[neighbours[-1]][n]
else:
return 0
except IndexError:
return 0
# Does the next state of the cell depend on its neighbours?
# If yes, return next state
# If no, return -1
def depend_on_neighbours(state, generation):
return -1
Code: Select all
INFO:root:==========APPLICATION STARTING==========
INFO:root:Changed Mode to Selecting
INFO:root:Start selecting at (34, 41)
INFO:root:Stopped selecting at (90, 88)
INFO:root:Start selecting at (31, 107)
INFO:root:Stopped selecting at (31, 106)
INFO:root:Start selecting at (36, 42)
INFO:root:Stopped selecting at (93, 81)
INFO:root:Start selecting at (25, 100)
INFO:root:Stopped selecting at (25, 100)
INFO:root:Start selecting at (38, 68)
INFO:root:Stopped selecting at (93, 101)
INFO:root:Generating Single-state Soup of density 0.5 and symmetry C1
INFO:root:Start selecting at (142, 122)
INFO:root:Stopped selecting at (141, 122)
INFO:root:Start selecting at (63, 61)
INFO:root:Stopped selecting at (271, 168)
INFO:root:Start selecting at (86, 44)
INFO:root:Stopped selecting at (178, 137)
INFO:root:Generating Single-state Soup of density 0.5 and symmetry C1
INFO:root:Start selecting at (57, 85)
INFO:root:Stopped selecting at (57, 84)
INFO:root:Changed Mode to Selecting
INFO:root:Start selecting at (144, 93)
INFO:root:Stopped selecting at (187, 153)
INFO:root:Start selecting at (58, 173)
INFO:root:Stopped selecting at (58, 174)
INFO:root:==========APPLICATION STARTING==========
INFO:root:Opening Pattern...
INFO:root:Drawing at with state 1(60, 90)
INFO:root:Drawing at with state 1(60, 90)
INFO:root:Changed Mode to Selecting
INFO:root:Start selecting at (100, 58)
INFO:root:Stopped selecting at (145, 103)
INFO:root:Generating Single-state Soup of density 0.5 and symmetry C1
INFO:root:==========APPLICATION STARTING==========
INFO:root:Opening Pattern...
INFO:root:Changed Mode to Selecting
INFO:root:Start selecting at (17, 9)
INFO:root:Stopped selecting at (60, 45)
INFO:root:rule_table_string = """
0,0,0,0,0,0,1,0,0,3,0,2,9,0,0,0,0,3,0,0,0,0,0,1,1,5,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2,2,2,2,2,1,2,1,1,3,2,2,6,2,1,2,2,1,2,2,1,2,2,2,3,2,2,2,2,2,2,1,2,2,2,2,2,1,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,2,9,2,9,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
4,4,4,4,4,4,4,4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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"""
lst = []
rule_table = []
for i in rule_table_string.split("\n")[1:]:
lst = []
for j in i.split(",")[:-1]:
lst.append(int(j))
rule_table.append(lst)
# Information about the Rule (Must be filled)
n_states = len(rule_table) # Number of States
alternating_period = 1 # For alternating rules / neighbourhoods
colour_palette = None # Colours of the different states
rule_name = "Rule_4" # Rule Name
# Neighbourhood of the Rule (Relative Distance from Central Cell)
def get_neighbourhood(generation): # Note (y, x) not (x, y)
return [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2),
(1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
(0, -2), (0, -1), (0, 0), (0, 1), (0, 2),
(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2)]
# Transition Function of Rule, Last Element of Neighbours is the Central Cell
def transition_func(neighbours, generation):
n = 0
weights = [1, 2, 2, 2, 1,
2, 5, 6, 5, 2,
2, 6, 9, 6, 2,
2, 5, 6, 5, 2,
1, 2, 2, 2, 1]
state_weights = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(len(neighbours) - 1):
n += weights[i] * state_weights[neighbours[i]]
try:
if n >= 0:
return rule_table[neighbours[-1]][n]
else:
return 0
except IndexError:
return 0
# Does the next state of the cell depend on its neighbours?
# If yes, return next state
# If no, return -1
def depend_on_neighbours(state, generation):
return -1
INFO:root:==========APPLICATION STARTING==========
INFO:root:rule_table_string = """
0,0,0,0,0,0,1,0,0,3,0,2,9,0,0,0,0,3,0,0,0,0,0,1,1,5,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2,2,2,2,2,1,2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,8,8,8,5,8,5,4,8,8,8,8,8,5,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
9,9,9,9,9,9,9,9,9,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"""
lst = []
rule_table = []
for i in rule_table_string.split("\n")[1:]:
lst = []
for j in i.split(",")[:-1]:
lst.append(int(j))
rule_table.append(lst)
# Information about the Rule (Must be filled)
n_states = len(rule_table) # Number of States
alternating_period = 1 # For alternating rules / neighbourhoods
colour_palette = None # Colours of the different states
rule_name = "Rule_4" # Rule Name
# Neighbourhood of the Rule (Relative Distance from Central Cell)
def get_neighbourhood(generation): # Note (y, x) not (x, y)
return [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2),
(1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
(0, -2), (0, -1), (0, 0), (0, 1), (0, 2),
(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2)]
# Transition Function of Rule, Last Element of Neighbours is the Central Cell
def transition_func(neighbours, generation):
n = 0
weights = [1, 2, 2, 2, 1,
2, 5, 6, 5, 2,
2, 6, 9, 6, 2,
2, 5, 6, 5, 2,
1, 2, 2, 2, 1]
state_weights = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(len(neighbours) - 1):
n += weights[i] * state_weights[neighbours[i]]
try:
if n >= 0:
return rule_table[neighbours[-1]][n]
else:
return 0
except IndexError:
return 0
# Does the next state of the cell depend on its neighbours?
# If yes, return next state
# If no, return -1
def depend_on_neighbours(state, generation):
return -1
INFO:root:==========APPLICATION STARTING==========
INFO:root:Opening Pattern...
INFO:root:rule_table_string = """
0,0,0,0,0,3,1,0,0,0,3,0,0,2,0,0,0,2,0,0,0,0,0,0,0,3,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0
2,2,2,2,2,2,2,2,1,2,2,1,2,2,1,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,3,2,1,1,2,2,2,2,1,2,2,2,1,2,1,2,2,2,3,1,1,2,1,1,1,1,1,2,2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,1,1,2,2,1,2
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"""
lst = []
rule_table = []
for i in rule_table_string.split("\n")[1:]:
lst = []
for j in i.split(",")[:-1]:
lst.append(int(j))
rule_table.append(lst)
# Information about the Rule (Must be filled)
n_states = len(rule_table) # Number of States
alternating_period = 1 # For alternating rules / neighbourhoods
colour_palette = None # Colours of the different states
rule_name = "Rule_1" # Rule Name
# Neighbourhood of the Rule (Relative Distance from Central Cell)
def get_neighbourhood(generation): # Note (y, x) not (x, y)
return [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2),
(1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
(0, -2), (0, -1), (0, 0), (0, 1), (0, 2),
(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2)]
# Transition Function of Rule, Last Element of Neighbours is the Central Cell
def transition_func(neighbours, generation):
n = 0
weights = [1, 2, 3, 2, 1,
2, 4, 6, 4, 2,
3, 6, 9, 6, 3,
2, 4, 6, 4, 2,
1, 2, 3, 2, 1]
state_weights = [0, 1, 0, 0, 0]
for i in range(len(neighbours) - 1):
n += weights[i] * state_weights[neighbours[i]]
try:
if n >= 0:
return rule_table[neighbours[-1]][n]
else:
return 0
except IndexError:
return 0
# Does the next state of the cell depend on its neighbours?
# If yes, return next state
# If no, return -1
def depend_on_neighbours(state, generation):
return -1
INFO:root:==========APPLICATION STARTING==========
INFO:root:Changed Mode to Selecting
INFO:root:Start selecting at (57, 46)
INFO:root:Stopped selecting at (84, 69)
INFO:root:Start selecting at (16, 107)
INFO:root:Stopped selecting at (16, 106)
INFO:root:Start selecting at (44, 47)
INFO:root:Stopped selecting at (89, 88)
INFO:root:Generating Single-state Soup of density 0.5 and symmetry C1
INFO:root:==========APPLICATION STARTING==========
INFO:root:Opening Pattern...
INFO:root:Cancelled Operation
INFO:root:rule_table_string = """
0,0,0,0,0,0,1,0,0,3,0,2,9,0,0,0,0,3,0,0,0,0,0,1,1,5,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2,2,2,2,2,1,2,1,1,3,2,2,6,2,1,2,2,1,2,2,1,2,2,2,3,2,2,2,2,2,2,1,2,2,2,2,2,1,2,2,2,2,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2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,8,8,8
9,9,9,9,9,9,9,9,9,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"""
lst = []
rule_table = []
for i in rule_table_string.split("\n")[1:]:
lst = []
for j in i.split(",")[:-1]:
lst.append(int(j))
rule_table.append(lst)
# Information about the Rule (Must be filled)
n_states = len(rule_table) # Number of States
alternating_period = 1 # For alternating rules / neighbourhoods
colour_palette = None # Colours of the different states
rule_name = "Rule_4" # Rule Name
# Neighbourhood of the Rule (Relative Distance from Central Cell)
def get_neighbourhood(generation): # Note (y, x) not (x, y)
return [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2),
(1, -2), (1, -1), (1, 0), (1, 1), (1, 2),
(0, -2), (0, -1), (0, 0), (0, 1), (0, 2),
(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2)]
# Transition Function of Rule, Last Element of Neighbours is the Central Cell
def transition_func(neighbours, generation):
n = 0
weights = [1, 2, 2, 2, 1,
2, 5, 6, 5, 2,
2, 6, 9, 6, 2,
2, 5, 6, 5, 2,
1, 2, 2, 2, 1]
state_weights = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
for i in range(len(neighbours) - 1):
n += weights[i] * state_weights[neighbours[i]]
try:
if n >= 0:
return rule_table[neighbours[-1]][n]
else:
return 0
except IndexError:
return 0
# Does the next state of the cell depend on its neighbours?
# If yes, return next state
# If no, return -1
def depend_on_neighbours(state, generation):
return -1
INFO:root:Opening Pattern...
Working on it. Will take a while though.The 'load pattern' command has all the information needed to check the current rule, replace it with the correct rule if necessary, clear the display if the current and new number of states differ and perform any required initialization before loading the pattern.
Yes, probably next update.Do you plan to implement pattern editing such as rotating and flipping?
One button is for a Single State Random Soup and the other is for a Multi State Random Soup.Why are two buttons necessary to set a selection to a random state? A single button could simply use the current number of states to perform the operation correctly.
You could add a widget to the 'random soup settings' dialog which displays the current rule's state colors and allows the user to select which ones should be included in the soup.lemon41625 wrote: April 17th, 2020, 9:44 pm One button is for a Single State Random Soup and the other is for a Multi State Random Soup.
Can I use p2.x and p3.x at the same time?lemon41625 wrote: April 23rd, 2020, 5:07 am Download here: https://winpython.github.io/ (Download the one with Python 3.something only)
But you probably will just need python 3.6.
So, download python 3.6 or higher here: https://www.python.org/downloads/.
When installing, click the checkbox add to PATH.
After installation, go to cmd and run:
pip3 install PyQt5
pip3 install pyperclip
pip3 install numpy
pip3 install pillow
If pip3 does not work, you can just use pip.
After which, you should be able to run Main.py without issues.