-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from jameslawlor/chores/migrate-to-config-yaml
Chores/migrate to config yaml
- Loading branch information
Showing
10 changed files
with
119 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
ruff==0.3.4 | ||
numpy==1.26.4 | ||
matplotlib==3.8.3 | ||
pytest==8.0.2 | ||
pytest==8.0.2 | ||
PyYAML==6.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmap: "Oranges" | ||
plot_mode: "animate" | ||
canvas_size: 8 | ||
padding_size: 2 # expand in each direction by this amount of cells | ||
animation_interval: 1 | ||
save_animation: False | ||
frame_skip: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmap: "Oranges" | ||
plot_mode: "static" | ||
canvas_size: 8 | ||
padding_size: 2 # expand in each direction by this amount of cells |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
n_steps: 20000 | ||
ruleset: "classic" | ||
instructions: "RL" # "Classic" instructions format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
n_steps: 20000 | ||
ruleset: "stateful" # 'classic' or 'stateful' | ||
instructions: [ # triplet notation (write colour, turn instruction, next state) | ||
[(1, 'R', 0),(1, 'R', 1)], # one state per row, one colour per tuple | ||
[(0, 'N', 0),(0, 'N', 1)], | ||
] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
import argparse | ||
from pyturmite.constants import ( | ||
CANVAS_SIZE, | ||
N_STEPS, | ||
PLOT_MODE, | ||
RULESET, | ||
) | ||
import yaml | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--ant_config_path", required=True, type=str) | ||
parser.add_argument("--plotting_config_path", required=True, type=str) | ||
args = parser.parse_args() | ||
return args | ||
|
||
parser.add_argument("--n_steps", required=False, type=int, default=N_STEPS) | ||
|
||
parser.add_argument("--canvas_size", required=False, type=int, default=CANVAS_SIZE) | ||
def load_yaml_file_to_json(path): | ||
with open(path, "r") as stream: | ||
return yaml.safe_load(stream) | ||
|
||
parser.add_argument("--plot_mode", required=False, type=str, default=PLOT_MODE) | ||
|
||
parser.add_argument("--ruleset", required=False, type=str, default=RULESET) | ||
class Config: | ||
def __init__(self): | ||
input_args = parse_args() | ||
self.ant_config_path = input_args.ant_config_path | ||
self.plotting_config_path = input_args.plotting_config_path | ||
|
||
args = parser.parse_args() | ||
return args | ||
self.instructions = None | ||
self.ruleset = "" | ||
self.padding_size = 0 | ||
self.canvas_size = 0 | ||
self.cmap = "" | ||
self.plot_mode = "" | ||
self.n_steps = 0 | ||
self.animation_interval = 0 | ||
self.frame_skip = 0 | ||
self.save_animation = False | ||
|
||
def __str__(self): | ||
return str(vars(self)) | ||
|
||
def _set_attributes_from_dictionary(self, dictionary): | ||
for k, v in dictionary.items(): | ||
setattr(self, k, v) | ||
|
||
def _load_config_from_path(self, path): | ||
raw_config = load_yaml_file_to_json(path) | ||
self._set_attributes_from_dictionary(raw_config) | ||
|
||
def load(self): | ||
self._load_config_from_path(self.ant_config_path) | ||
self._load_config_from_path(self.plotting_config_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters