diff --git a/.gitignore b/.gitignore index d9024f1..9df9b77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -docs/ .vscode/ environment/ tests/ diff --git a/README.md b/README.md index 58b228d..0cd9ac9 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The template system was created in an effort to decrease the risk of entering in * timesteps: integer > 0. * sim_type: str takes value of 'visual' or 'full'. * tempurature: int between 1 and 5 -* struct_mode: str takes values of 'static', 'blinker', 'toad', 'glider', 'pulsar', 'beacon', 'gun', 'pentadecon', 'heavyglider' and 'none' (no structure added). +* struct_mode: str takes values of 'static', 'blinker', 'toad', 'glider' and 'none' (no structure added). * dyn_mode: str takes values of 'cyclic', 'absorbing', 'half', 'dynamic', 'cut' and 'none' (default start state) * prob: list (array object in json terms) of length 3. * *cahn simulation*: all values other than the default first three are floating point numbers. diff --git a/docs/Checkpoint 1.pdf b/docs/Checkpoint 1.pdf new file mode 100644 index 0000000..fc8d844 Binary files /dev/null and b/docs/Checkpoint 1.pdf differ diff --git a/docs/Checkpoint 2.pdf b/docs/Checkpoint 2.pdf new file mode 100644 index 0000000..fd88d5d Binary files /dev/null and b/docs/Checkpoint 2.pdf differ diff --git a/docs/Checkpoint 3.pdf b/docs/Checkpoint 3.pdf new file mode 100644 index 0000000..35ad9b0 Binary files /dev/null and b/docs/Checkpoint 3.pdf differ diff --git a/docs/Checkpoint Practice.pdf b/docs/Checkpoint Practice.pdf new file mode 100644 index 0000000..4c35b9c Binary files /dev/null and b/docs/Checkpoint Practice.pdf differ diff --git a/docs/Lecture 1.pdf b/docs/Lecture 1.pdf new file mode 100644 index 0000000..05ce6e5 Binary files /dev/null and b/docs/Lecture 1.pdf differ diff --git a/docs/Lecture 2.pdf b/docs/Lecture 2.pdf new file mode 100644 index 0000000..3f83ff9 Binary files /dev/null and b/docs/Lecture 2.pdf differ diff --git a/docs/Lecture 3.pdf b/docs/Lecture 3.pdf new file mode 100644 index 0000000..e569388 Binary files /dev/null and b/docs/Lecture 3.pdf differ diff --git a/help/reactionDiffusion.png b/help/reactionDiffusion.png new file mode 100644 index 0000000..c4f6d69 Binary files /dev/null and b/help/reactionDiffusion.png differ diff --git a/main.py b/main.py index 537f439..6c1cbe2 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ def main(): general_utils.check_directories() # gets name of module python files tools/utils - modules = general_utils.get_py_files(general_utils.MODULEPATH) + modules = general_utils.get_py_files(general_utils.MODULE_PATH) # resolves module class names into a list (references to classes) module_class = [general_utils.str_to_class("tools", module) for module in modules] diff --git a/packages/__init__.py b/packages/__init__.py index b3b4353..7dfec01 100644 --- a/packages/__init__.py +++ b/packages/__init__.py @@ -1,4 +1,4 @@ from tools.utils import general_utils -__all__ = general_utils.get_py_files(general_utils.SIMPATH) +__all__ = general_utils.get_py_files(general_utils.SIM_PATH) diff --git a/packages/controller/simulationPlane.py b/packages/controller/simulationPlane.py index 8719e57..379a560 100644 --- a/packages/controller/simulationPlane.py +++ b/packages/controller/simulationPlane.py @@ -22,7 +22,6 @@ def __init__(self, dimensions, timesteps): def create_figure(self): """ Creates the figure elements for the simulations """ - plt.rcParams.update(general_utils.returnGraphConfigs("anim")) self.fig = plt.figure() self.axes = plt.axes() self.axes.set_xlabel("Cells In X (Columns)") @@ -74,11 +73,11 @@ def check_all_nieghbours(self, coordinate): def d_index(self, coord): """Decrease index number in array in up or right directions""" - return coord - 1 if coord - 1 < 0 else self.dimensions - 1 + return coord - 1 if coord - 1 >= 0 else self.dimensions - 1 def i_index(self, coord): """Increase index number in array in down or left directions""" - return coord + 1 if coord + 1 > self.dimensions - 1 else 0 + return coord + 1 if coord + 1 <= self.dimensions - 1 else 0 def end_simulation(self): time.sleep(1) diff --git a/packages/reaction.py b/packages/reaction.py new file mode 100644 index 0000000..37a7029 --- /dev/null +++ b/packages/reaction.py @@ -0,0 +1,60 @@ +import numpy as np +from packages.controller import SimulationPlane +from tools.utils import sim_utils + +class Reaction(SimulationPlane): + def __init__(self, dimensions, timesteps, k, sigma, dt): + super().__init__(dimensions, timesteps) + self.k = k + self.sigma = sigma + self.dt = dt + + #override + def start_sim(self): + self.create_cells() + self.create_figure() + super().start_sim() + + #override + def create_figure(self): + super().create_figure() + self.axes.set_title("Reaction-Diffusion Simulation For {} Cells".format(self.dimensions ** 2)) + self.im = self.axes.imshow(self.cells, interpolation = "nearest", animated = True) + self.fig.colorbar(self.im) + #override + def create_cells(self): + self.cells = np.random.uniform(low=-0.1, high=0.1, size=(self.dimensions, self.dimensions)) + for i in range(self.dimensions): + for j in range(self.dimensions): + self.cells[i, j] += 0.5 + + #override + def anim_func(self, i): + self.new_cells = np.copy(self.cells) + for i in range(self.dimensions): + for j in range(self.dimensions): + self.new_cells[i, j] = self.reaction_procedure(i, j) + self.cells = np.copy(self.new_cells) + self.im.set_array(self.cells) + self.check_sim() + yield self.im + + def reaction_procedure(self, i , j): + laplacian = self.dt * ( + self.cells[self.i_index(i), j] + \ + self.cells[self.d_index(i), j] + \ + self.cells[i, self.i_index(j)] + \ + self.cells[i, self.d_index(j)] - \ + 4 * self.cells[i, j] + ) + constants = self.dt * self.calc_row(i, j) - self.k * self.cells[i, j] + new_value = laplacian + constants + return new_value + + def calc_row(self, i , j): + i_component = i - (self.dimensions / 2) + j_component = j - (self.dimensions / 2) + mag_r = np.sqrt(i_component ** 2 + j_component ** 2) + row = np.exp(-(mag_r ** 2) / (self.sigma ** 2)) + return row + diff --git a/params/cahn - 2019,04,04 23,05,18.996745.json b/params/cahn - 2019,04,04 23,05,18.996745.json deleted file mode 100644 index bad3b61..0000000 --- a/params/cahn - 2019,04,04 23,05,18.996745.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "mode": "cahn", - "dimensions": "200", - "timesteps": "10000", - "default_values": [100, 10000, "visual", 1, 0.1, 0.1, 0.1, 0, 0.5], - "sim_type": "full", - "dx_value": "1", - "M": "0.1", - "a_and_b": "0.1", - "k": "0.1", - "sig0": "0", - "noise": "0.5" -} diff --git a/params/gol - 2019,04,05 12,20,40.124700.json b/params/gol - 2019,04,05 12,20,40.124700.json index b497f62..8aae65c 100644 --- a/params/gol - 2019,04,05 12,20,40.124700.json +++ b/params/gol - 2019,04,05 12,20,40.124700.json @@ -4,5 +4,5 @@ "default_values": [50, 100, null, "glider"], "timesteps": null, "percentage": null, - "struct_mode": "fafaf" + "struct_mode": "glider" } diff --git a/params/poisson - 2019,04,05 14,49,36.424985.json b/params/poisson - 2019,04,05 14,49,36.424985.json deleted file mode 100644 index 37f42a6..0000000 --- a/params/poisson - 2019,04,05 14,49,36.424985.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "mode": "poisson", - "dimensions": 50, - "timesteps": 100000, - "default_values": [50, 10000, "jacobi", "point", 1, 1], - "poi_type": "jacobi", - "charge_type": "point", - "dx_value": 1, - "limit": 0.00001 -} diff --git a/params/poisson - 2019,04,05 16,24,04.260395.json b/params/poisson - 2019,04,05 16,24,04.260395.json deleted file mode 100644 index 246d8ef..0000000 --- a/params/poisson - 2019,04,05 16,24,04.260395.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "mode": "poisson", - "dimensions": 50, - "timesteps": 150, - "default_values": [50, 10000, "jacobi", "point", "charges", 1, 0.001], - "poi_type": "gauss", - "charge_type": "line", - "quantities": "magnetic", - "dx_value": 1, - "limit": 0.001 -} diff --git a/params/reaction - 2019,04,24 11,42,32.211440.json b/params/reaction - 2019,04,24 11,42,32.211440.json new file mode 100644 index 0000000..aede3fc --- /dev/null +++ b/params/reaction - 2019,04,24 11,42,32.211440.json @@ -0,0 +1,9 @@ +{ + "mode": "reaction", + "dimensions": 50, + "timesteps": 1000, + "default_values":[50, 10000, 0, 0, 0], + "k": 1, + "sigma": 0.1, + "dt": 0.1 +} diff --git a/templates/files/commands.txt b/templates/files/commands.txt new file mode 100644 index 0000000..cb7617a --- /dev/null +++ b/templates/files/commands.txt @@ -0,0 +1,6 @@ +--new-template : creates new template file +--new-simulation : creates new simulation and corresponding template file +--new-module : creates new module +--shortcut : jumps to module +--readme: opens the programme readme +--help-commands: displays command line call syntax (You Just Called It) diff --git a/templates/files/module.py b/templates/files/module.py new file mode 100644 index 0000000..1666c11 --- /dev/null +++ b/templates/files/module.py @@ -0,0 +1,6 @@ +import numpy as np +from tools.utils import UtilityBase, general_utils + +class {}(UtilityBase): + def __init__(self): + super().__init__() diff --git a/templates/files/params.json b/templates/files/params.json new file mode 100644 index 0000000..36af672 --- /dev/null +++ b/templates/files/params.json @@ -0,0 +1,6 @@ +{ + "mode": null, + "dimensions": null, + "timesteps": null, + "default_values": [] +} diff --git a/templates/files/sim.py b/templates/files/sim.py new file mode 100644 index 0000000..19abf59 --- /dev/null +++ b/templates/files/sim.py @@ -0,0 +1,35 @@ +import numpy as np +from tools.utils import sim_utils +from packages.controller import SimulationPlane + +class {}(SimulationPlane): + def __init__(self, dimensions, timesteps): + super().__init__(dimensions, timesteps) + + #override + def start_sim(self): + # override to add different simulation types visual or full + super().start_sim() + + #override + def create_figure(self): + super().create_figure() + self.im = self.axes.imshow(self.cells, interpolation = "nearest", animated = True) + self.fig.colorbar(self.im) + + #override + def create_cells(self): + """ + self.cells = np.random.normal( + size=(self.dimensions, self.dimensions)) # loc and scale for noise + self.cells = np.random.uniform( + size=self.dimensions, self.dimensions) # high or low + """ + pass + + #override + def anim_func(self, i): + yield self.im + + + diff --git a/templates/cahn.json b/templates/sims/cahn.json similarity index 100% rename from templates/cahn.json rename to templates/sims/cahn.json diff --git a/templates/glauber.json b/templates/sims/glauber.json similarity index 100% rename from templates/glauber.json rename to templates/sims/glauber.json diff --git a/templates/gol.json b/templates/sims/gol.json similarity index 100% rename from templates/gol.json rename to templates/sims/gol.json diff --git a/templates/kawasaki.json b/templates/sims/kawasaki.json similarity index 100% rename from templates/kawasaki.json rename to templates/sims/kawasaki.json diff --git a/templates/manifest.json b/templates/sims/manifest.json similarity index 100% rename from templates/manifest.json rename to templates/sims/manifest.json diff --git a/templates/poisson.json b/templates/sims/poisson.json similarity index 100% rename from templates/poisson.json rename to templates/sims/poisson.json diff --git a/templates/sims/reaction.json b/templates/sims/reaction.json new file mode 100644 index 0000000..081516a --- /dev/null +++ b/templates/sims/reaction.json @@ -0,0 +1,9 @@ +{ + "mode": "reaction", + "dimensions": null, + "timesteps": null, + "default_values":[50, 10000, 0, 0, 0], + "k": null, + "sigma": null, + "dt": null +} diff --git a/templates/sirs.json b/templates/sims/sirs.json similarity index 100% rename from templates/sirs.json rename to templates/sims/sirs.json diff --git a/tools/__init__.py b/tools/__init__.py index f5288e0..8bc633c 100644 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -1,3 +1,3 @@ from tools.utils import general_utils -__all__ = general_utils.get_py_files(general_utils.MODULEPATH) +__all__ = general_utils.get_py_files(general_utils.MODULE_PATH) diff --git a/tools/grapher.py b/tools/grapher.py index 22f1e2a..545c951 100644 --- a/tools/grapher.py +++ b/tools/grapher.py @@ -23,7 +23,6 @@ def setup(self): def create_figure(self): """Creates figure for plotting and subplotting""" self.figure = plt.figure() - plt.rcParams.update(general_utils.returnGraphConfigs("subplots")) def plot_data(self, file_name): """Plots the data based on simulations chosen""" diff --git a/tools/utils/general_utils.py b/tools/utils/general_utils.py index c82d7ba..16b73a2 100644 --- a/tools/utils/general_utils.py +++ b/tools/utils/general_utils.py @@ -5,12 +5,15 @@ import datetime import webbrowser -TEMPLATEPATH = str(pathlib.Path("templates")) -SAVEPATH = str(pathlib.Path("params")) -MODULEPATH = str(pathlib.Path("tools")) -SIMPATH = str(pathlib.Path("packages")) -DATAPATH = str(pathlib.Path("data")) -GRAPHSPATH = str(pathlib.Path("graphs")) +SIM_TEMPLATES = str(pathlib.Path("templates/sims")) +FILE_TEMPLATES = str(pathlib.Path("templates/files")) +SAVE_PATH = str(pathlib.Path("params")) +MODULE_PATH = str(pathlib.Path("tools")) +SIM_PATH = str(pathlib.Path("packages")) +DATA_PATH = str(pathlib.Path("data")) +GRAPHS_PATH = str(pathlib.Path("graphs")) + +# General Functions def pick_parameter(identifier, iterable = None): """Picks parameters based on list of options or integer""" @@ -29,30 +32,6 @@ def pick_parameter(identifier, iterable = None): break return iterable[chosen_option - 1] -def returnGraphConfigs(fig_call): - """Returns general figure configurations for matplotlib""" - anim_fig = { - "font.family": "Courier New", - "axes.titlesize": 22, - "axes.titlepad": 8.0, - "axes.labelsize": 15, - "axes.labelpad": 8.0, - "figure.autolayout": True, - } - subplot_fig = { - "font.family": "Courier New", - "figure.titlesize": 22, - "axes.titlesize": 18, - "axes.titlepad": 8.0, - "axes.labelsize": 15, - "axes.labelpad": 8.0, - } - if fig_call == "anim": - fig_params = anim_fig - elif fig_call == "subplots": - fig_params = subplot_fig - return (fig_params) - def list_options(iterable): """List options from a iterable with numbers""" for i, item in enumerate(iterable, 1): @@ -65,11 +44,14 @@ def get_directory_contents(dir_path): def join_path(dir_path, file_name): return os.path.join(dir_path, file_name) -def load_file(path): +def load_file(path, flag = False): """Load a file and gets it data""" with open(path, "r") as file_data: - data = file_data.readlines() - del data[0:2] + if flag == False: + data = file_data.readlines() + del data[0:2] + else: + data = file_data.read() return data def load_json_file(path): @@ -79,7 +61,7 @@ def load_json_file(path): def write_data(data, file_data, sim_info): """Write data from simulations to file""" data_file_name = "{} - {} - {}.txt".format(*file_data) - data_file_path = join_path(DATAPATH, data_file_name) + data_file_path = join_path(DATA_PATH, data_file_name) with open(data_file_path, "w") as data_file: data_file.write("{}\n".format(sim_info)) for line in data: @@ -87,22 +69,26 @@ def write_data(data, file_data, sim_info): print ("Data succesfully saved as {}".format(data_file_name)) def check_directories(): - if os.path.isdir(DATAPATH) == False: + if os.path.basename(os.getcwd()) != "SimSuite": + raise Exception("Please Run Programme From Base Directory") + if os.path.isdir(DATA_PATH) == False: os.mkdir("data") - if os.path.isdir(GRAPHSPATH) == False: + if os.path.isdir(GRAPHS_PATH) == False: os.mkdir("graphs") - if os.path.isdir(TEMPLATEPATH) == False: + if os.path.isdir(SIM_TEMPLATES) == False: os.mkdir("templates") - if os.path.isdir(SAVEPATH) == False: + if os.path.isdir(SAVE_PATH) == False: os.mkdir("params") +# Template Functions + def copy_template(name): try: file_name = "{}.json".format(name) new_file_name = "{} - {}.json".format( name, str(datetime.datetime.utcnow()).replace(":",",").replace("-",",")) - template_path = join_path(TEMPLATEPATH, file_name) - params_path = join_path(SAVEPATH, new_file_name) + template_path = join_path(SIM_TEMPLATES, file_name) + params_path = join_path(SAVE_PATH, new_file_name) with open(template_path, "r") as template_f: copy_data = template_f.read() @@ -118,49 +104,59 @@ def load_template(name): try: file_name = "{}.json".format(name) - file_path = join_path(TEMPLATEPATH, file_name) + file_path = join_path(SIM_TEMPLATES, file_name) with open(file_path, "r") as template_f: json_data = json.loads(template_f.read()) return json_data except FileNotFoundError: print("File Not Found {}".format(file_name)) +# Creation Functions + def create_simulation(sim_name): # file names class_file = "{}.py".format(sim_name.lower()) json_name = "{}.json".format(sim_name.lower()) # data for each file - class_template = "import numpy as np\nfrom packages.controller import SimulationPlane\nfrom tools.utils import utils\n\nclass {}(SimulationPlane):\n\tdef __init__(self, dimensions, timesteps):\n\t\tsuper().__init__(dimensions, timesteps)\n\n\t#override\n\tdef create_figure(self):\n\t\tsuper().create_figure()\n\n\t#override\n\tdef create_cells(self):\n\t\tpass\n\n\t#override\n\tdef anim_func(self, i):\n\t\tpass".format(sim_name.title()) - data_string = "\t\"mode\": \"{}\",\n\t\"dimensions\": \"null\",\n\t\"timesteps\": \"null\",\n\t\"default_values\":[]".format(sim_name) - data = "{{\n{}\n}}".format(data_string) + class_template = load_file( + join_path(FILE_TEMPLATES, "sim.py"), True).format(sim_name.title()) + + json_template = load_json_file(join_path(FILE_TEMPLATES, "params.json")) + + json_template["mode"] = sim_name # writing data to files - with open(os.path.join(TEMPLATEPATH, json_name), "w") as new_template: - new_template.write(data) + with open(join_path(SIM_TEMPLATES, json_name), "w") as new_template: + new_template.write(json.dumps(json_template, indent=4)) print ("New Template File {} Created".format(sim_name)) - with open(os.path.join(SIMPATH, class_file), "w") as new_sim_class: + with open(join_path(SIM_PATH, class_file), "w") as new_sim_class: new_sim_class.write(class_template) print ("New Class File {} Created".format(sim_name.title())) def create_module(name): - template_string = "import numpy as np\nfrom tools.utils import UtilityBase,utils\n\nclass {}(UtilityBase):\n\tdef __init__(self):\n\t\tsuper().__init__()".format(name.title()) + class_template = load_file( + join_path(FILE_TEMPLATES, "module.py"), True).format(name.title()) file_name = "{}.py".format(name) - with open(os.path.join(MODULEPATH, file_name), "w") as new_module: - new_module.write(template_string) + with open(os.path.join(MODULE_PATH, file_name), "w") as new_module: + new_module.write(class_template) + print ("New Module {} Created".format(name)) -def get_sim_modes(): - modes = [] - for files in os.listdir(TEMPLATEPATH): - if "manifest" not in files: - modes.append(files.replace(".json","")) - return modes +# Command Line Stuff + +def command_line_error(name): + print("Command Line Error: Not Enough Arguements Given for --{} call".format(name.replace("_", "-"))) + +def print_cl_commands(): + print(load_file(join_path(FILE_TEMPLATES, "commands.txt"), True)) + +# For Dynamic Packages def str_to_class(package, name): return getattr(sys.modules["{}.{}".format(package, name)], name.title()) @@ -172,13 +168,9 @@ def get_py_files(path): classes.append(files.replace(".py","")) return classes -def command_line_error(name): - print("Command Line Error: Not Enough Arguements Given for --{} call".format(name.replace("_", "-"))) - -def open_readme(): - print("Opening README in default browser") - webbrowser.open("README.html") - -def print_cl_commands(): - commands_str = "--new-template : creates new template file\n--new-simulation : creates new simulation and corresponding template file\n--new-module : creates new module\n--shortcut : jumps to module\n--readme: opens the programme readme\n--help-commands: displays command line call syntax (You Just Called It)" - print(commands_str) +def get_sim_modes(): + modes = [] + for files in os.listdir(SIM_TEMPLATES): + if "manifest" not in files: + modes.append(files.replace(".json", "")) + return modes diff --git a/tools/utils/parametiser.py b/tools/utils/parametiser.py index b4fd1b2..6c4576a 100644 --- a/tools/utils/parametiser.py +++ b/tools/utils/parametiser.py @@ -3,7 +3,7 @@ class Parametiser(object): # FIXME Not Dynamic, have to add sim info manually - manifest = general_utils.load_json_file(general_utils.join_path(general_utils.TEMPLATEPATH, "manifest.json")) + manifest = general_utils.load_json_file(general_utils.join_path(general_utils.SIM_TEMPLATES, "manifest.json")) params = {} sim_mode = None @@ -16,7 +16,7 @@ def __init__(self, modes): def load_template(self): print ("\nChoosing template file") - files = general_utils.get_directory_contents(general_utils.SAVEPATH) + files = general_utils.get_directory_contents(general_utils.SAVE_PATH) if len(files) == 0: print( "No template files present, use creator module to create file") @@ -25,7 +25,7 @@ def load_template(self): chosen_file = general_utils.pick_parameter("Template File", files) file_path = general_utils.join_path( - general_utils.SAVEPATH, chosen_file) + general_utils.SAVE_PATH, chosen_file) self.params = general_utils.load_json_file(file_path) @@ -37,7 +37,6 @@ def load_template(self): if self.flag != False: self.check_template() - # TODO add type checks to values def check_template(self): if len(self.params) != len(self.default_values): print ("Template Error: Number of default Values do not match the amount of modifiable parameters") diff --git a/tools/utils/parseArg.py b/tools/utils/parseArg.py index feeffc0..54aa26a 100644 --- a/tools/utils/parseArg.py +++ b/tools/utils/parseArg.py @@ -15,7 +15,6 @@ def intialiseCommands(self): ("--new-simulation", "new", self.new_simulation), ("--new-module", "new", self.new_module), ("--shortcut", None, self.shortcut), - ("--readme", "docs", general_utils.open_readme), ("--help-commands", "help", general_utils.print_cl_commands)] self.calls = [command[0] for command in self.commands] self.flags = [flag[1] for flag in self.commands] diff --git a/tools/utils/sim_utils.py b/tools/utils/sim_utils.py index 97b51bf..11137e3 100644 --- a/tools/utils/sim_utils.py +++ b/tools/utils/sim_utils.py @@ -128,61 +128,7 @@ def calculate_total_mag(cells): [0, 0, 1], [1, 1, 1] ] - ), - "pulsar": np.array( - [ - [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0, 0], - [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1], - [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1], - [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1], - [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0, 0], - [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0], - [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1], - [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1], - [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1], - [0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0, 0], - [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0], - ] - ), - "beacon": np.array( - [ - [1, 1, 0, 0], - [1, 1, 0, 0], - [0, 0, 1, 1], - [0, 0, 1, 1] - ] - ), - "gun": np.vstack( - [ - [0] * 24 + [1] + [0] * 11, - [0] * 22 + [1, 0, 1] + [0] * 11, - [0] * 12 + [1, 1] + [0] * 6 + [1, 1] + [0] * 12 + [1, 1], - [0] * 11 + [1, 0, 0, 0, 1] + [0] * 4 + [1, 1] + [0] * 12 + [1, 1], - [1, 1] + [0] * 8 + [1] + [0] * 5 + [1] + [0] * 3 + [1, 1] + [0] * 14, - [1, 1] + [0] * 8 + [1, 0, 0, 0, 1, 0, 1, 1] + [0] * 4 + [1, 0, 1] + [0] * 11, - [0] * 10 + [1] + [0] * 5 + [1] + [0] * 7 + [1] + [0] * 11, - [0] * 11 + [1, 0, 0, 0, 1] + [0] * 20, - [0] * 12 + [1, 1] + [0] * 22, - ] - ), - "pentadecon": np.array( - [ - [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], - [1, 1, 0, 1, 1, 1, 1, 0, 1, 1], - [0, 0, 1, 0, 0, 0, 0, 1, 0 ,0] - ] - ), - "heavyglider": np.array( - [ - [0, 0, 0, 1, 1, 0, 0], - [0, 1, 0, 0, 0, 0, 1], - [1, 0, 0, 0, 0, 0, 0], - [1, 0, 0, 0, 0, 0, 1], - [1, 1, 1, 1, 1, 1, 0] - ] - ) + ) } def return_gol_structures(struct_name):