Page 2 of 7

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 4:44 pm
by Apollyon094
Are Margolus neighborhoods supported?

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 7:45 pm
by lemon41625
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.
I have added the requested information to the error message.
However, I am unable to reproduce this error. Could you share with me which pattern you loaded?
Are Margolus neighborhoods supported?
They can be supported through the use of alternating neighbourhoods.
However, I don't think that block cellular automaton is supported.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 10:09 pm
by bprentice
Here is a screen shot after loading rule ../Others/Rule_4 and then loading pattern Oscillator:

Error.png
Error.png (1.29 MiB) Viewed 9295 times

If you had done what I suggested rather than change your error dialog we would have got more useful information.

Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 10:35 pm
by bprentice
Here is screen shot after loading rule ../Others/Rule_1 and then loading pattern Gun:

Error2.png
Error2.png (1.22 MiB) Viewed 9287 times

Notice that the shape of the gun is correct but the state colors are incorrect.

Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 10:43 pm
by lemon41625
Could you upload the contents of transFunc.py here for the incorrect state colours?
And does the simulation still run?
Here is a screen shot after loading rule ../Others/Rule_4 and then loading pattern Oscillator
Also for this, the error dialog says that the current rule is Rule_1 while the pattern's rule is Rule_4.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 11:16 pm
by bprentice
Copy of file transFunc.py from ../Others/Rule_1:

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
Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 11:23 pm
by lemon41625
There is no problem with the file.
Perhaps you should check if the transFunc.py inside the same folder as Main.py has the contents of Rule_4 or Rule_1. I am only able to replicate this error if Rule_4 is loaded instead of Rule_1.

I have added logging of the rule file into log.log instead of cmd as it would get too cluttered. When reporting bugs in future, please upload log.log as well.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 16th, 2020, 11:49 pm
by bprentice
An important fact that I have not mentioned is that the behavior of a rule seems to depend on prior activity. All of the example problems that are documented above are intermittent. Sometimes the rules work correctly and sometimes they don't.

I will try your new version tomorrow.

Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 17th, 2020, 6:40 am
by bprentice
Tried the new version. Loading rule ../Others/Rule_4 and then loading pattern Oscillator produced the same error dialog as shown above.

Here is log.log:

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,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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: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,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7,7,7,7,7,7,7
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,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,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8,8,8,8,8,8,8,8,8,8,8,8,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:Opening Pattern...
Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 17th, 2020, 10:15 am
by lemon41625
I have managed to recreate the error.
When a new rule is opened, a message pops up to say that you have to reload the application before the rule updates.

I believe you did not reload the application. I hope this helps. Please inform me of any other bugs.
I will add this to the README.md.
Pic.png
Pic.png (35.99 KiB) Viewed 9217 times

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 17th, 2020, 1:34 pm
by bprentice
Requiring the user to close the cmd window, execute RunMain.bat, reposition and resize the cmd and application windows in order to successfully change rules is a serious inconvenience. Your software should do all the required initializing. The 'load rule' command is not even necessary. 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.

Consider centering a new pattern in the display when loading. Placing them in the top left corner causes a ship to be quickly lost if it is moving up or left.

Do you plan to implement pattern editing such as rotating and flipping?

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.

Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 17th, 2020, 9:44 pm
by lemon41625
Update v1.6:

Added Random Rule Generation - "?" for random transition in rulestring (b3s?,3) -> New Rule in File Menu
Note: Random Generation of Neighbourhood Weights is not Isotropic Yet (Working on it)
Removed need to reload application after loading rule
When opening pattern, it is now lower and further to the left. However, it is still not centred. For that, I will need window size.
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.
Working on it. Will take a while though.
Do you plan to implement pattern editing such as rotating and flipping?
Yes, probably next update.
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.
One button is for a Single State Random Soup and the other is for a Multi State Random Soup.

Source Code + WinPython Installation Here:
https://github.com/jedlimlx/Cellular-Automaton-Viewer

Source Code Only is as attached

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 17th, 2020, 10:43 pm
by bprentice
Big improvement, well done!
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.
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.

Consider keyboard short cuts for starting and stopping the simulation (return key), stepping the simulation (space bar)

It would be nice if the current rule name, pattern name and number of state's were displayed.

Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 20th, 2020, 9:06 am
by lemon41625
Update v1.7:

Added Keyboard Shortcuts for Stepping 1 Generation (Space) and Pausing / Running Simulation (Return)
Now replaces current rule with required rule when pattern is loaded
Added Rotating and Flipping Selection
Displays Pattern Name and Rule Name as well as number of states
Random Generation of Neighbourhood Weights is now Isotropic

In transFunc.py, there is a script that implements range 2 isotropic non totalistic von neumann rulespace. I have fixed it.
It still does not simulate the SkewLife correctly. I am not sure it is because I did something wrong or the rulestring is wrong.

Also I am looking for suggestions on how to identify patterns such as rakes, puffers, breeders and replicators as well as find their speed.

Source Code + WinPython Installation here:
https://github.com/jedlimlx/Cellular-Automaton-Viewer

Source Code is as attached

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 22nd, 2020, 10:14 am
by lemon41625
Update v1.8:

Added options for choosing what states to include in random soup.
Added identification for replicators (It is somewhat reliable, does not working for moving replicators and quadratic replicators yet).
- Also does not work for replicators that produce debris.
- Does not always work. Tested it on Brian Prentice's Oblique Replicator https://conwaylife.com/forums/viewtopic ... 7&start=25
(Did not work)

Added more rules to Rules Folder:
WeighedGenerations_Rule_10 - It is non-isotropic and has oblique wickstrecher and spaceship.


Picture of Replicator Identification in PigsReverseGenerationsVariant
Pic.png
Pic.png (44.31 KiB) Viewed 9028 times
Source Code + WinPython Installation: https://github.com/jedlimlx/Cellular-Automaton-Viewer
Source Code is attached:

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 22nd, 2020, 3:44 pm
by bprentice
To simplify and reduce the number of your transition functions consider a design that uses python classes to implement rule families.

An object created from the base rule class reads and writes the pattern specification which is common to all rules. Objects created from inherited rule classes implement a specific rule family. Methods in these inherited classes use dialogs to display and obtain rule parameters and options. Methods are also provided to generate and test new rules.

All pattern files contain a complete description of their associated rule. This would include the rule parameters and options.

As an example a single rule family using dialogs like these which specify the Star Wars rule:

d1.png
d1.png (104.66 KiB) Viewed 9012 times
d2.png
d2.png (61.99 KiB) Viewed 9012 times

could be used to specify your Outer Totalistic (normal and weighted) rules, Generations (normal and weighted) rules and Rule_1 thru Rule_4 in your Others directory. As a bonus such a rule family supports the Wire World rule and variants.

As a test of your pattern editing implementation construct this pattern from a single cell:

p.png
p.png (242.58 KiB) Viewed 9012 times


Brian Prentice

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 22nd, 2020, 10:07 pm
by lemon41625
I have already done something similar here:
Pic.png
Pic.png (44.31 KiB) Viewed 8992 times
However, custom rule families are not yet supported. I will get it done soon.
Next update, I will also add BokaBB's Semi Totalistic Larger then Life and my regenerating generations rulespace.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 22nd, 2020, 11:25 pm
by yujh
Are you going to try something like apgsearch there?

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 23rd, 2020, 1:09 am
by lemon41625
I will eventually get to it. However, it would be really slow unless I find a way to optimize that algorithm.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 23rd, 2020, 4:25 am
by yujh
Oh and where can I download the wpy64 thing?( original site)

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 23rd, 2020, 5:07 am
by lemon41625
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.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 23rd, 2020, 6:07 am
by yujh
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.
Can I use p2.x and p3.x at the same time?

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 23rd, 2020, 6:18 am
by lemon41625
Yes. If Python 2.x is added to your PATH already, do not add Python 3.x to your PATH.

Instead to install the packages you will have to 'cd' into the Python 3.x installation folder and pip install from there.

However, I think it would be better if you installed https://winpython.github.io/ if that is the case.
Download WinPython64-3.7.7.0dot from https://sourceforge.net/projects/winpyt ... 7/3.7.7.0/.

After downloading, there is an .exe that will unzip into the installation.
Move the folders into the CAViewer folder.

Run the pip commands I mentioned above in the WinPython Command Prompt.
Afterwards, you should be able to run Main.bat and the program should start.

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 25th, 2020, 6:54 am
by lemon41625
Update v1.9:

Added BokaBB's Semi Totalistic Rulespace (For now it is avaliable as a b/s condition for single state and extended generations rules)
Added Regenerating Generations Rulespace
Added Some Sample Rules using the 2 Rulespaces to Rules Folder

If you have any feedback about the application or problems running it, please let me know.

Note: There was a major bug in the previous release of v1.9, I have uploaded the fixed copy.

Update v1.9.1:
Just a small update with minor improvements.
BokaBB Rulespace Simulation is Now Faster (Supporting Various Neighbourhoods and Weights)

Added Some Sample Rules using BokaBB B/S Condition (In the application, it is called BokaBB until it gets a proper name)
GIF of one of the rules:
BokaBB2.gif
BokaBB2.gif (991.65 KiB) Viewed 8864 times
Source Code + WinPython Installation: https://github.com/jedlimlx/Cellular-Automaton-Viewer
Source Code as Attached:

Re: CAViewer - A Cellular Automaton Simulator written in Python

Posted: April 26th, 2020, 10:14 am
by bprentice
How are rules GenerationsBokaBB_Rule_1 and GenerationsBokaBB_Rule_2 loaded?

The expected transFunc.py file has been replaced by a rule.ca_rule file in their directories.


Brian Prentice