From 37a6325d7d0d3d09dbb0ef2005f1db3de0a7c1e8 Mon Sep 17 00:00:00 2001 From: Eli Date: Mon, 24 Dec 2018 00:25:12 -0800 Subject: [PATCH 01/33] Update Coord class & create Neighborhood class as groundwork for better symmetries --- CHANGELOG.md | 4 +- nutshell/segment_types/table/_classes.py | 114 ++++++++++-------- .../segment_types/table/_neighborhoods.py | 70 ++++++++++- nutshell/segment_types/table/_symutils.py | 24 ++++ nutshell/segment_types/table/table.py | 8 +- 5 files changed, 157 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14443c6..475a6d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,13 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)'s. -## [0.6.0] - In progress? +## [0.6.0] - In progress ### Planned - A complete overhaul of symmetries and neighborhoods such that: - Such transformations as reflection and rotation are handled from the *neighborhood* rather than the symmetry type - Nutshell, given the compass directions composing a neighborhood, automatically determines what standard transformations it can undergo - - Symmetry types simply have to call, for instance, neighborhood.rotate4() -- rather than themselves reordering the napkin + - ~~Symmetry types simply have to call, for instance, neighborhood.rotate4() -- rather than themselves reordering the napkin~~ - Symmetry types can be composed from within Nutshell without my having to define a new Python class for each basic combination of symmetries - Also, apgsearch-like symmetry notation...? diff --git a/nutshell/segment_types/table/_classes.py b/nutshell/segment_types/table/_classes.py index a5272a2..a2e7235 100644 --- a/nutshell/segment_types/table/_classes.py +++ b/nutshell/segment_types/table/_classes.py @@ -708,7 +708,7 @@ def __init__(self, tbl, initial_cdir, delay, resultant, *, context, symmetries=N self.ctx = context self.tbl = tbl self.initial_cdir = initial_cdir - self.orig = Coord.from_name(initial_cdir, tbl).inv + self.orig = Coord.from_name(initial_cdir).inv self.resultant = resultant self.symmetries = symmetries or tbl.symmetries self.stationary = False @@ -718,7 +718,7 @@ def __init__(self, tbl, initial_cdir, delay, resultant, *, context, symmetries=N f'Delayed auxiliaries (as in "{initial_cdir}+{delay}") are not supported as of yet' ) if isinstance(resultant, Mapping): - if resultant.cdir != '0' and not self.orig.toward(resultant.cdir).valid(): + if resultant.cdir != '0' and not self.orig.toward(resultant.cdir).valid_in(tbl.neighborhood): nbhd = tbl.directives['neighborhood'] raise CoordOutOfBounds( self.ctx, @@ -740,22 +740,23 @@ def __repr__(self): def _make_tr(self, tr, resultant): new_tr = [tr[self.initial_cdir], *[self.tbl.vars['any']]*self.tbl.trlen, resultant] orig = self.orig + nbhd = self.tbl.neighborhood # Adjacent cells to original cell (diagonal to current) with suppress(KeyError): - new_tr[orig.idx] = tr[0] + new_tr[orig.idx_in(nbhd)] = tr[0] with suppress(KeyError): - new_tr[orig.cw.idx] = tr[orig.cw.toward(self.initial_cdir).idx] + new_tr[orig.cw(1).idx_in(nbhd)] = tr[orig.cw(1).toward(self.initial_cdir).idx_in(nbhd)] with suppress(KeyError): - new_tr[orig.ccw.idx] = tr[orig.ccw.toward(self.initial_cdir).idx] + new_tr[orig.ccw(1).idx_in(nbhd)] = tr[orig.ccw(1).toward(self.initial_cdir).idx_in(nbhd)] # If we're orthogonal to orig, we have to account for the cells adjacent to us too if not orig.diagonal(): # In this case orig.cw(2).toward(self.initial_cdir) happens to be equivalent # to orig.cw(3), which is also shorter, but in the interest of remaining # consistent with the general technique I'll write it the longer way with suppress(KeyError): - new_tr[orig.cw(2).idx] = tr[orig.cw(2).toward(self.initial_cdir).idx] + new_tr[orig.cw(2).idx_in(nbhd)] = tr[orig.cw(2).toward(self.initial_cdir).idx_in(nbhd)] with suppress(KeyError): - new_tr[orig.ccw(2).idx] = tr[orig.ccw(2).toward(self.initial_cdir).idx] + new_tr[orig.ccw(2).idx_in(nbhd)] = tr[orig.ccw(2).toward(self.initial_cdir).idx_in(nbhd)] return new_tr def from_int(self, tr): @@ -768,7 +769,7 @@ def from_binding(self, tr): # if isinstance(within, ResolvedBinding): # raise Reshape(self.resultant.cdir) if isinstance(within, ResolvedBinding): - within.cdir = Coord.from_name(within.cdir, self.tbl).move(*self.orig).name + within.cdir = Coord.from_name(within.cdir).move(*self.orig).name return TransitionGroup.from_seq( self._make_tr(tr, within), self.tbl, context=self.ctx, symmetries=self.symmetries ).expand(tr) @@ -799,45 +800,54 @@ class Coord(tuple): '0': (0, 0), } _DIRMAP = dict(zip(_DIRS, range(8))) - _NAMES = {**{v: k for k, v in _OFFSETS.items()}, (0, 0): '0'} + _NAMES = {v: k for k, v in _OFFSETS.items()} - def __new__(cls, it, tbl=None): + def __new__(cls, it): return super().__new__(cls, it) - def __init__(self, tup, tbl=None): - self.tbl = tbl + def __init__(self, tup): self.tuple = tuple(super().__iter__()) - if not (-2 < self.x < 2 and -2 < self.y < 2): + if len(tup) != 2 or not (-2 < self.x < 2 and -2 < self.y < 2): raise CoordOutOfBoundsError(self) def __repr__(self): return f'Coord({super().__repr__()})' + def __eq__(self, other): + if isinstance(other, Coord): + return self.tuple == other.tuple + return NotImplemented + + def __hash__(self): + return super().__hash__() + + def __lt__(self, other): + return self.idx < other.idx + + def __le__(self, other): + return self < other or self == other + + def __gt__(self, other): + return self.idx > other.idx + + def __ge__(self, other): + return self > other or self == other + @classmethod - def from_name(cls, cdir, tbl=None): - return cls(cls._OFFSETS[cdir], tbl) + def from_name(cls, cdir): + return cls(cls._OFFSETS[cdir]) @property def name(self): return self._NAMES[self] - @property - def idx(self): - return self.tbl.neighborhood[self.name] - @property def inv(self): - return Coord((-self.x, -self.y), self.tbl) - - @property - def cw(self): - idx = 1 + self._DIRMAP[self.name] - return _MaybeCallableCW(self._OFFSETS[self._DIRS[idx % 8]], self.tbl) + return Coord((-self.x, -self.y)) @property - def ccw(self): - idx = self._DIRMAP[self.name] - return _MaybeCallableCCW(self._OFFSETS[self._DIRS[idx-1]], self.tbl) + def idx(self): + return self._DIRMAP[self.name] @property def x(self): @@ -847,8 +857,33 @@ def x(self): def y(self): return self[1] - def valid(self): - return self.center() or self.tbl and self.name in self.tbl.neighborhood + def idx_in(self, nbhd): + return nbhd[self.name] + + def valid_in(self, nbhd): + return self.center() or self.name in nbhd + + def cw_distance(self, other, nbhd=None): + """Returns n such that self.cw(n) == other""" + if nbhd is None: + return (8 - self.ccw_distance(other)) % 8 + return (len(nbhd) - self.ccw_distance(other, nbhd)) % len(nbhd) + + def ccw_distance(self, other, nbhd=None): + """Returns n such that self.ccw(n) == other""" + if nbhd is None: + return (self.idx - other.idx) % 8 + return (self.idx_in(nbhd) - other.idx_in(nbhd)) % len(nbhd) + + def cw(self, count, nbhd=None): + if nbhd is None: + return Coord(self._OFFSETS[self._DIRS[(count + self._DIRMAP[self.name]) % 8]]) + return Coord(self._OFFSETS[nbhd.cdir_at((nbhd[self.name] + count - 1) % len(nbhd) + 1)]) + + def ccw(self, count, nbhd=None): + if nbhd is None: + return Coord(self._OFFSETS[self._DIRS[self._DIRMAP[self.name] - count]]) + return Coord(self._OFFSETS[nbhd.cdir_at(nbhd[self.name] - count)]) def diagonal(self): return all(self) @@ -860,21 +895,4 @@ def toward(self, cd): return self.move(*self._OFFSETS[cd.upper()]) def move(self, x=0, y=0): - return Coord((x + self.x, y + self.y), self.tbl) - - -class _MaybeCallableCW(Coord): - """ - Allows Coord.cw.cw.cw.cw to be replaced by Coord.cw(4), and so on. - (The former will still work, however.) - """ - def __call__(self, num): - return Coord(self.cw(num-1) if num > 1 else self, self.tbl) - - -class _MaybeCallableCCW(Coord): - """ - Ditto above, but counterclockwise. - """ - def __call__(self, num): - return Coord(self.ccw(num-1) if num > 1 else self, self.tbl) + return Coord((x + self.x, y + self.y)) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index b1d6527..28a45d5 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -1,4 +1,5 @@ from itertools import takewhile +from ._classes import Coord NBHD_SETS = ( # for containment-checking @@ -23,26 +24,83 @@ def get_gollyizer(tbl, nbhd): tbl.directives['neighborhood'] = name if nbhd_set < s: return fill.__get__(ORDERED_NBHDS[name]) - return lambda tbl, napkin, _: reorder(ORDERED_NBHDS[name], tbl, napkin) + return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) raise ValueError('Invalid (non-Moore-subset) neighborhood {nbhd_set}}') def reorder(ordered_nbhd, tbl, napkin): - nbhd = tbl.neighborhood.inv - d = {nbhd[k]: v for k, v in enumerate(napkin, 1)} + cdir_at = tbl.neighborhood.cdir_at + d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} return [d[cdir] for cdir in ordered_nbhd] def fill(ordered_nbhd, tbl, napkin, anys): # anys == usages of `any` if isinstance(anys, int): anys = set(range(anys)) - nbhd = tbl.neighborhood.inv - d = {nbhd[k]: v for k, v in enumerate(napkin, 1)} + cdir_at = tbl.neighborhood.cdir_at + d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} available_tags = [i for i in range(10) if i not in anys] # (ew, but grabbing VarName object) tbl.vars.inv[tbl.vars['any']].update_rep( - max(anys) + len(ordered_nbhd) - len(nbhd) - sum(takewhile(max(anys).__gt__, available_tags)) + max(anys) + len(ordered_nbhd) - len(tbl.neighborhood) - sum(takewhile(max(anys).__gt__, available_tags)) ) tagged_names = (f'any.{i}' for i in available_tags) # `or` because this needs lazy evaluation return [d.get(cdir) or next(tagged_names) for cdir in ordered_nbhd] + + +class Neighborhood: + MOORE = dict(zip(ORDERED_NBHDS['Moore'], range(8))) + + def __init__(self, cdirs): + self.cdirs = tuple(cdirs) + self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) + self._inv = dict(enumerate(cdirs, 1)) + self.idxes = {v: k for k, v in self._inv.items()} + self.symmetrical = all(c.inv.name in self for c in self.coord_cdirs) + + def __contains__(self, item): + return item in self.idxes + + def __getitem__(self, item): + if isinstance(item, slice): + # old-'inv of bidict'-style syntax, obj[:item] + return self.cdir_at(item.stop) + return self.idxes[item] + + def __iter__(self): + yield from self.cdirs + + def __len__(self): + return len(self.cdirs) + + def cdir_at(self, idx): + if idx < 1: # like negative access on python sequences + return self._inv[len(self) + idx] + return self._inv[idx] + + def gollyizer_for(self, tbl): + return get_gollyizer(tbl, self.cdirs) + + def reflect_across(self, a, b=None): + if b is None: + b = a + if a != b and a.cw(1) != b: + raise ValueError('Endpoint compass directions of a line of reflection must be adjacent and given in clockwise order') + d = {} + try: + for cdir in self.coord_cdirs: + d[cdir.name] = a.cw(b.ccw_distance(cdir, self), self).name + except KeyError as e: + raise ValueError(f'Neighborhood does not contain {e}') + if set(d) != set(d.values()): + raise ValueError('Neighborhood is asymmetrical across the requested line of reflection') + r = {cdir: self[orig_cdir] for orig_cdir, cdir in d.items()} + return Neighborhood(sorted(r, key=r.get)) + + def rotations_by(self, amt): + if len(self) % amt: + raise ValueError(f'Neighborhood cannot be rotated evenly by {amt}') + if not self.symmetrical: + raise ValueError('Neighborhood is asymmetrical, cannot be rotated except by 1') + return [Neighborhood(self.cdirs[offset:] + self.cdirs[:offset]) for offset in range(0, len(self), len(self) // amt)] diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 0cbac7b..2a224c2 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,6 +1,7 @@ from importlib import import_module from nutshell.common import symmetries as ext_symmetries +from ._classes import Coord from . import _napkins as napkins NAMES = napkins.NAMES.copy() @@ -58,3 +59,26 @@ def get_sym_type(sym): module = ext_symmetries if name == 'nutshell' else import_module(name.lstrip('_')) NAMES[sym] = getattr(module, clsname) return NAMES[sym] + + +def reflect(nbhd, endpoint): + endpoints = (endpoint, endpoint) + if '+' in endpoint: + endpoints = endpoint.split('+') + first, second = map(Coord.from_name, endpoints) + symmetries = (nbhd.cdirs, nbhd.reflect_across(first, second).cdirs) + # TODO: inherit from napkin + return type(f'ReflectFrom{first}{second}', (object,), { + 'expanded': property(lambda self: symmetries), + }) + + +def rotate(nbhd, n): + symmetries = (nbhd.cdirs, *[i.cdirs for i in nbhd.rotations_by(int(n))]) + return type(f'RotateBy{n}', (object,), { + 'expanded': property(lambda self: symmetries), + }) + + +def permute(nbhd, cdirs): + ... # TODO diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index d61cf8b..3549efd 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -32,13 +32,7 @@ class Bidict(bidict.bidict): class TableSegment: - CARDINALS = generate_cardinals({ - 'oneDimensional': ('W', 'E'), - 'vonNeumann': ('N', 'E', 'S', 'W'), - 'hexagonal': ('N', 'E', 'SE', 'S', 'W', 'NW'), - 'Moore': ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'), - }) - TRLENS = {k: len(v) for k, v in CARDINALS.items()} + CARDINALS = generate_cardinals(nbhoods.ORDERED_NBHDS) def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): # parser (lexer?) dies if there are blank lines right at the start From bef2f59f11df99f08ac05ec4587bf0998b812358 Mon Sep 17 00:00:00 2001 From: Eli Date: Mon, 24 Dec 2018 11:59:18 -0800 Subject: [PATCH 02/33] Update Neighborhood class to fix reflection --- .../segment_types/table/_neighborhoods.py | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 28a45d5..aff0596 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -50,13 +50,12 @@ def fill(ordered_nbhd, tbl, napkin, anys): # anys == usages of `any` class Neighborhood: - MOORE = dict(zip(ORDERED_NBHDS['Moore'], range(8))) - def __init__(self, cdirs): self.cdirs = tuple(cdirs) self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) self._inv = dict(enumerate(cdirs, 1)) self.idxes = {v: k for k, v in self._inv.items()} + self.get = self.idxes.get self.symmetrical = all(c.inv.name in self for c in self.coord_cdirs) def __contains__(self, item): @@ -74,6 +73,17 @@ def __iter__(self): def __len__(self): return len(self.cdirs) + def __repr__(self): + return f'Neighborhood({self.cdirs!r})' + + def __str__(self): + blank = '.' + + return '\n'.join( + ' '.join(str(self.get(cdir, blank)) for cdir in row) + for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE')) + ) + def cdir_at(self, idx): if idx < 1: # like negative access on python sequences return self._inv[len(self) + idx] @@ -82,19 +92,29 @@ def cdir_at(self, idx): def gollyizer_for(self, tbl): return get_gollyizer(tbl, self.cdirs) - def reflect_across(self, a, b=None): - if b is None: - b = a + def reflect_across(self, endpoint): + a, b = endpoint + if isinstance(a, str): + a = Coord.from_name(a) + if isinstance(b, str): + b = Coord.from_name(b) if a != b and a.cw(1) != b: raise ValueError('Endpoint compass directions of a line of reflection must be adjacent and given in clockwise order') + to_check = [cdir for cdir in self.coord_cdirs if cdir not in {a, b, a.inv, b.inv}] + if len(to_check) % 2 or any(c.inv.name not in self for c in to_check): + raise ValueError('Neighborhood is asymmetrical across the requested line of reflection') + if a == b: + # i think the naive approach is the only way to go :( + while a.name not in self: + a = a.ccw(1) + while b.name not in self: + b = b.cw(1) d = {} try: for cdir in self.coord_cdirs: d[cdir.name] = a.cw(b.ccw_distance(cdir, self), self).name except KeyError as e: raise ValueError(f'Neighborhood does not contain {e}') - if set(d) != set(d.values()): - raise ValueError('Neighborhood is asymmetrical across the requested line of reflection') r = {cdir: self[orig_cdir] for orig_cdir, cdir in d.items()} return Neighborhood(sorted(r, key=r.get)) From 0b348126697d7caff52fae59ef4b6bb70f8f6da8 Mon Sep 17 00:00:00 2001 From: Eli Date: Mon, 24 Dec 2018 14:16:48 -0800 Subject: [PATCH 03/33] Add neighborhood->symmetry, add permutation & symmetry composition --- .../segment_types/table/_neighborhoods.py | 27 +++++++++----- nutshell/segment_types/table/_symutils.py | 35 ++++++++++++------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index aff0596..2d22dde 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -1,4 +1,4 @@ -from itertools import takewhile +from itertools import takewhile, permutations from ._classes import Coord NBHD_SETS = ( @@ -77,12 +77,10 @@ def __repr__(self): return f'Neighborhood({self.cdirs!r})' def __str__(self): - blank = '.' - - return '\n'.join( - ' '.join(str(self.get(cdir, blank)) for cdir in row) - for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE')) - ) + return '\n'.join(map(' '.join, self.to_list())) + + def to_list(self, blank='.'): + return [[self.get(cdir, blank) for cdir in row] for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE'))] def cdir_at(self, idx): if idx < 1: # like negative access on python sequences @@ -93,13 +91,15 @@ def gollyizer_for(self, tbl): return get_gollyizer(tbl, self.cdirs) def reflect_across(self, endpoint): + if not isinstance(endpoint, tuple): + raise TypeError('Endpoint of line of reflection should be given as tuple of compass directions') a, b = endpoint if isinstance(a, str): a = Coord.from_name(a) if isinstance(b, str): b = Coord.from_name(b) if a != b and a.cw(1) != b: - raise ValueError('Endpoint compass directions of a line of reflection must be adjacent and given in clockwise order') + raise ValueError('Endpoint compass directions of a line of reflection must be both adjacent and given in clockwise order') to_check = [cdir for cdir in self.coord_cdirs if cdir not in {a, b, a.inv, b.inv}] if len(to_check) % 2 or any(c.inv.name not in self for c in to_check): raise ValueError('Neighborhood is asymmetrical across the requested line of reflection') @@ -118,9 +118,18 @@ def reflect_across(self, endpoint): r = {cdir: self[orig_cdir] for orig_cdir, cdir in d.items()} return Neighborhood(sorted(r, key=r.get)) + def rotate_by(self, offset): + return Neighborhood(self.cdirs[offset:] + self.cdirs[:offset]) + def rotations_by(self, amt): if len(self) % amt: raise ValueError(f'Neighborhood cannot be rotated evenly by {amt}') if not self.symmetrical: raise ValueError('Neighborhood is asymmetrical, cannot be rotated except by 1') - return [Neighborhood(self.cdirs[offset:] + self.cdirs[:offset]) for offset in range(0, len(self), len(self) // amt)] + return [self.rotate_by(offset) for offset in range(0, len(self), len(self) // amt)] + + def permutations(self, cdirs=None): + if cdirs is None: + cdirs = self.cdirs + check = set(cdirs) + return [Neighborhood(next(permute) if c in check else c for c in self) for permute in map(iter, permutations(cdirs))] diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 2a224c2..8c6a16b 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -61,24 +61,33 @@ def get_sym_type(sym): return NAMES[sym] -def reflect(nbhd, endpoint): - endpoints = (endpoint, endpoint) - if '+' in endpoint: - endpoints = endpoint.split('+') - first, second = map(Coord.from_name, endpoints) - symmetries = (nbhd.cdirs, nbhd.reflect_across(first, second).cdirs) +def compose(symmetries): + expanded = sorted([t for s in symmetries for t in s.expanded]) + names = [s.__name__ for s in symmetries] + return type('+'.join(names), (object,), { + 'expanded': property(lambda self: expanded) + }) + + +def reflect(nbhd, first, second=None): + first = Coord.from_name(first) + second = first if second is None else Coord.from_name(second) + expanded = sorted([nbhd.cdirs, nbhd.reflect_across((first, second)).cdirs]) # TODO: inherit from napkin - return type(f'ReflectFrom{first}{second}', (object,), { - 'expanded': property(lambda self: symmetries), + return type(f'Reflect_{first}_{second}', (object,), { + 'expanded': property(lambda self: expanded), }) def rotate(nbhd, n): - symmetries = (nbhd.cdirs, *[i.cdirs for i in nbhd.rotations_by(int(n))]) - return type(f'RotateBy{n}', (object,), { - 'expanded': property(lambda self: symmetries), + expanded = sorted([i.cdirs for i in nbhd.rotations_by(int(n))]) + return type(f'Rotate_{n}', (object,), { + 'expanded': property(lambda self: expanded), }) -def permute(nbhd, cdirs): - ... # TODO +def permute(nbhd, cdirs=None): + expanded = sorted(nbhd.permutations(cdirs)) + return type(f"Permute_{'_'.join(cdirs)}", (object,), { + 'expanded': property(lambda self: expanded) + }) From c3f5eb605f83fb8117cb36e571eb94dc788a4dbd Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 25 Dec 2018 01:06:46 -0800 Subject: [PATCH 04/33] Add borken impl of symmetries & symmetry-string-parsing --- nutshell/segment_types/table/_classes.py | 13 ++- nutshell/segment_types/table/_napkins.py | 2 +- .../segment_types/table/_neighborhoods.py | 75 ++++++++------- nutshell/segment_types/table/_symutils.py | 93 +++++++++++++------ nutshell/segment_types/table/_transformer.py | 8 +- .../table/inline_rulestring/default_rs.py | 5 +- nutshell/segment_types/table/table.py | 9 +- 7 files changed, 119 insertions(+), 86 deletions(-) diff --git a/nutshell/segment_types/table/_classes.py b/nutshell/segment_types/table/_classes.py index a2e7235..199a309 100644 --- a/nutshell/segment_types/table/_classes.py +++ b/nutshell/segment_types/table/_classes.py @@ -3,7 +3,6 @@ from functools import partial from itertools import count, cycle -from . import _neighborhoods as nbhds from nutshell.common.utils import random, distinct from nutshell.common.errors import * from .lark_assets.exceptions import * @@ -63,8 +62,8 @@ def __init__(self, tbl, initial, napkin, resultant, *, context, extra=None, symm self.extra = extra self.tbl = tbl self.symmetries = symmetries or tbl.symmetries - nbhd = tbl.neighborhood.inv - self._tr_dict = {'0': initial, **{nbhd[k]: v for k, v in napkin.items()}} + cdir_at = tbl.neighborhood.cdir_at + self._tr_dict = {'0': initial, **{cdir_at(k): v for k, v in napkin.items()}} self._tr = [initial, *map(napkin.get, range(1, 1+len(napkin))), resultant] self._n = napkin self._expandeds = {} @@ -226,8 +225,8 @@ def __init__(self, tr, tbl, *, context, extra=None, symmetries=None): f"got {resultant.untether()}, a statelist of length {len(resultant)}" ) self.resultant = resultant - nbhd = tbl.neighborhood.inv - self._tr_dict = {'0': self.initial, **{nbhd[k]: v for k, v in enumerate(self.napkin, 1)}} + cdir_at = tbl.neighborhood.cdir_at + self._tr_dict = {'0': self.initial, **{cdir_at(k): v for k, v in enumerate(self.napkin, 1)}} self.symmetries = symmetries or tbl.symmetries self.tbl = tbl @@ -878,12 +877,12 @@ def ccw_distance(self, other, nbhd=None): def cw(self, count, nbhd=None): if nbhd is None: return Coord(self._OFFSETS[self._DIRS[(count + self._DIRMAP[self.name]) % 8]]) - return Coord(self._OFFSETS[nbhd.cdir_at((nbhd[self.name] + count - 1) % len(nbhd) + 1)]) + return Coord(self._OFFSETS[nbhd.cdir_at((self.idx_in(nbhd) + count - 1) % len(nbhd) + 1)]) def ccw(self, count, nbhd=None): if nbhd is None: return Coord(self._OFFSETS[self._DIRS[self._DIRMAP[self.name] - count]]) - return Coord(self._OFFSETS[nbhd.cdir_at(nbhd[self.name] - count)]) + return Coord(self._OFFSETS[nbhd.cdir_at(self.idx_in(nbhd) - count)]) def diagonal(self): return all(self) diff --git a/nutshell/segment_types/table/_napkins.py b/nutshell/segment_types/table/_napkins.py index 407c616..24551a4 100644 --- a/nutshell/segment_types/table/_napkins.py +++ b/nutshell/segment_types/table/_napkins.py @@ -201,7 +201,7 @@ def clear(cls): @staticmethod def special(values, length): """ - Given a shorthand permutationally-symmetric transition: + Given a shorthand permutationally-symmetrical transition: length=8 (Moore neighborhood) ------- 1, 0 diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 2d22dde..3725a0a 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -17,54 +17,18 @@ } -def get_gollyizer(tbl, nbhd): - nbhd_set = set(nbhd) - for s, name in NBHD_SETS: - if nbhd_set <= s: - tbl.directives['neighborhood'] = name - if nbhd_set < s: - return fill.__get__(ORDERED_NBHDS[name]) - return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) - raise ValueError('Invalid (non-Moore-subset) neighborhood {nbhd_set}}') - - -def reorder(ordered_nbhd, tbl, napkin): - cdir_at = tbl.neighborhood.cdir_at - d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} - return [d[cdir] for cdir in ordered_nbhd] - - -def fill(ordered_nbhd, tbl, napkin, anys): # anys == usages of `any` - if isinstance(anys, int): - anys = set(range(anys)) - cdir_at = tbl.neighborhood.cdir_at - d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} - available_tags = [i for i in range(10) if i not in anys] - # (ew, but grabbing VarName object) - tbl.vars.inv[tbl.vars['any']].update_rep( - max(anys) + len(ordered_nbhd) - len(tbl.neighborhood) - sum(takewhile(max(anys).__gt__, available_tags)) - ) - tagged_names = (f'any.{i}' for i in available_tags) - # `or` because this needs lazy evaluation - return [d.get(cdir) or next(tagged_names) for cdir in ordered_nbhd] - - class Neighborhood: def __init__(self, cdirs): self.cdirs = tuple(cdirs) self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) self._inv = dict(enumerate(cdirs, 1)) self.idxes = {v: k for k, v in self._inv.items()} - self.get = self.idxes.get self.symmetrical = all(c.inv.name in self for c in self.coord_cdirs) def __contains__(self, item): return item in self.idxes def __getitem__(self, item): - if isinstance(item, slice): - # old-'inv of bidict'-style syntax, obj[:item] - return self.cdir_at(item.stop) return self.idxes[item] def __iter__(self): @@ -79,6 +43,9 @@ def __repr__(self): def __str__(self): return '\n'.join(map(' '.join, self.to_list())) + def get(self, item, default=None): + return self.idxes.get(item, default) + def to_list(self, blank='.'): return [[self.get(cdir, blank) for cdir in row] for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE'))] @@ -131,5 +98,37 @@ def rotations_by(self, amt): def permutations(self, cdirs=None): if cdirs is None: cdirs = self.cdirs - check = set(cdirs) - return [Neighborhood(next(permute) if c in check else c for c in self) for permute in map(iter, permutations(cdirs))] + permuted_cdirs = set(cdirs) + return [Neighborhood(next(permute) if c in permuted_cdirs else c for c in self) for permute in map(iter, permutations(cdirs))] + + +def get_gollyizer(tbl, nbhd): + nbhd_set = set(nbhd) + for s, name in NBHD_SETS: + if nbhd_set <= s: + tbl.directives['neighborhood'] = name + if nbhd_set < s: + return fill.__get__(ORDERED_NBHDS[name]) + return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) + raise ValueError('Invalid (non-Moore-subset) neighborhood {nbhd_set}}') + + +def reorder(ordered_nbhd, tbl, napkin): + cdir_at = tbl.neighborhood.cdir_at + d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} + return [d[cdir] for cdir in ordered_nbhd] + + +def fill(ordered_nbhd, tbl, napkin, anys): # anys == usages of `any` + if isinstance(anys, int): + anys = set(range(anys)) + cdir_at = tbl.neighborhood.cdir_at + d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} + available_tags = [i for i in range(10) if i not in anys] + # (ew, but grabbing VarName object) + tbl.vars.inv[tbl.vars['any']].update_rep( + max(anys) + len(ordered_nbhd) - len(tbl.neighborhood) - sum(takewhile(max(anys).__gt__, available_tags)) + ) + tagged_names = (f'any.{i}' for i in available_tags) + # `or` because this needs lazy evaluation + return [d.get(cdir) or next(tagged_names) for cdir in ordered_nbhd] diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 8c6a16b..b88e1e1 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,10 +1,23 @@ from importlib import import_module -from nutshell.common import symmetries as ext_symmetries +from nutshell.common import symmetries as ext_symmetries, utils from ._classes import Coord from . import _napkins as napkins -NAMES = napkins.NAMES.copy() + +PRESETS = { + 'rotate8reflect': lambda nbhd: compose(rotate(nbhd, 8), reflect_multiple(nbhd, 'W', 'NW', 'N', 'NE')), + 'rotate8': lambda nbhd: rotate(nbhd, 8), + 'rotate4reflect': lambda nbhd: compose(rotate(nbhd, 4), reflect_multiple(nbhd, 'W', 'N')), + 'rotate4': lambda nbhd: rotate(nbhd, 4), + 'reflect_horizontal': lambda nbhd: reflect(nbhd, 'W'), + 'reflect_vertical': lambda nbhd: reflect(nbhd, 'N'), + 'none': lambda nbhd: none(nbhd), + #### + 'permute': lambda nbhd, *cdirs: permute(nbhd, cdirs), + 'reflect': lambda nbhd, *endpoint: reflect(nbhd, *endpoint), + 'rotate': lambda nbhd, amt: rotate(nbhd, int(amt)), +} def find_min_sym_type(symmetries, tr_len): @@ -51,43 +64,67 @@ def find_min_sym_type(symmetries, tr_len): ) -def get_sym_type(sym): - if sym not in NAMES: - if '.' not in sym: - raise ImportError(f'No symmetry type {sym!r} found') - name, clsname = sym.rsplit('.', 1) - module = ext_symmetries if name == 'nutshell' else import_module(name.lstrip('_')) - NAMES[sym] = getattr(module, clsname) - return NAMES[sym] +def get_sym_type(nbhd, string): + all_syms = [] + current = [] + for token in utils.multisplit(string, (None, *'(),_')): + if token in PRESETS: + if current: + all_syms.append(current) + current = [] + current.append(token) + all_syms.append(current) + resultant_sym = None + for name, *args in all_syms: + cur_sym = PRESETS[name](nbhd, *args) + resultant_sym = cur_sym if resultant_sym is None else compose(resultant_sym, cur_sym) + return resultant_sym +# get_sym_type(Neighborhood(('N', 'NE', 'E', 'S', 'SW', 'W')), 'rotate(2) reflect(N, NE))').expanded +# for example -def compose(symmetries): - expanded = sorted([t for s in symmetries for t in s.expanded]) - names = [s.__name__ for s in symmetries] - return type('+'.join(names), (object,), { - 'expanded': property(lambda self: expanded) +def _new_sym_type(name, expanded): + return type(name, (list,), { + 'expanded': expanded }) +def compose(*symmetries): + print([i.expanded for i in symmetries]) + return _new_sym_type( + '+'.join([s.__name__ for s in symmetries]), + sorted({t for s in symmetries for t in s.expanded}) + ) + + +def reflect_multiple(nbhd, *coords): + return compose(reflect(nbhd, c) if isinstance(c, str) else reflect(nbhd, *c) for c in coords) + + def reflect(nbhd, first, second=None): first = Coord.from_name(first) second = first if second is None else Coord.from_name(second) - expanded = sorted([nbhd.cdirs, nbhd.reflect_across((first, second)).cdirs]) - # TODO: inherit from napkin - return type(f'Reflect_{first}_{second}', (object,), { - 'expanded': property(lambda self: expanded), - }) + return _new_sym_type( + f'Reflect_{first}_{second}', + sorted([nbhd.cdirs, nbhd.reflect_across((first, second)).cdirs]) + ) def rotate(nbhd, n): - expanded = sorted([i.cdirs for i in nbhd.rotations_by(int(n))]) - return type(f'Rotate_{n}', (object,), { - 'expanded': property(lambda self: expanded), - }) + return _new_sym_type( + f'Rotate_{n}', + sorted([i.cdirs for i in nbhd.rotations_by(int(n))]) + ) def permute(nbhd, cdirs=None): - expanded = sorted(nbhd.permutations(cdirs)) - return type(f"Permute_{'_'.join(cdirs)}", (object,), { - 'expanded': property(lambda self: expanded) - }) + return _new_sym_type( + f"Permute_{'_'.join(cdirs)}", + sorted(nbhd.permutations(cdirs or None)) + ) + +def none(nbhd, cdirs=None): + return _new_sym_type( + f'NoSymmetry', + [nbhd.cdirs] + ) diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segment_types/table/_transformer.py index 5751bec..596ab77 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segment_types/table/_transformer.py @@ -250,7 +250,7 @@ def main(self, children, meta): raise SyntaxErr( fix(first.meta), 'Out-of-sequence compass direction ' - f'(expected {self._tbl.neighborhood.inv[idx] + (" or further" if all_cdir else "")}, got {first.children[0]})' + f'(expected {self._tbl.neighborhood.cdir_at(idx) + (" or further" if all_cdir else "")}, got {first.children[0]})' ) pure_idx += abs(cdir - idx) idx = cdir @@ -277,11 +277,11 @@ def main(self, children, meta): if idx == 1: idx = offset_initial = crange[0] else: - nbhd = self._tbl.neighborhood.inv + cdir_at = tbl.neighborhood.cdir_at raise SyntaxErr( (first.meta.line, first.meta.column, len(a) + first.meta.column), 'Out-of-sequence compass direction ' - f'(expected {nbhd[idx]}, got {nbhd[crange[0]]})' + f'(expected {cdir_at(idx)}, got {cdir_at(crange[0])})' ) rest, = rest @@ -310,7 +310,7 @@ def main(self, children, meta): pure_idx += 1 if all_cdir: napkin.update(dict.fromkeys( - [idx for idx in self._tbl.neighborhood.inv if idx not in napkin], + [idx for idx in range(1, 1+len(self._tbl.neighborhood)) if idx not in napkin], self.vars['any'] )) if len(napkin) != self._tbl.trlen: diff --git a/nutshell/segment_types/table/inline_rulestring/default_rs.py b/nutshell/segment_types/table/inline_rulestring/default_rs.py index 72ae388..d9a2606 100644 --- a/nutshell/segment_types/table/inline_rulestring/default_rs.py +++ b/nutshell/segment_types/table/inline_rulestring/default_rs.py @@ -6,8 +6,6 @@ from . import hensel from .. import _symutils as symutils -ROTATE_4_REFLECT = symutils.get_sym_type('rotate4reflect') -PERMUTE = symutils.get_sym_type('permute') FOUR_NEIGHBOR = { 'c': 'e', 'e': 'c', @@ -40,6 +38,7 @@ def standard(meta, initial, fg, bg, resultant, rulestring, variables, table): if r4r_nbhds: table.add_sym_type('rotate4reflect') + r4r = symutils.get_sym_type(table.neighborhood, 'rotate4reflect') get_fg, get_bg = _get_getter(table, fg, 'FG'), _get_getter(table, bg, 'BG') get_initial, get_resultant = _get_getter(table, initial, None), _get_getter(table, resultant, None) @@ -57,7 +56,7 @@ def standard(meta, initial, fg, bg, resultant, rulestring, variables, table): }, get_resultant(nb_count, letter, meta), context=meta, extra=next(counter), - symmetries=ROTATE_4_REFLECT + symmetries=r4r ) for nb_count, letters in r4r_nbhds.items() for letter in letters diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index 3549efd..c90c87f 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -22,8 +22,7 @@ def generate_cardinals(d): - """{'name': ('N', 'E', ...)} >>> {'name': {'N' :: 1, 'E' :: 2, ...}}""" - return {k: bidict.bidict(enumerate(v, 1)).inv for k, v in d.items()} + return {k: nbhoods.Neighborhood(v) for k, v in d.items()} class Bidict(bidict.bidict): @@ -165,8 +164,8 @@ def neighborhood(self, val): nbhd = val.split(',') if len(nbhd) != len(set(nbhd)): raise ValueError('Duplicate compass directions in neighborhood') - self._nbhd = bidict.bidict(enumerate(nbhd, 1)).inv - self.gollyize_nbhd = nbhoods.get_gollyizer(self, nbhd) + self._nbhd = nbhoods.Neighborhood(nbhd) + self.gollyize_nbhd = self._nbhd.gollyizer_for(self) elif val in self.CARDINALS: self._nbhd = self.CARDINALS[val] else: @@ -181,7 +180,7 @@ def trlen(self): @property def symmetries(self): - return symutils.get_sym_type(self.directives['symmetries']) + return symutils.get_sym_type(self.neighborhood, self.directives['symmetries']) @property def n_states(self): From e8ecf8883130df502939e5b906a95394f53cb036 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 25 Dec 2018 01:10:45 -0800 Subject: [PATCH 05/33] Small oversights (str() in Neighborhood.__str__(), remove debug print) --- nutshell/segment_types/table/_neighborhoods.py | 2 +- nutshell/segment_types/table/_symutils.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 3725a0a..d9a496b 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -47,7 +47,7 @@ def get(self, item, default=None): return self.idxes.get(item, default) def to_list(self, blank='.'): - return [[self.get(cdir, blank) for cdir in row] for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE'))] + return [[str(self.get(cdir, blank)) for cdir in row] for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE'))] def cdir_at(self, idx): if idx < 1: # like negative access on python sequences diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index b88e1e1..ece24ab 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -90,7 +90,6 @@ def _new_sym_type(name, expanded): def compose(*symmetries): - print([i.expanded for i in symmetries]) return _new_sym_type( '+'.join([s.__name__ for s in symmetries]), sorted({t for s in symmetries for t in s.expanded}) From 4c7a703b2619aa054c614a7678c86d322410a4f0 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 25 Dec 2018 22:15:34 -0800 Subject: [PATCH 06/33] Working symmetry composition & none-expansion --- .../segment_types/table/_neighborhoods.py | 3 + nutshell/segment_types/table/_symutils.py | 173 +++++++++--------- 2 files changed, 93 insertions(+), 83 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index d9a496b..9abf1db 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -85,6 +85,9 @@ def reflect_across(self, endpoint): r = {cdir: self[orig_cdir] for orig_cdir, cdir in d.items()} return Neighborhood(sorted(r, key=r.get)) + def reflections_across(self, endpoint): + return (self, self.reflect_across(endpoint)) + def rotate_by(self, offset): return Neighborhood(self.cdirs[offset:] + self.cdirs[:offset]) diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index ece24ab..2f3dd2d 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,3 +1,4 @@ +from functools import reduce from importlib import import_module from nutshell.common import symmetries as ext_symmetries, utils @@ -6,68 +7,82 @@ PRESETS = { - 'rotate8reflect': lambda nbhd: compose(rotate(nbhd, 8), reflect_multiple(nbhd, 'W', 'NW', 'N', 'NE')), - 'rotate8': lambda nbhd: rotate(nbhd, 8), - 'rotate4reflect': lambda nbhd: compose(rotate(nbhd, 4), reflect_multiple(nbhd, 'W', 'N')), - 'rotate4': lambda nbhd: rotate(nbhd, 4), - 'reflect_horizontal': lambda nbhd: reflect(nbhd, 'W'), - 'reflect_vertical': lambda nbhd: reflect(nbhd, 'N'), - 'none': lambda nbhd: none(nbhd), + 'rotate8reflect': lambda *_: compose(rotate(8), reflect('W')), + 'rotate8': lambda *_: rotate(8), + 'rotate4reflect': lambda *_: compose(rotate(4), reflect('W')), + 'rotate4': lambda *_: rotate(4), + 'reflect_horizontal': lambda *_: reflect('W'), + 'reflect_vertical': lambda *_: reflect('N'), + 'none': lambda *_: lambda nbhd: _new_sym_type(nbhd, 'NoSymmetry', _none), #### - 'permute': lambda nbhd, *cdirs: permute(nbhd, cdirs), - 'reflect': lambda nbhd, *endpoint: reflect(nbhd, *endpoint), - 'rotate': lambda nbhd, amt: rotate(nbhd, int(amt)), + 'permute': lambda *args: permute(*args), + 'reflect': lambda *args: reflect(*args), + 'rotate': lambda *args: rotate(*args), } -def find_min_sym_type(symmetries, tr_len): - """ - Find the "minimum" common symmetry type between all given symmetries. - For instance: - none, permute => none - rotate8, permute => rotate8 - rotate4reflect, rotate8 => rotate4 - The last one resolves to a wholly-different symmetry type. This is - because rotate4reflect cannot express the fact that rotate8 does - not include reflection, so it cannot resolve to rotate4reflect. +class Napkin(tuple): + def __new__(cls, iterable, *_): + return super().__new__(cls, iterable) - Algorithmically, this is calculated by: - (1) finding the symmetry type whose symmetries:none expansion (when - all terms are unique) is the smallest - (2) checking whether this symmetry type is comprised entirely by all - the others - (3) if (2), returning that minimum symmetry type, but otherwise: - (4) finding the first Golly symmetry type that is comprised entirely - by both the minimum symmetry type and all the rest - """ - # Find smallest symmetries:none-expanded sym type - # (sym_lens holds precalculated lengths of these 'none expansions') - min_cls = min(symmetries, key=lambda cls: cls.sym_lens[tr_len]) - # If it's a custom symmetry type, use its Golly fallback - golly_cls = min_cls if not hasattr(min_cls, 'fallback') else min_cls.fallback.get(tr_len, min_cls.fallback[None]) - min_syms, min_sym_len = golly_cls.symmetries[tr_len], golly_cls.sym_lens[tr_len] - # All symmetry types used which do not comprise min_syms - failures = [ - napkin_set for napkin_set in - [c.symmetries[tr_len] for c in symmetries if min_cls is not c is not golly_cls] - if not all(map(napkin_set.__contains__, min_syms)) - ] - if not failures: - return golly_cls - to_test = [min_syms, *failures] - # Largest Golly symmetry type that comprises both min_syms and everything else used - return next( - cls - for cls, v in napkins.GOLLY_SYMS[tr_len] - if v < min_sym_len - and all(napkin in napkin_set for napkin in cls.symmetries[tr_len] for napkin_set in to_test) - ) + def __init__(self, _): + self._cdir_map = dict(zip(self.nbhd, self)) + self._expanded = None + self._hash = None + + def __hash__(self): + if self._hash is None: + self._hash = hash(tuple(sorted(self.expanded))) + return self._hash + + def __repr__(self): + return f'{self.__class__.__name__}{super().__repr__()}' + + def _expand(self): + raise NotImplementedError("Please override method `_expand()` in Napkin subclass") + + @property + def nbhd(self): + raise NotImplementedError("Please override static variable `nbhd` in Napkin subclass") + + @property + def expanded(self): + if self._expanded is None: + self._expanded = frozenset(self._expand()) + return self._expanded + + @classmethod + def compose(cls, other): + if cls.nbhd != other.nbhd: + raise TypeError(f'Cannot compose symmetries of differing neighborhoods {cls.nbhd} and {other.nbhd}') + return _new_sym_type( + cls.nbhd, + f'{cls.__name__}+{other.__name__}', + lambda self: [j for i in other(self).expanded for j in cls(i).expanded] + ) + + def _convert(self, iterable): + return [tuple(map(self._cdir_map.get, i)) for i in iterable] + + def reflections_across(self, *args): + return self._convert(self.nbhd.reflections_across(*args)) + + def rotations_by(self, *args): + return self._convert(self.nbhd.rotations_by(*args)) + + def permutations(self, *args): + return self._convert(self.nbhd.permutations(args)) + + +def find_min_sym_type(symmetries, tr_len): + dummy = range(tr_len) + return permute()(dummy) & reduce(set.__and__, [cls(dummy).expanded for cls in symmetries]) def get_sym_type(nbhd, string): all_syms = [] current = [] - for token in utils.multisplit(string, (None, *'(),_')): + for token in utils.multisplit(string, (None, *'(),')): if token in PRESETS: if current: all_syms.append(current) @@ -76,54 +91,46 @@ def get_sym_type(nbhd, string): all_syms.append(current) resultant_sym = None for name, *args in all_syms: - cur_sym = PRESETS[name](nbhd, *args) - resultant_sym = cur_sym if resultant_sym is None else compose(resultant_sym, cur_sym) + cur_sym = PRESETS[name](*args)(nbhd) + resultant_sym = cur_sym if resultant_sym is None else resultant_sym.compose(cur_sym) return resultant_sym -# get_sym_type(Neighborhood(('N', 'NE', 'E', 'S', 'SW', 'W')), 'rotate(2) reflect(N, NE))').expanded -# for example -def _new_sym_type(name, expanded): - return type(name, (list,), { - 'expanded': expanded +def _new_sym_type(nbhd, name, func): + return type(name, (Napkin,), { + '_expand': func, + 'nbhd': nbhd }) -def compose(*symmetries): - return _new_sym_type( - '+'.join([s.__name__ for s in symmetries]), - sorted({t for s in symmetries for t in s.expanded}) - ) - +def compose(*funcs): + return lambda nbhd: reduce(lambda a, b: a.compose(b), [f(nbhd) for f in funcs]) -def reflect_multiple(nbhd, *coords): - return compose(reflect(nbhd, c) if isinstance(c, str) else reflect(nbhd, *c) for c in coords) - -def reflect(nbhd, first, second=None): +def reflect(first, second=None): first = Coord.from_name(first) second = first if second is None else Coord.from_name(second) - return _new_sym_type( - f'Reflect_{first}_{second}', - sorted([nbhd.cdirs, nbhd.reflect_across((first, second)).cdirs]) + return lambda nbhd: _new_sym_type( + nbhd, + f'Reflect_{first.name}_{second.name}', + lambda self: self.reflections_across((first, second)) ) -def rotate(nbhd, n): - return _new_sym_type( +def rotate(n): + return lambda nbhd: _new_sym_type( + nbhd, f'Rotate_{n}', - sorted([i.cdirs for i in nbhd.rotations_by(int(n))]) + lambda self: self.rotations_by(int(n)) ) -def permute(nbhd, cdirs=None): - return _new_sym_type( +def permute(*cdirs): + return lambda nbhd: _new_sym_type( + nbhd, f"Permute_{'_'.join(cdirs)}", - sorted(nbhd.permutations(cdirs or None)) + lambda self: self.permutations(cdirs or None) ) -def none(nbhd, cdirs=None): - return _new_sym_type( - f'NoSymmetry', - [nbhd.cdirs] - ) +def _none(self): + return [self] From c3055094964bb62afdc164770e9954789d421d34 Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 26 Dec 2018 01:25:55 -0800 Subject: [PATCH 07/33] Proper, working neighborhood reassignment for symmetries --- nutshell/segment_types/table/_symutils.py | 130 ++++++++++++++-------- 1 file changed, 83 insertions(+), 47 deletions(-) diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 2f3dd2d..466bcc1 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -6,27 +6,38 @@ from . import _napkins as napkins -PRESETS = { - 'rotate8reflect': lambda *_: compose(rotate(8), reflect('W')), - 'rotate8': lambda *_: rotate(8), - 'rotate4reflect': lambda *_: compose(rotate(4), reflect('W')), - 'rotate4': lambda *_: rotate(4), - 'reflect_horizontal': lambda *_: reflect('W'), - 'reflect_vertical': lambda *_: reflect('N'), - 'none': lambda *_: lambda nbhd: _new_sym_type(nbhd, 'NoSymmetry', _none), - #### - 'permute': lambda *args: permute(*args), - 'reflect': lambda *args: reflect(*args), - 'rotate': lambda *args: rotate(*args), -} +# pretty sure this is a hacky observer-pattern implementation +class NapkinMeta(type): + def __init__(cls, *_): + cls.__tested = False + + @property + def nbhd(cls): + if not hasattr(cls, '_nbhd'): + cls._nbhd = None + if cls._nbhd is not None and not cls.__tested: + cls.__tested = True + cls.test_nbhd() + return cls._nbhd + + @nbhd.setter + def nbhd(cls, neighborhood): + old, cls._nbhd = cls._nbhd, neighborhood + try: + cls.test_nbhd() + except: + cls._nbhd = old + raise + + def test_nbhd(cls): + cls(range(len(cls.nbhd))).expanded -class Napkin(tuple): - def __new__(cls, iterable, *_): +class Napkin(tuple, metaclass=NapkinMeta): + def __new__(cls, iterable): return super().__new__(cls, iterable) def __init__(self, _): - self._cdir_map = dict(zip(self.nbhd, self)) self._expanded = None self._hash = None @@ -38,52 +49,62 @@ def __hash__(self): def __repr__(self): return f'{self.__class__.__name__}{super().__repr__()}' - def _expand(self): - raise NotImplementedError("Please override method `_expand()` in Napkin subclass") - - @property - def nbhd(self): - raise NotImplementedError("Please override static variable `nbhd` in Napkin subclass") + def expand(self): + raise NotImplementedError("Please override method `expand()` in Napkin subclass") @property def expanded(self): if self._expanded is None: - self._expanded = frozenset(self._expand()) + self._expanded = frozenset(self.expand()) return self._expanded + @property + def cdir_map(self): + return dict(zip(self._neighborhood, self)) + + @property + def _neighborhood(self): + return self.__class__.nbhd + @classmethod def compose(cls, other): - if cls.nbhd != other.nbhd: - raise TypeError(f'Cannot compose symmetries of differing neighborhoods {cls.nbhd} and {other.nbhd}') + def _not_lambda(self): + # why bother with .__get__() rather than just iterating through .expanded? + # because (1) each class's nbhd may not yet have been initialized, which will + # make .expanded error, and (2) when we're composing, we don't really care about + # the method as relating to a specific class -- we only care about the *transformation* + # provided by the pure, unbound method + return [j for i in other.expand.__get__(self)() for j in cls.expand.__get__(self.__class__(i))()] return _new_sym_type( - cls.nbhd, f'{cls.__name__}+{other.__name__}', - lambda self: [j for i in other(self).expanded for j in cls(i).expanded] + _not_lambda ) def _convert(self, iterable): - return [tuple(map(self._cdir_map.get, i)) for i in iterable] + cdir_map = self.cdir_map + return [tuple(cdir_map[j] for j in i) for i in iterable] def reflections_across(self, *args): - return self._convert(self.nbhd.reflections_across(*args)) + return self._convert(self._neighborhood.reflections_across(*args)) def rotations_by(self, *args): - return self._convert(self.nbhd.rotations_by(*args)) + return self._convert(self._neighborhood.rotations_by(*args)) def permutations(self, *args): - return self._convert(self.nbhd.permutations(args)) + return self._convert(self._neighborhood.permutations(*args)) -def find_min_sym_type(symmetries, tr_len): - dummy = range(tr_len) - return permute()(dummy) & reduce(set.__and__, [cls(dummy).expanded for cls in symmetries]) +def find_min_sym_type(symmetries, nbhd): + dummy = range(len(nbhd)) + # `return permute_under_nbhd(dummy) & ...` for non-golly symmetries too + return reduce(frozenset.__and__, [cls(dummy).expanded for cls in symmetries]) def get_sym_type(nbhd, string): all_syms = [] current = [] for token in utils.multisplit(string, (None, *'(),')): - if token in PRESETS: + if token in PRESETS or token in FUNCS: if current: all_syms.append(current) current = [] @@ -91,46 +112,61 @@ def get_sym_type(nbhd, string): all_syms.append(current) resultant_sym = None for name, *args in all_syms: - cur_sym = PRESETS[name](*args)(nbhd) + cur_sym = PRESETS[name] if name in PRESETS else FUNCS[name](*args) resultant_sym = cur_sym if resultant_sym is None else resultant_sym.compose(cur_sym) + resultant_sym.nbhd = nbhd return resultant_sym -def _new_sym_type(nbhd, name, func): +def _new_sym_type(name, func): return type(name, (Napkin,), { - '_expand': func, - 'nbhd': nbhd + 'expand': func, + '_nbhd': None }) def compose(*funcs): - return lambda nbhd: reduce(lambda a, b: a.compose(b), [f(nbhd) for f in funcs]) + return reduce(lambda a, b: a.compose(b), funcs) def reflect(first, second=None): first = Coord.from_name(first) second = first if second is None else Coord.from_name(second) - return lambda nbhd: _new_sym_type( - nbhd, + return _new_sym_type( f'Reflect_{first.name}_{second.name}', lambda self: self.reflections_across((first, second)) ) def rotate(n): - return lambda nbhd: _new_sym_type( - nbhd, + return _new_sym_type( f'Rotate_{n}', lambda self: self.rotations_by(int(n)) ) def permute(*cdirs): - return lambda nbhd: _new_sym_type( - nbhd, - f"Permute_{'_'.join(cdirs)}", + return _new_sym_type( + f"Permute_{'_'.join(cdirs) if cdirs else 'All'}", lambda self: self.permutations(cdirs or None) ) def _none(self): return [self] + + +PRESETS = { + 'rotate8reflect': compose(rotate(8), reflect('W')), + 'rotate8': rotate(8), + 'rotate4reflect': compose(rotate(4), reflect('W')), + 'rotate4': rotate(4), + 'reflect_horizontal': reflect('W'), + 'reflect_vertical': reflect('N'), + 'none': _new_sym_type('NoSymmetry', _none) +} + +FUNCS = { + 'permute': permute, + 'reflect': reflect, + 'rotate': rotate, +} From c2dc0cf8c6780ba18558d9a66c3b349e3e99670c Mon Sep 17 00:00:00 2001 From: hadi tarhini Date: Wed, 26 Dec 2018 02:13:31 -0800 Subject: [PATCH 08/33] Improve style, update find_min_sym --- nutshell/segment_types/table/_symutils.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 466bcc1..ec1ffd8 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,5 +1,6 @@ from functools import reduce from importlib import import_module +from operator import and_ as bitwise_and from nutshell.common import symmetries as ext_symmetries, utils from ._classes import Coord @@ -68,16 +69,9 @@ def _neighborhood(self): @classmethod def compose(cls, other): - def _not_lambda(self): - # why bother with .__get__() rather than just iterating through .expanded? - # because (1) each class's nbhd may not yet have been initialized, which will - # make .expanded error, and (2) when we're composing, we don't really care about - # the method as relating to a specific class -- we only care about the *transformation* - # provided by the pure, unbound method - return [j for i in other.expand.__get__(self)() for j in cls.expand.__get__(self.__class__(i))()] return _new_sym_type( f'{cls.__name__}+{other.__name__}', - _not_lambda + lambda self: [j for i in other.expand(self) for j in cls.expand(self.__class__(i))] ) def _convert(self, iterable): @@ -96,8 +90,12 @@ def permutations(self, *args): def find_min_sym_type(symmetries, nbhd): dummy = range(len(nbhd)) - # `return permute_under_nbhd(dummy) & ...` for non-golly symmetries too - return reduce(frozenset.__and__, [cls(dummy).expanded for cls in symmetries]) + superset = permute() + superset.nbhd = nbhd + return superset(dummy) & reduce( + bitwise_and, + [cls(dummy).expanded for cls in symmetries] + ) def get_sym_type(nbhd, string): From 5ba39f83abdf525081762079593063e0bf3c217e Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 26 Dec 2018 13:46:47 -0800 Subject: [PATCH 09/33] Nix NapkinMeta, impl support-checking, make permute faster --- README.md | 2 +- .../segment_types/table/_neighborhoods.py | 44 +++++-- nutshell/segment_types/table/_symutils.py | 107 ++++++++---------- 3 files changed, 84 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index d3a1c53..6c68b06 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ of this makes any sense to you and you aren't sure how you got here, check out t - [The `@ICONS` segment](#the-icons-segment) ## Setup -1. [Download & install Python 3.6](https://www.python.org/downloads/release/python-365/) or higher (support for < 3.6 hopefully coming soon) +1. [Download & install Python 3.6](https://www.python.org/downloads/release/python-365/) or higher 2. Either: 1. Execute the terminal command `pip install -U git+git://github.com/eltrhn/nutshell.git` (or whichever of the pip command's variations works for you; you may need to try `python -m pip install`, `python3 -m pip install`, diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 9abf1db..0059635 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -57,7 +57,22 @@ def cdir_at(self, idx): def gollyizer_for(self, tbl): return get_gollyizer(tbl, self.cdirs) - def reflect_across(self, endpoint): + def supports(self, sym_type): + for method, *args in sym_type.transformations: + if method == 'rotations_by': + amt, = args + if len(self) % int(amt) or not self.symmetrical: + return False + if method == 'reflections_across': + try: + self.reflect_across(*args) + except Exception: + return False + # if method == 'permute': + # True + return True + + def reflect_across(self, endpoint, *, as_cls=True): if not isinstance(endpoint, tuple): raise TypeError('Endpoint of line of reflection should be given as tuple of compass directions') a, b = endpoint @@ -83,26 +98,33 @@ def reflect_across(self, endpoint): except KeyError as e: raise ValueError(f'Neighborhood does not contain {e}') r = {cdir: self[orig_cdir] for orig_cdir, cdir in d.items()} - return Neighborhood(sorted(r, key=r.get)) + if as_cls: + return Neighborhood(sorted(r, key=r.get)) + return tuple(sorted(r, key=r.get)) - def reflections_across(self, endpoint): - return (self, self.reflect_across(endpoint)) + def reflections_across(self, endpoint, as_cls): + if as_cls: + return (self, self.reflect_across(endpoint)) + return [self.cdirs, self.reflect_across(endpoint, as_cls=as_cls)] - def rotate_by(self, offset): - return Neighborhood(self.cdirs[offset:] + self.cdirs[:offset]) + def rotate_by(self, offset, *, as_cls=True): + if as_cls: + return Neighborhood(self.cdirs[offset:] + self.cdirs[:offset]) + return self.cdirs[offset:] + self.cdirs[:offset] - def rotations_by(self, amt): + def rotations_by(self, amt, *, as_cls=True): if len(self) % amt: raise ValueError(f'Neighborhood cannot be rotated evenly by {amt}') if not self.symmetrical: raise ValueError('Neighborhood is asymmetrical, cannot be rotated except by 1') - return [self.rotate_by(offset) for offset in range(0, len(self), len(self) // amt)] + return [self.rotate_by(offset, as_cls=as_cls) for offset in range(0, len(self), len(self) // amt)] - def permutations(self, cdirs=None): + def permutations(self, cdirs=None, *, as_cls=True): if cdirs is None: - cdirs = self.cdirs + return [Neighborhood(i) for i in permutations(self.cdirs)] if as_cls else list(permutations(self.cdirs)) permuted_cdirs = set(cdirs) - return [Neighborhood(next(permute) if c in permuted_cdirs else c for c in self) for permute in map(iter, permutations(cdirs))] + cls = Neighborhood if as_cls else tuple + return [cls(next(permute) if c in permuted_cdirs else c for c in self) for permute in map(iter, permutations(cdirs))] def get_gollyizer(tbl, nbhd): diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index ec1ffd8..282d268 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -4,44 +4,24 @@ from nutshell.common import symmetries as ext_symmetries, utils from ._classes import Coord -from . import _napkins as napkins - - -# pretty sure this is a hacky observer-pattern implementation -class NapkinMeta(type): - def __init__(cls, *_): - cls.__tested = False - - @property - def nbhd(cls): - if not hasattr(cls, '_nbhd'): - cls._nbhd = None - if cls._nbhd is not None and not cls.__tested: - cls.__tested = True - cls.test_nbhd() - return cls._nbhd +# from ._neighborhoods import Neighborhood - @nbhd.setter - def nbhd(cls, neighborhood): - old, cls._nbhd = cls._nbhd, neighborhood - try: - cls.test_nbhd() - except: - cls._nbhd = old - raise - - def test_nbhd(cls): - cls(range(len(cls.nbhd))).expanded +class Napkin(tuple): + nbhd = None + transformations = None -class Napkin(tuple, metaclass=NapkinMeta): - def __new__(cls, iterable): - return super().__new__(cls, iterable) - def __init__(self, _): self._expanded = None self._hash = None + def __init_subclass__(cls): + if cls.nbhd is None: + raise NotImplementedError('Please override class attribute `nbhd` in Napkin subclass') + if cls.transformations is None: + raise NotImplementedError('Please override class attribute `transformations` in Napkin subclass') + cls.test_nbhd() + def __hash__(self): if self._hash is None: self._hash = hash(tuple(sorted(self.expanded))) @@ -51,7 +31,7 @@ def __repr__(self): return f'{self.__class__.__name__}{super().__repr__()}' def expand(self): - raise NotImplementedError("Please override method `expand()` in Napkin subclass") + raise NotImplementedError('Please override method `expand()` in Napkin subclass') @property def expanded(self): @@ -61,38 +41,42 @@ def expanded(self): @property def cdir_map(self): - return dict(zip(self._neighborhood, self)) - - @property - def _neighborhood(self): - return self.__class__.nbhd + return dict(zip(self.nbhd, self)) @classmethod def compose(cls, other): + if cls.nbhd != other.nbhd: + raise TypeError('Cannot compose symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') return _new_sym_type( + cls.nbhd, f'{cls.__name__}+{other.__name__}', + cls.transformations + other.transformations, lambda self: [j for i in other.expand(self) for j in cls.expand(self.__class__(i))] ) + @classmethod + def test_nbhd(cls): + if not cls.nbhd.supports(cls): + raise ValueError(f'Neighborhood does not support {cls.__name__} symmetries') + def _convert(self, iterable): cdir_map = self.cdir_map return [tuple(cdir_map[j] for j in i) for i in iterable] def reflections_across(self, *args): - return self._convert(self._neighborhood.reflections_across(*args)) + return self._convert(self.nbhd.reflections_across(*args, as_cls=False)) def rotations_by(self, *args): - return self._convert(self._neighborhood.rotations_by(*args)) + return self._convert(self.nbhd.rotations_by(*args, as_cls=False)) def permutations(self, *args): - return self._convert(self._neighborhood.permutations(*args)) + return self._convert(self.nbhd.permutations(*args, as_cls=False)) def find_min_sym_type(symmetries, nbhd): dummy = range(len(nbhd)) - superset = permute() - superset.nbhd = nbhd - return superset(dummy) & reduce( + superset = permute()(dummy) + return superset(dummy).expanded & reduce( bitwise_and, [cls(dummy).expanded for cls in symmetries] ) @@ -110,47 +94,56 @@ def get_sym_type(nbhd, string): all_syms.append(current) resultant_sym = None for name, *args in all_syms: - cur_sym = PRESETS[name] if name in PRESETS else FUNCS[name](*args) + _cur_sym = PRESETS[name](nbhd) if name in PRESETS else FUNCS[name](*args) + cur_sym = _cur_sym(nbhd) resultant_sym = cur_sym if resultant_sym is None else resultant_sym.compose(cur_sym) - resultant_sym.nbhd = nbhd return resultant_sym -def _new_sym_type(name, func): +def _new_sym_type(nbhd, name, transformations, func=None): + if func is None: + method = getattr(Napkin, transformations[0]) + args = transformations[1:] + func = lambda self: method(self, *args) + transformations = [transformations] return type(name, (Napkin,), { 'expand': func, - '_nbhd': None + 'transformations': transformations, + 'nbhd': nbhd }) def compose(*funcs): - return reduce(lambda a, b: a.compose(b), funcs) + return lambda nbhd: reduce(Napkin.compose.__func__, [f(nbhd) for f in funcs]) def reflect(first, second=None): first = Coord.from_name(first) second = first if second is None else Coord.from_name(second) - return _new_sym_type( + return lambda nbhd: _new_sym_type( + nbhd, f'Reflect_{first.name}_{second.name}', - lambda self: self.reflections_across((first, second)) + ('reflections_across', (first, second)) # lambda self: self.reflections_across((first, second)) ) def rotate(n): - return _new_sym_type( + return lambda nbhd: _new_sym_type( + nbhd, f'Rotate_{n}', - lambda self: self.rotations_by(int(n)) + ('rotations_by', int(n)) # lambda self: self.rotations_by(int(n)) ) def permute(*cdirs): - return _new_sym_type( + return lambda nbhd: _new_sym_type( + nbhd, f"Permute_{'_'.join(cdirs) if cdirs else 'All'}", - lambda self: self.permutations(cdirs or None) + ('permutations', cdirs or None) # lambda self: self.permutations(cdirs or None) ) -def _none(self): - return [self] +def _none(nbhd): + return _new_sym_type(nbhd, 'NoSymmetry', lambda self: [self]) PRESETS = { @@ -160,7 +153,7 @@ def _none(self): 'rotate4': rotate(4), 'reflect_horizontal': reflect('W'), 'reflect_vertical': reflect('N'), - 'none': _new_sym_type('NoSymmetry', _none) + 'none': _none } FUNCS = { From 4b6c13891bd0a4c3530f1e65a5b77cafa73f456a Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 26 Dec 2018 15:41:16 -0800 Subject: [PATCH 10/33] Fully impl min-sym-type-finding, more speed improvements --- .../segment_types/table/_neighborhoods.py | 9 +++ nutshell/segment_types/table/_symutils.py | 58 +++++++++++++------ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 0059635..1b76be8 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -18,7 +18,16 @@ class Neighborhood: + GOLLY_NBHDS = { + 'oneDimensional': ('W', 'E'), + 'vonNeumann': ('N', 'E', 'S', 'W'), + 'hexagonal': ('N', 'E', 'SE', 'S', 'W', 'NW'), + 'Moore': ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW') + } + def __init__(self, cdirs): + if isinstance(cdirs, str): + cdirs = self.GOLLY_NBHDS[cdirs] self.cdirs = tuple(cdirs) self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) self._inv = dict(enumerate(cdirs, 1)) diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 282d268..a63bcad 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,15 +1,16 @@ -from functools import reduce +from functools import reduce, lru_cache from importlib import import_module from operator import and_ as bitwise_and from nutshell.common import symmetries as ext_symmetries, utils +from ._neighborhoods import Neighborhood from ._classes import Coord -# from ._neighborhoods import Neighborhood - + class Napkin(tuple): nbhd = None transformations = None + _RECENTS = {} def __init__(self, _): self._expanded = None @@ -20,6 +21,7 @@ def __init_subclass__(cls): raise NotImplementedError('Please override class attribute `nbhd` in Napkin subclass') if cls.transformations is None: raise NotImplementedError('Please override class attribute `transformations` in Napkin subclass') + cls._RECENTS = {} cls.test_nbhd() def __hash__(self): @@ -70,16 +72,20 @@ def rotations_by(self, *args): return self._convert(self.nbhd.rotations_by(*args, as_cls=False)) def permutations(self, *args): - return self._convert(self.nbhd.permutations(*args, as_cls=False)) + if args not in self._RECENTS: + self._RECENTS[args] = self._convert(self.nbhd.permutations(*args, as_cls=False)) + return self._RECENTS[args] def find_min_sym_type(symmetries, nbhd): dummy = range(len(nbhd)) - superset = permute()(dummy) - return superset(dummy).expanded & reduce( + result = reduce( bitwise_and, [cls(dummy).expanded for cls in symmetries] ) + if result in _GOLLY_NAMES: + return result, _GOLLY_NAMES[result] + return none(nbhd), 'none' def get_sym_type(nbhd, string): @@ -94,8 +100,7 @@ def get_sym_type(nbhd, string): all_syms.append(current) resultant_sym = None for name, *args in all_syms: - _cur_sym = PRESETS[name](nbhd) if name in PRESETS else FUNCS[name](*args) - cur_sym = _cur_sym(nbhd) + cur_sym = PRESETS[name](nbhd) if name in PRESETS else FUNCS[name](*args)(nbhd) resultant_sym = cur_sym if resultant_sym is None else resultant_sym.compose(cur_sym) return resultant_sym @@ -113,37 +118,43 @@ def _new_sym_type(nbhd, name, transformations, func=None): }) +@lru_cache() def compose(*funcs): - return lambda nbhd: reduce(Napkin.compose.__func__, [f(nbhd) for f in funcs]) + return lru_cache()(lambda nbhd: reduce(Napkin.compose.__func__, [f(nbhd) for f in funcs])) +@lru_cache() def reflect(first, second=None): first = Coord.from_name(first) second = first if second is None else Coord.from_name(second) - return lambda nbhd: _new_sym_type( + return lru_cache()(lambda nbhd: _new_sym_type( nbhd, f'Reflect_{first.name}_{second.name}', ('reflections_across', (first, second)) # lambda self: self.reflections_across((first, second)) - ) + )) +@lru_cache() def rotate(n): - return lambda nbhd: _new_sym_type( + return lru_cache()(lambda nbhd: _new_sym_type( nbhd, f'Rotate_{n}', ('rotations_by', int(n)) # lambda self: self.rotations_by(int(n)) - ) + )) +@lru_cache() def permute(*cdirs): - return lambda nbhd: _new_sym_type( + return lru_cache()(lambda nbhd: _new_sym_type( nbhd, f"Permute_{'_'.join(cdirs) if cdirs else 'All'}", ('permutations', cdirs or None) # lambda self: self.permutations(cdirs or None) - ) + )) -def _none(nbhd): - return _new_sym_type(nbhd, 'NoSymmetry', lambda self: [self]) + +@lru_cache() +def none(nbhd): + return _new_sym_type(nbhd, 'NoSymmetry', (), lambda self: [tuple(self)]) PRESETS = { @@ -153,7 +164,7 @@ def _none(nbhd): 'rotate4': rotate(4), 'reflect_horizontal': reflect('W'), 'reflect_vertical': reflect('N'), - 'none': _none + 'none': none } FUNCS = { @@ -161,3 +172,14 @@ def _none(nbhd): 'reflect': reflect, 'rotate': rotate, } + +_permute = permute() +_GOLLY_NAMES = {} +for nbhd_name, nbhd in [(name, Neighborhood(name)) for name in Neighborhood.GOLLY_NBHDS]: + dummy = range(len(nbhd)) + for sym_name, func in PRESETS.items(): + try: + _GOLLY_NAMES[func(nbhd)(dummy).expanded] = sym_name + except: + pass + _GOLLY_NAMES[_permute(nbhd)(dummy).expanded] = 'permute' From 693480c5e8aeeab7793d73b63d2cb48d4e80e7de Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 27 Dec 2018 00:30:10 -0800 Subject: [PATCH 11/33] Add symmetry-combining, still no working AlternatingPermute --- nutshell/segment_types/table/_symutils.py | 34 +++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index a63bcad..6ef0f74 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -56,6 +56,17 @@ def compose(cls, other): lambda self: [j for i in other.expand(self) for j in cls.expand(self.__class__(i))] ) + @classmethod + def combine(cls, other): + if cls.nbhd != other.nbhd: + raise TypeError('Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') + return _new_sym_type( + cls.nbhd, + f'{cls.__name__}/{other.__name__}', + cls.transformations + other.transformations, + lambda self: [*other.expand(self), *cls.expand(self)] + ) + @classmethod def test_nbhd(cls): if not cls.nbhd.supports(cls): @@ -89,19 +100,30 @@ def find_min_sym_type(symmetries, nbhd): def get_sym_type(nbhd, string): - all_syms = [] current = [] + all_syms = [[]] for token in utils.multisplit(string, (None, *'(),')): + if token == '/': + if current: + all_syms[-1].append(current) + if all_syms[-1]: + all_syms.append([]) + current = [] + continue if token in PRESETS or token in FUNCS: if current: - all_syms.append(current) + all_syms[-1].append(current) current = [] current.append(token) - all_syms.append(current) + if current: + all_syms[-1].append(current) resultant_sym = None - for name, *args in all_syms: - cur_sym = PRESETS[name](nbhd) if name in PRESETS else FUNCS[name](*args)(nbhd) - resultant_sym = cur_sym if resultant_sym is None else resultant_sym.compose(cur_sym) + for compose_group in all_syms: + composed_sym = None + for name, *args in compose_group: + cur_sym = PRESETS[name](nbhd) if name in PRESETS else FUNCS[name](*args)(nbhd) + composed_sym = cur_sym if composed_sym is None else composed_sym.compose(cur_sym) + resultant_sym = composed_sym if resultant_sym is None else resultant_sym.combine(composed_sym) return resultant_sym From d6c1d01814efc0d600c22795c1f0423ee8ef45ec Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 27 Dec 2018 01:02:25 -0800 Subject: [PATCH 12/33] Fix composition (but need to reimpl permute-expansion caching later) --- nutshell/segment_types/table/_neighborhoods.py | 10 ++++++++++ nutshell/segment_types/table/_symutils.py | 8 +++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 1b76be8..84bfe60 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -52,6 +52,16 @@ def __repr__(self): def __str__(self): return '\n'.join(map(' '.join, self.to_list())) + def __eq__(self, other): + if isinstance(other, tuple): + return self.cdirs.__eq__(other) + if isinstance(other, Neighborhood): + return self.cdirs.__eq__(other.cdirs) + return NotImplemented + + def __hash__(self): + return self.cdirs.__hash__() + def get(self, item, default=None): return self.idxes.get(item, default) diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 6ef0f74..65ea9b1 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -48,7 +48,7 @@ def cdir_map(self): @classmethod def compose(cls, other): if cls.nbhd != other.nbhd: - raise TypeError('Cannot compose symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') + raise TypeError(f'Cannot compose symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') return _new_sym_type( cls.nbhd, f'{cls.__name__}+{other.__name__}', @@ -59,7 +59,7 @@ def compose(cls, other): @classmethod def combine(cls, other): if cls.nbhd != other.nbhd: - raise TypeError('Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') + raise TypeError(f'Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') return _new_sym_type( cls.nbhd, f'{cls.__name__}/{other.__name__}', @@ -83,9 +83,7 @@ def rotations_by(self, *args): return self._convert(self.nbhd.rotations_by(*args, as_cls=False)) def permutations(self, *args): - if args not in self._RECENTS: - self._RECENTS[args] = self._convert(self.nbhd.permutations(*args, as_cls=False)) - return self._RECENTS[args] + return self._convert(self.nbhd.permutations(*args, as_cls=False)) def find_min_sym_type(symmetries, nbhd): From 27136cf509be12130115257b2f121ccf512c86a6 Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 27 Dec 2018 22:26:11 -0800 Subject: [PATCH 13/33] Get find_min_sym_type in order; don't req symmetry for rotation --- .../segment_types/table/_neighborhoods.py | 36 +++++--- nutshell/segment_types/table/_symutils.py | 89 +++++++++++++------ 2 files changed, 85 insertions(+), 40 deletions(-) diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 84bfe60..833a5ba 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -1,12 +1,13 @@ +from collections import OrderedDict from itertools import takewhile, permutations from ._classes import Coord -NBHD_SETS = ( +NBHD_SETS = OrderedDict( # for containment-checking - (frozenset({'E', 'W'}), 'oneDimensional'), - (frozenset({'N', 'E', 'S', 'W'}), 'vonNeumann'), - (frozenset({'N', 'E', 'SE', 'S', 'W', 'NW'}), 'hexagonal'), - (frozenset({'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'}), 'Moore'), + oneDimensional=frozenset({'E', 'W'}), + vonNeumann=frozenset({'N', 'E', 'S', 'W'}), + hexagonal=frozenset({'N', 'E', 'SE', 'S', 'W', 'NW'}), + Moore=frozenset({'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'}), ) ORDERED_NBHDS = { @@ -32,7 +33,6 @@ def __init__(self, cdirs): self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) self._inv = dict(enumerate(cdirs, 1)) self.idxes = {v: k for k, v in self._inv.items()} - self.symmetrical = all(c.inv.name in self for c in self.coord_cdirs) def __contains__(self, item): return item in self.idxes @@ -76,11 +76,11 @@ def cdir_at(self, idx): def gollyizer_for(self, tbl): return get_gollyizer(tbl, self.cdirs) - def supports(self, sym_type): - for method, *args in sym_type.transformations: + def supports_transformations(self, transformations): + for method, *args in transformations: if method == 'rotations_by': amt, = args - if len(self) % int(amt) or not self.symmetrical: + if len(self) % int(amt): return False if method == 'reflections_across': try: @@ -91,6 +91,9 @@ def supports(self, sym_type): # True return True + def supports(self, sym_type): + return self.supports_transformations(sym_type.transformations) + def reflect_across(self, endpoint, *, as_cls=True): if not isinstance(endpoint, tuple): raise TypeError('Endpoint of line of reflection should be given as tuple of compass directions') @@ -134,8 +137,8 @@ def rotate_by(self, offset, *, as_cls=True): def rotations_by(self, amt, *, as_cls=True): if len(self) % amt: raise ValueError(f'Neighborhood cannot be rotated evenly by {amt}') - if not self.symmetrical: - raise ValueError('Neighborhood is asymmetrical, cannot be rotated except by 1') + #if not self.symmetrical: + # raise ValueError('Neighborhood is asymmetrical, cannot be rotated except by 1') return [self.rotate_by(offset, as_cls=as_cls) for offset in range(0, len(self), len(self) // amt)] def permutations(self, cdirs=None, *, as_cls=True): @@ -146,9 +149,16 @@ def permutations(self, cdirs=None, *, as_cls=True): return [cls(next(permute) if c in permuted_cdirs else c for c in self) for permute in map(iter, permutations(cdirs))] -def get_gollyizer(tbl, nbhd): +def get_gollyizer(tbl, nbhd, *, golly_nbhd=None): nbhd_set = set(nbhd) - for s, name in NBHD_SETS: + if golly_nbhd is not None: + golly_set = NBHD_SETS[golly_nbhd] + return ( + fill.__get__(ORDERED_NBHDS[golly_nbhd]) + if nbhd_set < golly_set + else lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) + ) + for name, s in NBHD_SETS.items(): if nbhd_set <= s: tbl.directives['neighborhood'] = name if nbhd_set < s: diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 65ea9b1..2024ab8 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,3 +1,4 @@ +from collections import OrderedDict from functools import reduce, lru_cache from importlib import import_module from operator import and_ as bitwise_and @@ -16,9 +17,10 @@ def __init__(self, _): self._expanded = None self._hash = None + # 3.6-only: pep 487 def __init_subclass__(cls): - if cls.nbhd is None: - raise NotImplementedError('Please override class attribute `nbhd` in Napkin subclass') + # if cls.nbhd is None: + # raise NotImplementedError('Please override class attribute `nbhd` in Napkin subclass') if cls.transformations is None: raise NotImplementedError('Please override class attribute `transformations` in Napkin subclass') cls._RECENTS = {} @@ -29,6 +31,9 @@ def __hash__(self): self._hash = hash(tuple(sorted(self.expanded))) return self._hash + def __eq__(self, other): + return isinstance(other, tuple) and any(map(other.__eq__, self.expanded)) + def __repr__(self): return f'{self.__class__.__name__}{super().__repr__()}' @@ -49,7 +54,7 @@ def cdir_map(self): def compose(cls, other): if cls.nbhd != other.nbhd: raise TypeError(f'Cannot compose symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') - return _new_sym_type( + return new_sym_type( cls.nbhd, f'{cls.__name__}+{other.__name__}', cls.transformations + other.transformations, @@ -60,7 +65,7 @@ def compose(cls, other): def combine(cls, other): if cls.nbhd != other.nbhd: raise TypeError(f'Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') - return _new_sym_type( + return new_sym_type( cls.nbhd, f'{cls.__name__}/{other.__name__}', cls.transformations + other.transformations, @@ -92,8 +97,18 @@ def find_min_sym_type(symmetries, nbhd): bitwise_and, [cls(dummy).expanded for cls in symmetries] ) + if result not in _GOLLY_NAMES: + # Pretty sure this is 100% wrong for the general case. + # it works for alternatingpermute->rotate4reflect, at least. + HighestSupportedSym = ( + compose(rotate(len(nbhd)), reflect('N')) + if nbhd.supports_transformations([['reflect_across', 'N']]) + else rotate(len(nbhd)) + )(nbhd) + result &= HighestSupportedSym(dummy).expanded if result in _GOLLY_NAMES: - return result, _GOLLY_NAMES[result] + name = _GOLLY_NAMES[result] + return (PRESETS.get(name) or FUNCS[name]())(nbhd), name return none(nbhd), 'none' @@ -125,7 +140,7 @@ def get_sym_type(nbhd, string): return resultant_sym -def _new_sym_type(nbhd, name, transformations, func=None): +def new_sym_type(nbhd, name, transformations, func=None): if func is None: method = getattr(Napkin, transformations[0]) args = transformations[1:] @@ -144,10 +159,17 @@ def compose(*funcs): @lru_cache() -def reflect(first, second=None): +def combine(*funcs): + return lru_cache()(lambda nbhd: reduce(Napkin.combine.__func__, [f(nbhd) for f in funcs])) + + +@lru_cache() +def reflect(first=None, second=None): + if first is None: + first = second = 'N' first = Coord.from_name(first) second = first if second is None else Coord.from_name(second) - return lru_cache()(lambda nbhd: _new_sym_type( + return lru_cache()(lambda nbhd: new_sym_type( nbhd, f'Reflect_{first.name}_{second.name}', ('reflections_across', (first, second)) # lambda self: self.reflections_across((first, second)) @@ -156,7 +178,7 @@ def reflect(first, second=None): @lru_cache() def rotate(n): - return lru_cache()(lambda nbhd: _new_sym_type( + return lru_cache()(lambda nbhd: new_sym_type( nbhd, f'Rotate_{n}', ('rotations_by', int(n)) # lambda self: self.rotations_by(int(n)) @@ -165,7 +187,7 @@ def rotate(n): @lru_cache() def permute(*cdirs): - return lru_cache()(lambda nbhd: _new_sym_type( + return lru_cache()(lambda nbhd: new_sym_type( nbhd, f"Permute_{'_'.join(cdirs) if cdirs else 'All'}", ('permutations', cdirs or None) # lambda self: self.permutations(cdirs or None) @@ -174,18 +196,25 @@ def permute(*cdirs): @lru_cache() def none(nbhd): - return _new_sym_type(nbhd, 'NoSymmetry', (), lambda self: [tuple(self)]) - - -PRESETS = { - 'rotate8reflect': compose(rotate(8), reflect('W')), - 'rotate8': rotate(8), - 'rotate4reflect': compose(rotate(4), reflect('W')), - 'rotate4': rotate(4), - 'reflect_horizontal': reflect('W'), - 'reflect_vertical': reflect('N'), - 'none': none -} + return new_sym_type(nbhd, 'NoSymmetry', (), lambda self: [tuple(self)]) + + +_hex = Neighborhood('hexagonal') +# 3.6-only: pep 468 +PRESETS = OrderedDict( + none=none, + reflect_vertical=reflect('W'), + reflect_horizontal=reflect('N'), + rotate2=rotate(2), + rotate3=rotate(3), + rotate4=rotate(4), + rotate4reflect=compose(rotate(4), reflect('N')), + rotate6=rotate(6), + rotate6reflect=compose(rotate(6), reflect('N')), + rotate8=rotate(8), + rotate8reflect=compose(rotate(8), reflect('N')) +) +_GOLLY_NAMES = {} FUNCS = { 'permute': permute, @@ -194,12 +223,18 @@ def none(nbhd): } _permute = permute() -_GOLLY_NAMES = {} -for nbhd_name, nbhd in [(name, Neighborhood(name)) for name in Neighborhood.GOLLY_NBHDS]: +_FORBIDDEN = {('hexagonal', 'reflect'), ('Moore', 'rotate2'), ('vonNeumann', 'rotate2'), ('oneDimensional', 'rotate2')} +for nbhd_name in Neighborhood.GOLLY_NBHDS: + nbhd = Neighborhood(nbhd_name) dummy = range(len(nbhd)) for sym_name, func in PRESETS.items(): + if sym_name == 'reflect_horizontal': + sym_name = 'reflect' + if sym_name == 'reflect_vertical' or (nbhd_name, sym_name) in _FORBIDDEN: + continue try: - _GOLLY_NAMES[func(nbhd)(dummy).expanded] = sym_name - except: - pass + sym = func(nbhd) + except Exception: + continue + _GOLLY_NAMES[sym(dummy).expanded] = sym_name _GOLLY_NAMES[_permute(nbhd)(dummy).expanded] = 'permute' From 6c3490e19a1f6e30d7401a9c12e6951c52856219 Mon Sep 17 00:00:00 2001 From: Eli Date: Fri, 28 Dec 2018 00:03:23 -0800 Subject: [PATCH 14/33] Integrate into transpiler, update examples/confirm brokenness See AlternatingPermuteTest.ruel for bork --- .../AlternatingPermuteTest.rule | 73 ++++++++ examples/compiled_ruletables/BeeZero.rule | 170 +++++++++--------- examples/compiled_ruletables/Brew.rule | 140 +++++++-------- .../compiled_ruletables/DeficientLife.rule | 52 +++--- examples/compiled_ruletables/ExtendedX.rule | 56 +++--- .../RockPaperScissors.rule | 2 +- examples/compiled_ruletables/Simpl.rule | 2 +- examples/compiled_ruletables/XHistory.rule | 66 +++---- examples/compiled_ruletables/bct.rule | 2 +- examples/compiled_ruletables/bf.rule | 2 +- examples/compiled_ruletables/bml.rule | 2 +- examples/compiled_ruletables/data_test.rule | 2 +- .../compiled_ruletables/deficientseeds.rule | 2 +- examples/compiled_ruletables/newtons.rule | 2 +- examples/compiled_ruletables/roed.rule | 2 +- .../nutshells/AlternatingPermuteTest.ruel | 50 ++++++ nutshell/__init__.py | 2 +- .../segment_types/table/_neighborhoods.py | 3 + nutshell/segment_types/table/_symutils.py | 103 +++++++++-- nutshell/segment_types/table/_transformer.py | 23 +-- nutshell/segment_types/table/table.py | 30 ++-- test.py | 17 +- 22 files changed, 497 insertions(+), 306 deletions(-) create mode 100644 examples/compiled_ruletables/AlternatingPermuteTest.rule create mode 100644 examples/nutshells/AlternatingPermuteTest.ruel diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule new file mode 100644 index 0000000..093c4d3 --- /dev/null +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -0,0 +1,73 @@ +@RULE AlternatingPermuteTest +******************************** +**** COMPILED FROM NUTSHELL **** +**** v0.6.0a **** +******************************** + +The correct table -- +neighborhood: Moore +symmetries: rotate4reflect +n_states: 4 + +var any.0 = {0,1,2,3} +var any.1 = any.0 +var any.2 = any.0 +var any.3 = any.0 +var any.4 = any.0 +var any.5 = any.0 +var any.6 = any.0 +var any.7 = any.0 +var t.0 = {1} +var h.0 = {2} +var h.1 = h.0 +var b.0 = {3} +var _a0.0 = {0,2,3} +var _a0.1 = _a0.0 +var _a0.2 = _a0.0 +var _a0.3 = _a0.0 + +#### symmetries: nutshell.AlternatingPermute +#### line 12: 0, h, t, any, b, any, any, any, any, any, h #### +0, any.0, any.1, any.2, any.3, any.4, b.0, h.0, t.0, h.1 +0, any.0, any.1, any.2, b.0, any.3, any.4, h.0, t.0, h.1 +0, any.0, any.1, any.2, b.0, any.3, t.0, h.0, any.4, h.1 +0, any.0, any.1, any.2, t.0, any.3, any.4, h.0, b.0, h.1 +0, any.0, any.1, any.2, t.0, any.3, b.0, h.0, any.4, h.1 +0, any.0, b.0, any.1, t.0, any.2, any.3, h.0, any.4, h.1 +#### line 13: 0, h, --t, any, --t, any, --t, any, --t, h #### +0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 +#### line 14: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### +2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 +1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 + +@TABLE +neighborhood: Moore +symmetries: rotate4reflect +n_states: 4 + +var any.0 = {0,1,2,3} +var any.1 = any.0 +var any.2 = any.0 +var any.3 = any.0 +var any.4 = any.0 +var any.5 = any.0 +var any.6 = any.0 +var any.7 = any.0 +var t.0 = {1} +var h.0 = {2} +var h.1 = h.0 +var b.0 = {3} +var _a0.0 = {0,2,3} +var _a0.1 = _a0.0 +var _a0.2 = _a0.0 +var _a0.3 = _a0.0 + +#### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) +#### line 12: 0, h, t, any, b, any, any, any, any, any, h #### +0, any.0, t.0, any.1, b.0, any.2, any.3, any.4, any.5, h.0 +0, any.0, t.0, any.1, any.2, any.3, b.0, any.4, any.5, h.0 +#### line 13: 0, h, --t, any, --t, any, --t, any, --t, h #### +0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +#### line 14: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### +2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 +1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index 3803c38..d7d8aad 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -1,7 +1,7 @@ @RULE BeeZero ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** Demo of kind-of-automatic B0 rule creation. Demonstrated rule is B017/S01. Can be changed to any Hensel-notation B0 rule by separating the B/S parts of its rulestring, @@ -26,109 +26,109 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1, 1, 1, 1, 2 -1, 0, 1, 1, 0, 1, 1, 1, 1, 2 -1, 0, 1, 0, 1, 1, 1, 1, 1, 2 -1, 1, 0, 1, 1, 1, 1, 1, 1, 2 1, 0, 1, 1, 1, 1, 1, 1, 1, 2 +1, 1, 1, 1, 1, 1, 1, 1, 0, 2 # Birth - ODD generations #### line 16: 0, <01 b0-odd / 2 / 0>; 1 #### -0, 2, 0, 2, 2, 2, 2, 2, 2, 1 0, 0, 2, 2, 2, 2, 2, 2, 2, 1 +0, 2, 2, 2, 2, 2, 2, 2, 0, 1 # Survival - ODD generations #### line 19: 2, <017 b0-odd / 2 / 0>; 1 #### -2, 2, 0, 2, 2, 2, 2, 2, 2, 1 2, 0, 2, 2, 2, 2, 2, 2, 2, 1 +2, 2, 2, 2, 2, 2, 2, 2, 0, 1 +2, 2, 0, 0, 0, 0, 0, 0, 0, 1 2, 0, 0, 0, 0, 0, 0, 0, 2, 1 -2, 0, 0, 0, 0, 0, 0, 2, 0, 1 #### line 21: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index a957a45..1583d75 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -1,7 +1,7 @@ @RULE Brew ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** From 83bismuth38. Extensible to any number of states by changing the 4 in `states: 4`. @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### +_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1 -_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1 -_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, 1, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 +_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### -1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 +1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1 -1, 1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1 -1, 1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1 -1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 -1, 1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, 1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1 -1, 1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 +1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, 2, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2 -2, 2, _b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 -2, _b0.0, 2, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, 2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2 -2, 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2 -2, 2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3, 3 _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, 3, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 -_c0.0, 3, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 -3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 +3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, 3 3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 -3, 3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, 3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3 -3, 3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3 -3, 3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 -3, 3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index 34d65ed..7b7e0d5 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -1,7 +1,7 @@ @RULE DeficientLife ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** @TABLE @@ -55,45 +55,45 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, 0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 2 +0, 0, _a0.0, 0, 0, 0, _a0.1, 0, _a0.2, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### -0, 0, 0, _b0.0, 0, _b0.1, 0, _b0.2, 0, 3 +0, _b0.0, 0, _b0.1, 0, 0, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### 0, 0, 0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### -0, 0, 0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 5 +0, _d0.0, 0, 0, 0, 0, 0, _d0.1, _d0.2, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### -0, 0, 0, 0, 0, 0, _e0.0, _e0.1, _e0.2, 6 +0, _e0.0, _e0.1, 0, 0, 0, 0, 0, _e0.2, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### -0, 0, 0, 0, _f0.0, 0, _f0.1, _f0.2, 0, 7 +0, 0, _f0.0, _f0.1, 0, 0, 0, 0, _f0.2, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, 0, 0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 8 +0, 0, _g0.0, 0, 0, _g0.1, 0, 0, _g0.2, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, 0, 0, 0, _h0.0, _h0.1, 0, 0, _h0.2, 9 +0, _h0.0, 0, 0, _h0.1, 0, 0, 0, _h0.2, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### -0, 0, 0, 0, _i0.0, _i0.1, 0, _i0.2, 0, 10 +0, _i0.0, 0, _i0.1, 0, 0, 0, 0, _i0.2, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, 0, 0, _j0.0, 0, 0, _j0.1, _j0.2, 0, 11 +0, _j0.0, 0, 0, 0, _j0.1, 0, 0, _j0.2, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, 0, 0, 0, 0, 0, 0, live.1, live.2, 1 # s2 -live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 -live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 -live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 -live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 # s2 +live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 +live.0, live.1, 0, 0, live.2, 0, 0, 0, 0, 1 +live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 +live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, 0, 0, 0, 0, 0, live.1, live.2, live.3, 1 # s3 -live.0, 0, 0, 0, 0, live.1, 0, live.2, live.3, 1 -live.0, 0, 0, 0, 0, live.1, live.2, 0, live.3, 1 -live.0, 0, 0, 0, 0, live.1, live.2, live.3, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, live.2, live.3, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, live.3, 1 -live.0, 0, 0, live.1, 0, 0, 0, live.2, live.3, 1 -live.0, 0, 0, live.1, 0, 0, live.2, 0, live.3, 1 -live.0, 0, 0, live.1, 0, live.2, 0, 0, live.3, 1 -live.0, 0, 0, live.1, 0, live.2, 0, live.3, 0, 1 +live.0, live.1, live.2, live.3, 0, 0, 0, 0, 0, 1 # s3 +live.0, live.1, live.2, 0, live.3, 0, 0, 0, 0, 1 +live.0, live.1, live.2, 0, 0, live.3, 0, 0, 0, 1 +live.0, live.1, live.2, 0, 0, 0, live.3, 0, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, live.3, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, 0, live.3, 1 +live.0, live.1, 0, live.2, 0, live.3, 0, 0, 0, 1 +live.0, live.1, 0, live.2, 0, 0, live.3, 0, 0, 1 +live.0, live.1, 0, 0, live.2, 0, live.3, 0, 0, 1 +live.0, 0, live.1, 0, live.2, 0, live.3, 0, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index 420ed7f..56eff23 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -1,7 +1,7 @@ @RULE ExtendedX ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** Template for "extended" rules, in the vein of extendedlife. @@ -41,40 +41,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, off.0, off.1, off.2, off.3, off.4, on.0, on.1, on.2, 1 -0, off.0, off.1, off.2, on.0, on.1, off.3, off.4, on.2, 1 -0, off.0, off.1, on.0, off.2, off.3, on.1, on.2, off.4, 1 -0, off.0, off.1, on.0, off.2, off.3, on.1, off.4, on.2, 1 -0, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 -0, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 -0, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 -0, off.0, off.1, off.2, on.0, off.3, on.1, on.2, off.4, 1 +0, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 +0, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +0, on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 -0, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 +0, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 +0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +0, off.0, on.0, off.1, off.2, off.3, on.1, off.4, on.2, 1 +0, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +0, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 #### line 21: 0, birth ~ 1, any; 1 #### -0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, birth.0, 1 -0, any.0, any.1, any.2, any.3, any.4, any.5, birth.0, any.6, 1 +0, birth.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 +0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### -1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, death.0, 0 -1, any.0, any.1, any.2, any.3, any.4, any.5, death.0, any.6, 0 +1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 +1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, off.0, off.1, off.2, off.3, off.4, on.0, on.1, off.5, 1 -1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 +1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 -1, off.0, off.1, off.2, off.3, off.4, on.0, off.5, on.1, 1 -1, off.0, off.1, off.2, on.0, off.3, off.4, on.1, off.5, 1 -1, off.0, off.1, off.2, off.3, on.0, off.4, on.1, off.5, 1 -1, off.0, off.1, off.2, off.3, off.4, on.0, on.1, on.2, 1 -1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, on.2, 1 -1, off.0, off.1, on.0, off.2, off.3, on.1, on.2, off.4, 1 -1, off.0, off.1, on.0, off.2, off.3, on.1, off.4, on.2, 1 -1, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 -1, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 -1, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 -1, off.0, off.1, off.2, on.0, off.3, on.1, on.2, off.4, 1 +1, off.0, off.1, on.0, off.2, off.3, off.4, off.5, on.1, 1 +1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 +1, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 +1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 +1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, on.2, 1 +1, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +1, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/RockPaperScissors.rule b/examples/compiled_ruletables/RockPaperScissors.rule index bcf74f4..3a4bf95 100644 --- a/examples/compiled_ruletables/RockPaperScissors.rule +++ b/examples/compiled_ruletables/RockPaperScissors.rule @@ -1,7 +1,7 @@ @RULE RockPaperScissors ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** From "RockScissorsPaperLife" by Dave Greene. diff --git a/examples/compiled_ruletables/Simpl.rule b/examples/compiled_ruletables/Simpl.rule index cfa6635..56dc1a6 100644 --- a/examples/compiled_ruletables/Simpl.rule +++ b/examples/compiled_ruletables/Simpl.rule @@ -1,7 +1,7 @@ @RULE Simpl ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** From "Simpl" by _zM. diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index 20f5307..348a7b8 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -1,7 +1,7 @@ @RULE XHistory ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** Template for History rules. (LifeHistory by default in Nutshell’s examples/ directory) @@ -63,26 +63,26 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 1 -4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, on.2, _b0.4, 1 -4, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 -4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 1 -4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, _b0.3, on.0, on.1, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, on.0, on.1, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, on.2, _b0.4, 1 +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 _e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 +4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 1 +4, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### 1, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 @@ -91,22 +91,22 @@ _g0.0, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 _g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, off.5, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, on.2, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, off.5, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, off.4, on.2, off.5, on.0 -on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, on.3, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, on.3, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, on.2, on.3, off.4, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, on.3, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, on.3, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, off.3, on.3, off.4, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, on.2, on.3, off.4, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, on.2, on.3, off.4, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, off.5, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, on.3, off.4, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, off.1, on.2, off.2, off.3, off.4, on.3, on.0 on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, on.3, on.0 +on.0, off.0, on.1, on.2, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, on.3, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/examples/compiled_ruletables/bct.rule b/examples/compiled_ruletables/bct.rule index 61551cd..245a691 100644 --- a/examples/compiled_ruletables/bct.rule +++ b/examples/compiled_ruletables/bct.rule @@ -1,7 +1,7 @@ @RULE bct ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** An implementation of bitwise cyclic tag. diff --git a/examples/compiled_ruletables/bf.rule b/examples/compiled_ruletables/bf.rule index e8258f8..8d8108e 100644 --- a/examples/compiled_ruletables/bf.rule +++ b/examples/compiled_ruletables/bf.rule @@ -1,7 +1,7 @@ @RULE bf ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** Brainfuck. diff --git a/examples/compiled_ruletables/bml.rule b/examples/compiled_ruletables/bml.rule index ccf20a7..26c8094 100644 --- a/examples/compiled_ruletables/bml.rule +++ b/examples/compiled_ruletables/bml.rule @@ -1,7 +1,7 @@ @RULE bml ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** The Biham–Middleton–Levine traffic model. diff --git a/examples/compiled_ruletables/data_test.rule b/examples/compiled_ruletables/data_test.rule index b14f693..ceed6c4 100644 --- a/examples/compiled_ruletables/data_test.rule +++ b/examples/compiled_ruletables/data_test.rule @@ -1,7 +1,7 @@ @RULE data_test ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** 1: Data diff --git a/examples/compiled_ruletables/deficientseeds.rule b/examples/compiled_ruletables/deficientseeds.rule index db5ca0a..f911b98 100644 --- a/examples/compiled_ruletables/deficientseeds.rule +++ b/examples/compiled_ruletables/deficientseeds.rule @@ -1,7 +1,7 @@ @RULE DeficientSeeds ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** 1 c 2 e diff --git a/examples/compiled_ruletables/newtons.rule b/examples/compiled_ruletables/newtons.rule index a5ee2dc..56fc3e3 100644 --- a/examples/compiled_ruletables/newtons.rule +++ b/examples/compiled_ruletables/newtons.rule @@ -1,7 +1,7 @@ @RULE NewTons ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** By BlinkerSpawn 0 vacuum diff --git a/examples/compiled_ruletables/roed.rule b/examples/compiled_ruletables/roed.rule index 7a0995c..6b0c5df 100644 --- a/examples/compiled_ruletables/roed.rule +++ b/examples/compiled_ruletables/roed.rule @@ -1,7 +1,7 @@ @RULE roed ******************************** **** COMPILED FROM NUTSHELL **** -**** v0.5.5 **** +**** v0.6.0a **** ******************************** http://esolangs.org/wiki/Roie diff --git a/examples/nutshells/AlternatingPermuteTest.ruel b/examples/nutshells/AlternatingPermuteTest.ruel new file mode 100644 index 0000000..022c3e7 --- /dev/null +++ b/examples/nutshells/AlternatingPermuteTest.ruel @@ -0,0 +1,50 @@ +@NUTSHELL AlternatingPermuteTest + +The correct table -- +neighborhood: Moore +symmetries: rotate4reflect +n_states: 4 + +var any.0 = {0,1,2,3} +var any.1 = any.0 +var any.2 = any.0 +var any.3 = any.0 +var any.4 = any.0 +var any.5 = any.0 +var any.6 = any.0 +var any.7 = any.0 +var t.0 = {1} +var h.0 = {2} +var h.1 = h.0 +var b.0 = {3} +var _a0.0 = {0,2,3} +var _a0.1 = _a0.0 +var _a0.2 = _a0.0 +var _a0.3 = _a0.0 + +#### symmetries: nutshell.AlternatingPermute +#### line 12: 0, h, t, any, b, any, any, any, any, any, h #### +0, any.0, any.1, any.2, any.3, any.4, b.0, h.0, t.0, h.1 +0, any.0, any.1, any.2, b.0, any.3, any.4, h.0, t.0, h.1 +0, any.0, any.1, any.2, b.0, any.3, t.0, h.0, any.4, h.1 +0, any.0, any.1, any.2, t.0, any.3, any.4, h.0, b.0, h.1 +0, any.0, any.1, any.2, t.0, any.3, b.0, h.0, any.4, h.1 +0, any.0, b.0, any.1, t.0, any.2, any.3, h.0, any.4, h.1 +#### line 13: 0, h, --t, any, --t, any, --t, any, --t, h #### +0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 +#### line 14: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### +2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 +1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 + +@TABLE +states: 4 + +t=(1) +h=(2) +b=(3) + +symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) + +0, h, t, any, b, any, any, any, any, any, h +0, h, --t, any, --t, any, --t, any, --t, h +(h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] \ No newline at end of file diff --git a/nutshell/__init__.py b/nutshell/__init__.py index 4d6f0e1..58b46c5 100644 --- a/nutshell/__init__.py +++ b/nutshell/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.5.5' +__version__ = '0.6.0a' from .common import * from .segment_types.table import _napkins as napkin from .segment_types.table._napkins import Napkin, OrthNapkin, HexNapkin diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 833a5ba..5fa5a06 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -65,6 +65,9 @@ def __hash__(self): def get(self, item, default=None): return self.idxes.get(item, default) + def items(self): + return self.idxes.items() + def to_list(self, blank='.'): return [[str(self.get(cdir, blank)) for cdir in row] for row in (('NW', 'N', 'NE'), ('W', 'C', 'E'), ('SW', 'S', 'SE'))] diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 2024ab8..7223218 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,16 +1,18 @@ from collections import OrderedDict -from functools import reduce, lru_cache -from importlib import import_module +from functools import lru_cache, reduce, partial +from math import ceil from operator import and_ as bitwise_and -from nutshell.common import symmetries as ext_symmetries, utils +from nutshell.common.utils import multisplit from ._neighborhoods import Neighborhood -from ._classes import Coord +from ._classes import Coord, InlineBinding class Napkin(tuple): nbhd = None transformations = None + nested_transformations = None + tilde = None _RECENTS = {} def __init__(self, _): @@ -58,7 +60,8 @@ def compose(cls, other): cls.nbhd, f'{cls.__name__}+{other.__name__}', cls.transformations + other.transformations, - lambda self: [j for i in other.expand(self) for j in cls.expand(self.__class__(i))] + lambda self: [j for i in other.expand(self) for j in cls.expand(self.__class__(i))], + nested_transformations=cls.nested_transformations | other.nested_transformations ) @classmethod @@ -69,7 +72,8 @@ def combine(cls, other): cls.nbhd, f'{cls.__name__}/{other.__name__}', cls.transformations + other.transformations, - lambda self: [*other.expand(self), *cls.expand(self)] + lambda self: [*other.expand(self), *cls.expand(self)], + nested_transformations=frozenset((cls.nested_transformations, other.nested_transformations)) ) @classmethod @@ -91,7 +95,7 @@ def permutations(self, *args): return self._convert(self.nbhd.permutations(*args, as_cls=False)) -def find_min_sym_type(symmetries, nbhd): +def find_golly_sym_type(symmetries, nbhd): dummy = range(len(nbhd)) result = reduce( bitwise_and, @@ -109,13 +113,14 @@ def find_min_sym_type(symmetries, nbhd): if result in _GOLLY_NAMES: name = _GOLLY_NAMES[result] return (PRESETS.get(name) or FUNCS[name]())(nbhd), name + print(result) return none(nbhd), 'none' def get_sym_type(nbhd, string): current = [] all_syms = [[]] - for token in utils.multisplit(string, (None, *'(),')): + for token in multisplit(string, (None, *'(),')): if token == '/': if current: all_syms[-1].append(current) @@ -140,16 +145,20 @@ def get_sym_type(nbhd, string): return resultant_sym -def new_sym_type(nbhd, name, transformations, func=None): +def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_transformations=None): if func is None: method = getattr(Napkin, transformations[0]) args = transformations[1:] func = lambda self: method(self, *args) - transformations = [transformations] + transformations = (transformations,) + if nested_transformations is None: + nested_transformations = frozenset(transformations) return type(name, (Napkin,), { 'expand': func, 'transformations': transformations, - 'nbhd': nbhd + 'nested_transformations': nested_transformations, + 'nbhd': nbhd, + 'tilde': tilde, }) @@ -171,7 +180,7 @@ def reflect(first=None, second=None): second = first if second is None else Coord.from_name(second) return lru_cache()(lambda nbhd: new_sym_type( nbhd, - f'Reflect_{first.name}_{second.name}', + f'Reflect({first.name} {second.name})', ('reflections_across', (first, second)) # lambda self: self.reflections_across((first, second)) )) @@ -180,17 +189,18 @@ def reflect(first=None, second=None): def rotate(n): return lru_cache()(lambda nbhd: new_sym_type( nbhd, - f'Rotate_{n}', + f'Rotate({n})', ('rotations_by', int(n)) # lambda self: self.rotations_by(int(n)) )) @lru_cache() -def permute(*cdirs): +def permute(*cdirs, explicit=False): return lru_cache()(lambda nbhd: new_sym_type( nbhd, - f"Permute_{'_'.join(cdirs) if cdirs else 'All'}", - ('permutations', cdirs or None) # lambda self: self.permutations(cdirs or None) + f"Permute({' '.join(cdirs) if cdirs else 'All'})", + ('permutations', cdirs or None), # lambda self: self.permutations(cdirs or None) + tilde=permute_tilde_explicit if explicit or len(cdirs) == len(nbhd) else permute_tilde )) @@ -199,6 +209,66 @@ def none(nbhd): return new_sym_type(nbhd, 'NoSymmetry', (), lambda self: [tuple(self)]) +def permute_tilde_explicit(self, values): + new = [] + for v, count in values: + if count is None: + count = '1' + if not count.isdigit(): + raise Exception(f"{v} ~ {count}; '{count}' is not a number") + new.extend([v] * int(count)) + if len(new) < len(self.nbhd): + raise Exception(f'Expected {len(self.nbhd)} terms, got {len(new)}') + return new + + +def permute_tilde(self, values): + """ + Given a shorthand permutationally-symmetrical transition: + length=8 (Moore neighborhood) + ------- + 1, 0 + 1~4, 0~4 + 1~4, 0 + 1~3, 1, 0, 0 + Return its expanded representation: + 1, 1, 1, 1, 0, 0, 0, 0 + Order is not preserved. + """ + length = len(self.nbhd) + # filler algo courtesy of Thomas Russell on math.stackexchange + # https://math.stackexchange.com/a/1081084 + filler = _fill( + length, + # How many cells filled + length - sum(int(i) for _, i in values if i), + # And how many empty slots left to fill + sum(1 for _, i in values if not i) + ) + return list(_AccumulativeContainer( + (val.set(idx) if isinstance(val, InlineBinding) else val, next(filler) if num is None else int(num)) + for idx, (val, num) in enumerate(values, 1) + )) + + +def _fill(length, tally, empties): + """Only in its own function to be able to raise error on 0""" + for k in range(1, 1 + empties): + v = ceil((tally - k + 1) / empties) + if v == 0: + raise ValueError(f'Too many terms given (expected no more than {length})') + yield v + + +class _AccumulativeContainer(list): + def __init__(self, it): + for thing, count in it: + self.append((thing, 1 if count is None else count)) + + def __iter__(self): + return (i.give() if isinstance(i, InlineBinding) else i for k, v in super().__iter__() for i in [k]*v) + + _hex = Neighborhood('hexagonal') # 3.6-only: pep 468 PRESETS = OrderedDict( @@ -218,6 +288,7 @@ def none(nbhd): FUNCS = { 'permute': permute, + 'explicit_permute': partial(permute, explicit=True), 'reflect': reflect, 'rotate': rotate, } diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segment_types/table/_transformer.py index 596ab77..7c37fef 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segment_types/table/_transformer.py @@ -3,7 +3,6 @@ from inspect import signature from importlib import import_module from itertools import chain, repeat -from operator import attrgetter from pkg_resources import resource_filename import bidict @@ -17,13 +16,6 @@ SPECIALS = {'...', '_', 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'} Meta = namedtuple('Meta', ['lno', 'start', 'end']) -try: - with open(resource_filename('nutshell', 'segment_types/table/lark_assets/grammar.lark')) as f: - NUTSHELL_GRAMMAR = f.read() -except FileNotFoundError: - with open('nutshell/segment_types/table/lark_assets/grammar.lark') as f: - NUTSHELL_GRAMMAR = f.read() - def fix(meta): if isinstance(meta, tuple): @@ -80,18 +72,17 @@ def kill_string(self, val, meta, li=False): def kill_strings(self, val, meta): return [self.kill_string(i, meta) for i in val] - def special_transform(self, initial, resultant, napkin): + def tilde_transform(self, initial, resultant, napkin): """ - Handle the special ~ syntax for current symmetries + Handle the tilde ~ syntax for current symmetries """ special_params = { - 'length': self._tbl.trlen, 'initial': initial, 'resultant': resultant, 'values': napkin, }.items() - params = signature(self._tbl.symmetries.special).parameters - return self._tbl.symmetries.special(**{k: v for k, v in special_params if k in params}) + params = signature(self._tbl.symmetries.tilde).parameters + return self._tbl.symmetries.tilde(self._tbl.symmetries, **{k: v for k, v in special_params if k in params}) def unravel_permute(self, tree, meta): if isinstance(tree, tuple): @@ -183,7 +174,7 @@ def var_decl(self, meta, name, var): def permute_shorthand(self, children, meta): state, *permute = children - if not hasattr(self._tbl.symmetries, 'special'): + if self._tbl.symmetries.tilde is None: if permute: raise SyntaxErr( fix(meta), @@ -211,10 +202,10 @@ def main(self, children, meta): resultant = self.kill_string(resultant, meta) except UndefinedErr as e: raise UndefinedErr((meta.line, meta.end_column - len(str(resultant)), meta.end_column), e.msg) - if hasattr(self._tbl.symmetries, 'special'): + if self._tbl.symmetries.tilde is not None: seq = [self.unravel_permute(i, meta) for i in children] try: - napkin = dict(enumerate(self.special_transform(initial, resultant, seq), 1)) + napkin = dict(enumerate(self.tilde_transform(initial, resultant, seq), 1)) except Exception as e: raise Error( fix(meta), diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index c90c87f..65a5fef 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -9,11 +9,11 @@ from nutshell.cli import cli from nutshell.common.classes import TableRange -from nutshell.common.utils import printv, printq +from nutshell.common.utils import printq, multisplit from nutshell.common import macros from nutshell.common.errors import * from .lark_assets import parser as lark_standalone -from ._transformer import Preprocess, NUTSHELL_GRAMMAR +from ._transformer import Preprocess from ._classes import VarName, StateList from . import _symutils as symutils, _neighborhoods as nbhoods @@ -63,7 +63,7 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): self.current_macros = [] self._prepped_macros = {} self.available_macros = macros.__dict__.copy() - + self.specials = {'any': VarName('any'), 'live': VarName('live')} self.new_varname = VarName.new_generator() @@ -92,17 +92,12 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): self.update_special_vars() self._data = transformer.transform(_parsed) - if len(self.sym_types) <= 1 and not hasattr(next(iter(self.sym_types), None), 'fallback'): - sym = next(iter(self.sym_types), None) - if sym is not None: - # force these to be equal (in the event of, say, inline-rulestring - # napkins' having been used, which don't update directives) - self.directives['symmetries'] = sym.name[0] if hasattr(sym, 'name') else sym.__name__.lower() + MinSym, name = symutils.find_golly_sym_type(self.sym_types, self.neighborhood) + if len(self.sym_types) <= 1 and self.symmetries.nested_transformations == MinSym.nested_transformations: self.final = [t.fix_vars() for t in self._data] else: - MinSym = symutils.find_min_sym_type(self.sym_types, self.trlen) - self.directives['symmetries'] = MinSym.name[0] if hasattr(MinSym, 'name') else MinSym.__name__.lower() self.final = [new_tr for tr in self._data for new_tr in tr.in_symmetry(MinSym)] + self.directives['symmetries'] = name self.directives['n_states'] = self.directives.pop('states') self._apply_macros() @@ -161,7 +156,7 @@ def neighborhood(self): @neighborhood.setter def neighborhood(self, val): if CUSTOM_NBHD.fullmatch(val): - nbhd = val.split(',') + nbhd = multisplit(val, (None, ',')) if len(nbhd) != len(set(nbhd)): raise ValueError('Duplicate compass directions in neighborhood') self._nbhd = nbhoods.Neighborhood(nbhd) @@ -206,11 +201,8 @@ def update_special_vars(self, value=None): self.vars[self.specials['any']] = StateList(range(self.n_states), context=None) self.vars[self.specials['live']] = StateList(range(1, self.n_states), context=None) - def add_sym_type(self, name): - try: - self.sym_types.add(symutils.get_sym_type(name)) - except (ImportError, ModuleNotFoundError): - raise ImportError(f'No symmetry type {name!r} found') + def add_sym_type(self, string): + self.sym_types.add(symutils.get_sym_type(self.neighborhood, string)) def add_macros(self, path): with open(path) as f: @@ -247,7 +239,7 @@ def _apply_macros(self): def check_cdir(self, cdir, meta, *, return_int=True, enforce_int=False): if cdir in ('FG', 'BG'): raise SyntaxErr(meta, f'Invalid reference {cdir!r} outside of inline-rulestring transition') - if enforce_int and hasattr(self.symmetries, 'special') and not cdir.isdigit(): + if enforce_int and self.symmetries.tilde is not None and not cdir.isdigit(): raise SyntaxErr( meta, f"Compass directions have no meaning under {self.directives['symmetries']} symmetry. " @@ -256,7 +248,7 @@ def check_cdir(self, cdir, meta, *, return_int=True, enforce_int=False): try: if return_int: return int(cdir) if cdir.isdigit() else self.neighborhood[str(cdir)] - return int(cdir != '0') and self.neighborhood.inv[int(cdir)] if cdir.isdigit() else str(cdir) + return int(cdir != '0') and self.neighborhood.cdir_at(int(cdir)) if cdir.isdigit() else str(cdir) except KeyError: pre = 'Transition index' if cdir.isdigit() else 'Compass direction' raise ReferenceErr( diff --git a/test.py b/test.py index 13257b6..f970231 100755 --- a/test.py +++ b/test.py @@ -9,6 +9,7 @@ from nutshell.cli import cli from nutshell.main import transpile, write_rule from nutshell.common.utils import RAND_SEED, random as nutshell_rand +from nutshell.common.errors import NutshellException ARGV = sys.argv + [None, None][len(sys.argv):] wtf = cli.commands['transpile'] @@ -17,10 +18,14 @@ preserve_comments=True ) + def test_codecov(): for fname in list(os.walk('./examples/nutshells'))[0][2]: with open('./examples/nutshells/' + fname) as fp: - transpile(fp) + try: + transpile(fp) + except NutshellException as e: + raise SystemExit(e.code) if __name__ == '__main__': @@ -33,11 +38,17 @@ def test_codecov(): for fname in walk: print(fname) if len(ARGV) < 3 or fname.split('.')[0] in ARGV[2:]: - write_rule(infiles=['./examples/nutshells/' + fname], outdirs=['./examples/compiled_ruletables/'], find=False) + try: + write_rule(infiles=['./examples/nutshells/' + fname], outdirs=['./examples/compiled_ruletables/'], find=False) + except NutshellException as e: + raise SystemExit(e.code) nutshell_rand.seed(RAND_SEED) else: for fname in walk: if len(ARGV) < 3 or fname.split('.')[0] in ARGV[2:]: with open('./examples/nutshells/' + fname) as fp: - transpile(fp) + try: + transpile(fp) + except NutshellException as e: + raise SystemExit(e.code) nutshell_rand.seed(RAND_SEED) From 522fb27375962af607eafdb6f372e21afcaa1ec0 Mon Sep 17 00:00:00 2001 From: Eli Date: Fri, 28 Dec 2018 12:02:56 -0800 Subject: [PATCH 15/33] Passable speed improvements (10m -> 1m for examples/) --- .../AlternatingPermuteTest.rule | 13 +-- examples/compiled_ruletables/BeeZero.rule | 80 +++++++++---------- examples/compiled_ruletables/Brew.rule | 66 +++++++-------- .../compiled_ruletables/DeficientLife.rule | 17 ++-- examples/compiled_ruletables/ExtendedX.rule | 22 ++--- examples/compiled_ruletables/XHistory.rule | 40 +++++----- nutshell/segment_types/table/_symutils.py | 34 +++++--- 7 files changed, 140 insertions(+), 132 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 093c4d3..3f16037 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -40,9 +40,10 @@ var _a0.3 = _a0.0 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 + @TABLE neighborhood: Moore -symmetries: rotate4reflect +symmetries: none n_states: 4 var any.0 = {0,1,2,3} @@ -63,11 +64,13 @@ var _a0.2 = _a0.0 var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) -#### line 12: 0, h, t, any, b, any, any, any, any, any, h #### +#### line 48: 0, h, t, any, b, any, any, any, any, any, h #### 0, any.0, t.0, any.1, b.0, any.2, any.3, any.4, any.5, h.0 -0, any.0, t.0, any.1, any.2, any.3, b.0, any.4, any.5, h.0 -#### line 13: 0, h, --t, any, --t, any, --t, any, --t, h #### +#### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### 0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 -#### line 14: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### +0, any.0, _a0.0, h.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +0, any.0, _a0.0, any.1, _a0.1, h.0, _a0.2, any.2, _a0.3, h.1 +0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 +#### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index d7d8aad..821e151 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -26,98 +26,98 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations #### line 10: 0, <017 !hensel / 1 / 0>; 2 #### -0, 1, 0, 0, 0, 0, 0, 1, 0, 2 -0, 1, 0, 0, 0, 0, 0, 0, 1, 2 -0, 0, 1, 0, 0, 0, 0, 0, 1, 2 0, 0, 0, 0, 1, 0, 0, 0, 1, 2 0, 0, 0, 1, 0, 0, 0, 0, 1, 2 +0, 1, 0, 0, 0, 0, 0, 0, 1, 2 0, 1, 0, 0, 0, 1, 0, 0, 0, 2 -0, 1, 0, 1, 0, 0, 0, 1, 0, 2 -0, 1, 0, 0, 0, 0, 0, 1, 1, 2 +0, 1, 0, 0, 0, 0, 0, 1, 0, 2 +0, 0, 1, 0, 0, 0, 0, 0, 1, 2 0, 1, 0, 0, 0, 1, 0, 0, 1, 2 0, 0, 0, 1, 0, 1, 0, 0, 1, 2 +0, 1, 0, 0, 0, 0, 0, 1, 1, 2 0, 1, 1, 0, 0, 0, 0, 0, 1, 2 +0, 1, 0, 0, 1, 0, 0, 0, 1, 2 +0, 1, 0, 1, 0, 0, 0, 1, 0, 2 0, 1, 0, 1, 0, 0, 0, 0, 1, 2 +0, 0, 1, 1, 0, 0, 0, 0, 1, 2 0, 0, 1, 0, 0, 1, 0, 0, 1, 2 0, 0, 1, 0, 0, 0, 1, 0, 1, 2 -0, 1, 0, 0, 1, 0, 0, 0, 1, 2 -0, 0, 1, 1, 0, 0, 0, 0, 1, 2 -0, 1, 0, 1, 0, 1, 0, 1, 0, 2 -0, 1, 1, 1, 0, 0, 0, 0, 1, 2 -0, 1, 0, 1, 1, 0, 0, 0, 1, 2 0, 1, 0, 1, 0, 0, 0, 1, 1, 2 0, 0, 1, 0, 0, 1, 0, 1, 1, 2 +0, 1, 1, 1, 0, 0, 0, 0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, 1, 1, 1, 1, 1, 1, 0, 2 # Birth - ODD generations diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index 1583d75..e7d6ecb 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 -3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index 7b7e0d5..e346c16 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -21,7 +21,6 @@ var any.8 = any.0 var live.0 = {1,2,3,4,5,6,7,8,9,10,11} var live.1 = live.0 var live.2 = live.0 -var live.3 = live.0 var _a0.0 = {1,3,4,5,6,7,8,9,10,11} var _a0.1 = _a0.0 var _a0.2 = _a0.0 @@ -84,16 +83,12 @@ live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, live.1, live.2, live.3, 0, 0, 0, 0, 0, 1 # s3 -live.0, live.1, live.2, 0, live.3, 0, 0, 0, 0, 1 -live.0, live.1, live.2, 0, 0, live.3, 0, 0, 0, 1 -live.0, live.1, live.2, 0, 0, 0, live.3, 0, 0, 1 -live.0, live.1, live.2, 0, 0, 0, 0, live.3, 0, 1 -live.0, live.1, live.2, 0, 0, 0, 0, 0, live.3, 1 -live.0, live.1, 0, live.2, 0, live.3, 0, 0, 0, 1 -live.0, live.1, 0, live.2, 0, 0, live.3, 0, 0, 1 -live.0, live.1, 0, 0, live.2, 0, live.3, 0, 0, 1 -live.0, 0, live.1, 0, live.2, 0, live.3, 0, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 # s3 +live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 +live.0, live.1, 0, 0, live.2, 0, 0, 0, 0, 1 +live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 +live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index 56eff23..218a16a 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,16 +41,16 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 -0, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 0, on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +0, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 +0, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +0, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 0, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 +0, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 0, off.0, on.0, off.1, off.2, off.3, on.1, off.4, on.2, 1 -0, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -0, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 #### line 21: 0, birth ~ 1, any; 1 #### 0, birth.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 @@ -59,22 +59,22 @@ var death.0 = {3,4} 1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 -1, on.0, off.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 -1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 1, off.0, off.1, on.0, off.2, off.3, off.4, off.5, on.1, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 -1, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 -1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 +1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 +1, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +1, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 +1, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, on.2, 1 -1, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -1, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index 348a7b8..06538ba 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,24 +63,24 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 _e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 3 _e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 1 -4, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 _e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 4, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 _e0.0, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 # Death on touching a boundary cell @@ -92,20 +92,20 @@ _g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, off.5, on.2, on.0 on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, off.5, on.0 on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, on.1, off.0, off.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, on.1, off.0, on.2, off.1, off.2, off.3, on.3, off.4, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, on.1, off.0, off.1, on.2, off.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, on.3, on.0 on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, on.3, on.0 -on.0, off.0, on.1, on.2, off.1, off.2, off.3, off.4, on.3, on.0 on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, off.1, on.2, off.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, on.3, off.4, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, on.2, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, on.3, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 7223218..0d6b5c7 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -9,6 +9,7 @@ class Napkin(tuple): + _hash_func = None nbhd = None transformations = None nested_transformations = None @@ -39,13 +40,21 @@ def __eq__(self, other): def __repr__(self): return f'{self.__class__.__name__}{super().__repr__()}' - def expand(self): - raise NotImplementedError('Please override method `expand()` in Napkin subclass') + def expand(self, cls=None): + if cls is None: + cls = self.__class__ + searchable = cls._hash_func(self) + if searchable not in cls._RECENTS: + cls._RECENTS[searchable] = cls._expand(self) + return cls._RECENTS[searchable] + + def _expand(self): + raise NotImplementedError('Please override method `_expand()` in Napkin subclass') @property def expanded(self): if self._expanded is None: - self._expanded = frozenset(self.expand()) + self._expanded = frozenset(self._expand()) return self._expanded @property @@ -60,7 +69,7 @@ def compose(cls, other): cls.nbhd, f'{cls.__name__}+{other.__name__}', cls.transformations + other.transformations, - lambda self: [j for i in other.expand(self) for j in cls.expand(self.__class__(i))], + lambda self: [j for i in other.expand(self, other) for j in cls.expand(self.__class__(i), cls)], nested_transformations=cls.nested_transformations | other.nested_transformations ) @@ -72,7 +81,7 @@ def combine(cls, other): cls.nbhd, f'{cls.__name__}/{other.__name__}', cls.transformations + other.transformations, - lambda self: [*other.expand(self), *cls.expand(self)], + lambda self: [*other.expand(self, other), *cls.expand(self, cls)], nested_transformations=frozenset((cls.nested_transformations, other.nested_transformations)) ) @@ -113,7 +122,6 @@ def find_golly_sym_type(symmetries, nbhd): if result in _GOLLY_NAMES: name = _GOLLY_NAMES[result] return (PRESETS.get(name) or FUNCS[name]())(nbhd), name - print(result) return none(nbhd), 'none' @@ -145,20 +153,21 @@ def get_sym_type(nbhd, string): return resultant_sym -def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_transformations=None): +def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_transformations=None, hash_func=tuple): if func is None: method = getattr(Napkin, transformations[0]) - args = transformations[1:] - func = lambda self: method(self, *args) + method_args = transformations[1:] + func = lambda self: method(self, *method_args) transformations = (transformations,) if nested_transformations is None: nested_transformations = frozenset(transformations) return type(name, (Napkin,), { - 'expand': func, + '_expand': func, 'transformations': transformations, 'nested_transformations': nested_transformations, 'nbhd': nbhd, 'tilde': tilde, + '_hash_func': hash_func }) @@ -200,13 +209,14 @@ def permute(*cdirs, explicit=False): nbhd, f"Permute({' '.join(cdirs) if cdirs else 'All'})", ('permutations', cdirs or None), # lambda self: self.permutations(cdirs or None) - tilde=permute_tilde_explicit if explicit or len(cdirs) == len(nbhd) else permute_tilde + tilde=permute_tilde_explicit if explicit or len(cdirs) == len(nbhd) else permute_tilde, + hash_func=frozenset )) @lru_cache() def none(nbhd): - return new_sym_type(nbhd, 'NoSymmetry', (), lambda self: [tuple(self)]) + return new_sym_type(nbhd, 'NoSymmetry', (), lambda self, **_: [tuple(self)]) def permute_tilde_explicit(self, values): From 60e9814954972b46be44727aaf6aac04623e4a46 Mon Sep 17 00:00:00 2001 From: Eli Date: Sat, 29 Dec 2018 00:15:04 -0800 Subject: [PATCH 16/33] Add error for oversized napkins --- .../AlternatingPermuteTest.rule | 36 +++-- examples/compiled_ruletables/BeeZero.rule | 148 +++++++++--------- examples/compiled_ruletables/Brew.rule | 128 +++++++-------- .../compiled_ruletables/DeficientLife.rule | 33 ++-- examples/compiled_ruletables/ExtendedX.rule | 36 ++--- examples/compiled_ruletables/XHistory.rule | 62 ++++---- .../nutshells/AlternatingPermuteTest.ruel | 24 +-- nutshell/segment_types/table/_classes.py | 8 +- nutshell/segment_types/table/_symutils.py | 90 ++++++----- nutshell/segment_types/table/_transformer.py | 16 +- 10 files changed, 307 insertions(+), 274 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 3f16037..29fff17 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -26,24 +26,24 @@ var _a0.1 = _a0.0 var _a0.2 = _a0.0 var _a0.3 = _a0.0 -#### symmetries: nutshell.AlternatingPermute -#### line 12: 0, h, t, any, b, any, any, any, any, any, h #### -0, any.0, any.1, any.2, any.3, any.4, b.0, h.0, t.0, h.1 -0, any.0, any.1, any.2, b.0, any.3, any.4, h.0, t.0, h.1 -0, any.0, any.1, any.2, b.0, any.3, t.0, h.0, any.4, h.1 -0, any.0, any.1, any.2, t.0, any.3, any.4, h.0, b.0, h.1 -0, any.0, any.1, any.2, t.0, any.3, b.0, h.0, any.4, h.1 -0, any.0, b.0, any.1, t.0, any.2, any.3, h.0, any.4, h.1 -#### line 13: 0, h, --t, any, --t, any, --t, any, --t, h #### -0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 -#### line 14: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### +#### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) +#### line 48: 0, h, t, any, b, any, any, any, any, h #### +0, h.0, t.0, any.0, b.0, any.1, any.2, any.3, any.4, h.1 +0, any.0, t.0, any.1, b.0, any.2, any.3, h.0, any.4, h.1 +0, any.0, t.0, any.1, b.0, h.0, any.2, any.3, any.4, h.1 +0, any.0, t.0, h.0, b.0, any.1, any.2, any.3, any.4, h.1 +0, any.0, b.0, any.1, any.2, h.0, t.0, any.3, any.4, h.1 +0, any.0, b.0, h.0, any.1, any.2, t.0, any.3, any.4, h.1 +#### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### +0, any.0, _a0.0, h.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +#### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 @TABLE neighborhood: Moore -symmetries: none +symmetries: rotate4reflect n_states: 4 var any.0 = {0,1,2,3} @@ -64,13 +64,15 @@ var _a0.2 = _a0.0 var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) -#### line 48: 0, h, t, any, b, any, any, any, any, any, h #### -0, any.0, t.0, any.1, b.0, any.2, any.3, any.4, any.5, h.0 +#### line 48: 0, h, t, any, b, any, any, any, any, h #### +0, h.0, b.0, any.0, any.1, any.2, any.3, any.4, t.0, h.1 +0, any.0, b.0, any.1, any.2, any.3, any.4, h.0, t.0, h.1 +0, any.0, b.0, any.1, any.2, h.0, any.3, any.4, t.0, h.1 +0, any.0, b.0, h.0, any.1, any.2, any.3, any.4, t.0, h.1 +0, h.0, any.0, any.1, t.0, any.2, any.3, any.4, b.0, h.1 +0, any.0, any.1, any.2, t.0, h.0, any.3, any.4, b.0, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### 0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 -0, any.0, _a0.0, h.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 -0, any.0, _a0.0, any.1, _a0.1, h.0, _a0.2, any.2, _a0.3, h.1 -0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index 821e151..d1cdc53 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -27,108 +27,108 @@ var any.8 = any.0 # Birth - EVEN generations #### line 10: 0, <017 !hensel / 1 / 0>;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0, 0, 0, 0, 0, 0, 0, 2, 1 +2, 2, 2, 2, 2, 0, 2, 2, 2, 1 +2, 2, 2, 2, 2, 2, 0, 2, 2, 1 +2, 0, 0, 2, 0, 0, 0, 0, 0, 1 +2, 0, 0, 0, 0, 0, 2, 0, 0, 1 #### line 21: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index e7d6ecb..65fe91c 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, 1, _a0.4, _a0.5, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1, 1 +_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, _a0.5, 1 _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 -_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 +_a0.0, _a0.1, 1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 +1, _a0.0, _a0.1, 1, 1, _a0.2, 1, _a0.3, _a0.4, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1, 1 +1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, 1 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 -1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -_b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +1, _a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, 1 +_b0.0, 2, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 -2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 -2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 +2, 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 -_c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 +2, _b0.0, _b0.1, 2, 2, 2, _b0.2, _b0.3, _b0.4, 2 +2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 +_c0.0, _c0.1, _c0.2, 3, 3, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 -_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, _c0.2, 3, 3, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3, 3 +_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 +3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 +3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +3, _c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 -3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, 3, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, _c0.1, 3, 3, 3, _c0.2, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, 3 +3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index e346c16..f5e900b 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -21,6 +21,7 @@ var any.8 = any.0 var live.0 = {1,2,3,4,5,6,7,8,9,10,11} var live.1 = live.0 var live.2 = live.0 +var live.3 = live.0 var _a0.0 = {1,3,4,5,6,7,8,9,10,11} var _a0.1 = _a0.0 var _a0.2 = _a0.0 @@ -54,25 +55,25 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, _a0.0, 0, 0, 0, _a0.1, 0, _a0.2, 2 +0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 0, 0, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### 0, _b0.0, 0, _b0.1, 0, 0, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, 0, 0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 4 +0, _c0.0, 0, 0, _c0.1, 0, 0, _c0.2, 0, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### -0, _d0.0, 0, 0, 0, 0, 0, _d0.1, _d0.2, 5 +0, 0, 0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### -0, _e0.0, _e0.1, 0, 0, 0, 0, 0, _e0.2, 6 +0, 0, _e0.0, _e0.1, _e0.2, 0, 0, 0, 0, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### -0, 0, _f0.0, _f0.1, 0, 0, 0, 0, _f0.2, 7 +0, 0, 0, 0, 0, _f0.0, _f0.1, 0, _f0.2, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, 0, _g0.0, 0, 0, _g0.1, 0, 0, _g0.2, 8 +0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 0, 0, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### 0, _h0.0, 0, 0, _h0.1, 0, 0, 0, _h0.2, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### -0, _i0.0, 0, _i0.1, 0, 0, 0, 0, _i0.2, 10 +0, 0, 0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, _j0.0, 0, 0, 0, _j0.1, 0, 0, _j0.2, 11 +0, _j0.0, _j0.1, 0, 0, _j0.2, 0, 0, 0, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### @@ -83,12 +84,16 @@ live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 # s3 -live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 -live.0, live.1, 0, 0, live.2, 0, 0, 0, 0, 1 -live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 -live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 -live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 +live.0, live.1, live.2, live.3, 0, 0, 0, 0, 0, 1 # s3 +live.0, live.1, live.2, 0, live.3, 0, 0, 0, 0, 1 +live.0, live.1, live.2, 0, 0, live.3, 0, 0, 0, 1 +live.0, live.1, live.2, 0, 0, 0, live.3, 0, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, live.3, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, 0, live.3, 1 +live.0, live.1, 0, live.2, 0, live.3, 0, 0, 0, 1 +live.0, live.1, 0, live.2, 0, 0, live.3, 0, 0, 1 +live.0, live.1, 0, 0, live.2, 0, live.3, 0, 0, 1 +live.0, 0, live.1, 0, live.2, 0, live.3, 0, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index 218a16a..d8a25ee 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,16 +41,16 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +0, off.0, off.1, on.0, on.1, off.2, on.2, off.3, off.4, 1 +0, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +0, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 +0, off.0, off.1, off.2, on.0, on.1, off.3, off.4, on.2, 1 +0, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 0, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 -0, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -0, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 -0, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -0, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 -0, off.0, on.0, off.1, off.2, off.3, on.1, off.4, on.2, 1 +0, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 #### line 21: 0, birth ~ 1, any; 1 #### 0, birth.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 @@ -60,21 +60,21 @@ var death.0 = {3,4} 1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### 1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 -1, off.0, off.1, on.0, off.2, off.3, off.4, off.5, on.1, 1 -1, on.0, off.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 +1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, off.5, 1 +1, off.0, off.1, off.2, on.0, off.3, off.4, on.1, off.5, 1 1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 -1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 -1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 -1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +1, off.0, off.1, on.0, on.1, off.2, off.3, off.4, off.5, 1 +1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, off.5, 1 +1, off.0, off.1, on.0, on.1, off.2, on.2, off.3, off.4, 1 +1, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 +1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, on.2, 1 +1, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 -1, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -1, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 -1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -1, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 -1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, on.2, 1 +1, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index 06538ba..da9e6c5 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,26 +63,26 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 1 -4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 +4, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 +_e0.0, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 +4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 +_e0.0, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 1 +4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, _b0.0, _b0.1, _b0.2, _b0.3, on.0, on.1, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, on.0, on.1, on.2, _b0.4, 1 +4, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 3 +_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 1 +4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### 1, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 @@ -92,21 +92,21 @@ _g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, on.1, off.0, off.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, off.5, on.0 +on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, off.5, on.0 on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 -on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, off.5, on.0 -on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, off.5, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, off.5, on.0 +on.0, off.0, off.1, on.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, on.2, off.1, on.3, off.2, off.3, off.4, on.0 on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, on.3, off.3, off.4, on.0 on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, on.3, on.0 on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, on.1, off.0, off.1, on.2, off.2, off.3, off.4, on.3, on.0 -on.0, on.1, off.0, on.2, off.1, off.2, off.3, on.3, off.4, on.0 -on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, on.2, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, on.3, on.0 +on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, on.3, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/examples/nutshells/AlternatingPermuteTest.ruel b/examples/nutshells/AlternatingPermuteTest.ruel index 022c3e7..1737130 100644 --- a/examples/nutshells/AlternatingPermuteTest.ruel +++ b/examples/nutshells/AlternatingPermuteTest.ruel @@ -22,17 +22,17 @@ var _a0.1 = _a0.0 var _a0.2 = _a0.0 var _a0.3 = _a0.0 -#### symmetries: nutshell.AlternatingPermute -#### line 12: 0, h, t, any, b, any, any, any, any, any, h #### -0, any.0, any.1, any.2, any.3, any.4, b.0, h.0, t.0, h.1 -0, any.0, any.1, any.2, b.0, any.3, any.4, h.0, t.0, h.1 -0, any.0, any.1, any.2, b.0, any.3, t.0, h.0, any.4, h.1 -0, any.0, any.1, any.2, t.0, any.3, any.4, h.0, b.0, h.1 -0, any.0, any.1, any.2, t.0, any.3, b.0, h.0, any.4, h.1 -0, any.0, b.0, any.1, t.0, any.2, any.3, h.0, any.4, h.1 -#### line 13: 0, h, --t, any, --t, any, --t, any, --t, h #### -0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 -#### line 14: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### +#### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) +#### line 48: 0, h, t, any, b, any, any, any, any, h #### +0, h.0, t.0, any.0, b.0, any.1, any.2, any.3, any.4, h.1 +0, any.0, t.0, any.1, b.0, any.2, any.3, h.0, any.4, h.1 +0, any.0, t.0, any.1, b.0, h.0, any.2, any.3, any.4, h.1 +0, any.0, t.0, h.0, b.0, any.1, any.2, any.3, any.4, h.1 +0, any.0, b.0, any.1, any.2, h.0, t.0, any.3, any.4, h.1 +0, any.0, b.0, h.0, any.1, any.2, t.0, any.3, any.4, h.1 +#### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### +0, any.0, _a0.0, h.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +#### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 @@ -45,6 +45,6 @@ b=(3) symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) -0, h, t, any, b, any, any, any, any, any, h +0, h, t, any, b, any, any, any, any, h 0, h, --t, any, --t, any, --t, any, --t, h (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] \ No newline at end of file diff --git a/nutshell/segment_types/table/_classes.py b/nutshell/segment_types/table/_classes.py index 199a309..1717952 100644 --- a/nutshell/segment_types/table/_classes.py +++ b/nutshell/segment_types/table/_classes.py @@ -105,7 +105,7 @@ def expand(self, reference=None): TransitionGroup.from_seq( tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries ).expand() - ) + ) if combine: tr = self[:] tr[idx], tr[orig_idx] = StateList(combine, e.split, context=tethered_var.ctx), e.val @@ -123,7 +123,7 @@ def expand(self, reference=None): TransitionGroup.from_seq( tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries ).expand() - ) + ) break else: current.append(val) @@ -176,8 +176,8 @@ def apply_aux(self, auxiliaries, top=True): for new_tr in TransitionGroup.from_seq( tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries - ).apply_aux([i], False) - ) + ).apply_aux([i], False) + ) stationaries = [aux for aux in auxiliaries if aux.stationary] if stationaries: diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 0d6b5c7..0f2d975 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -9,7 +9,7 @@ class Napkin(tuple): - _hash_func = None + hash_func = None nbhd = None transformations = None nested_transformations = None @@ -40,49 +40,41 @@ def __eq__(self, other): def __repr__(self): return f'{self.__class__.__name__}{super().__repr__()}' - def expand(self, cls=None): - if cls is None: - cls = self.__class__ - searchable = cls._hash_func(self) - if searchable not in cls._RECENTS: - cls._RECENTS[searchable] = cls._expand(self) - return cls._RECENTS[searchable] - - def _expand(self): - raise NotImplementedError('Please override method `_expand()` in Napkin subclass') - - @property - def expanded(self): - if self._expanded is None: - self._expanded = frozenset(self._expand()) - return self._expanded - - @property - def cdir_map(self): - return dict(zip(self.nbhd, self)) - @classmethod def compose(cls, other): if cls.nbhd != other.nbhd: raise TypeError(f'Cannot compose symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') + if cls.hash_func is None or other.hash_func is None: + hash_func = None + else: + def hash_func(nbhd, self): + cls_tuple, cls_permute = cls.hash_func(nbhd, self) + other_tuple, other_permute = other.hash_func(nbhd, self) + return ((frozenset(cls_tuple), other_permute), (frozenset(other_tuple), cls_permute)) return new_sym_type( cls.nbhd, f'{cls.__name__}+{other.__name__}', cls.transformations + other.transformations, - lambda self: [j for i in other.expand(self, other) for j in cls.expand(self.__class__(i), cls)], - nested_transformations=cls.nested_transformations | other.nested_transformations + lambda self: [j for i in other(self).expanded for j in cls(i).expanded], + nested_transformations=cls.nested_transformations | other.nested_transformations, + #hash_func=hash_func ) @classmethod def combine(cls, other): if cls.nbhd != other.nbhd: raise TypeError(f'Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') + #if cls.hash_func is None or other.hash_func is None: + # hash_func = None + #else: + # hash_func = lambda nbhd, self: frozenset((other.hash_func(nbhd, self), cls.hash_func(nbhd, self))) return new_sym_type( cls.nbhd, f'{cls.__name__}/{other.__name__}', cls.transformations + other.transformations, - lambda self: [*other.expand(self, other), *cls.expand(self, cls)], - nested_transformations=frozenset((cls.nested_transformations, other.nested_transformations)) + lambda self: [*other(self).expand(), *cls(self).expand()], + nested_transformations=frozenset((cls.nested_transformations, other.nested_transformations)), + hash_func=None ) @classmethod @@ -90,6 +82,28 @@ def test_nbhd(cls): if not cls.nbhd.supports(cls): raise ValueError(f'Neighborhood does not support {cls.__name__} symmetries') + @property + def cdir_map(self): + return dict(zip(self.nbhd, self)) + + @property + def expanded(self): + if self._expanded is None: + self._expanded = frozenset(self.expand()) + return self._expanded + + def expand(self): + #cls = self.__class__ + #if cls.hash_func is None: + return self._expand() + #searchable = cls.hash_func(cls.nbhd, self) + #if searchable not in cls._RECENTS: + # cls._RECENTS[searchable] = self._expand() + #return cls._RECENTS[searchable] + + def _expand(self): + raise NotImplementedError('Please override method `_expand()` in Napkin subclass') + def _convert(self, iterable): cdir_map = self.cdir_map return [tuple(cdir_map[j] for j in i) for i in iterable] @@ -153,7 +167,7 @@ def get_sym_type(nbhd, string): return resultant_sym -def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_transformations=None, hash_func=tuple): +def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_transformations=None, hash_func=None): if func is None: method = getattr(Napkin, transformations[0]) method_args = transformations[1:] @@ -167,7 +181,7 @@ def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_t 'nested_transformations': nested_transformations, 'nbhd': nbhd, 'tilde': tilde, - '_hash_func': hash_func + 'hash_func': hash_func }) @@ -205,13 +219,19 @@ def rotate(n): @lru_cache() def permute(*cdirs, explicit=False): - return lru_cache()(lambda nbhd: new_sym_type( - nbhd, - f"Permute({' '.join(cdirs) if cdirs else 'All'})", - ('permutations', cdirs or None), # lambda self: self.permutations(cdirs or None) - tilde=permute_tilde_explicit if explicit or len(cdirs) == len(nbhd) else permute_tilde, - hash_func=frozenset - )) + @lru_cache() + def _(nbhd): + not_cdirs = [i for i in nbhd if i not in cdirs] + def hash_func(nbhd, self): + return (tuple(self[nbhd[i]-1] for i in cdirs), frozenset(self[nbhd[i]-1] for i in not_cdirs)) + return new_sym_type( + nbhd, + f"Permute({' '.join(cdirs) if cdirs else 'All'})", + ('permutations', cdirs or None), # lambda self: self.permutations(cdirs or None) + tilde=permute_tilde_explicit if explicit or cdirs and len(cdirs) < len(nbhd) else permute_tilde, + #hash_func=hash_func + ) + return _ @lru_cache() diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segment_types/table/_transformer.py index 7c37fef..a1bf88a 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segment_types/table/_transformer.py @@ -189,6 +189,7 @@ def permute_shorthand(self, children, meta): return MetaTuple(meta, (self.kill_string(state, meta), str(permute[0]) if permute else None)) def main(self, children, meta): + trlen = self._tbl.trlen if not self._tbl.default_sym_used and self.directives['symmetries'] == 'none': self._tbl.default_sym_used = True self._tbl.add_sym_type('none') @@ -215,7 +216,7 @@ def main(self, children, meta): else: idx = pure_idx = 1 napkin = {} - add_mod = partial(_add_mod, self._tbl.trlen) + add_mod = partial(_add_mod, trlen) offset_initial = False # whether it starts on a compass dir other than the first all_cdir = True # whether all terms are tagged with a compass-direction prefix @@ -237,7 +238,7 @@ def main(self, children, meta): if idx == 1 and not offset_initial: offset_initial = cdir elif cdir < idx and (not offset_initial or - offset_initial and pure_idx > self._tbl.trlen): + offset_initial and pure_idx > trlen): raise SyntaxErr( fix(first.meta), 'Out-of-sequence compass direction ' @@ -262,7 +263,7 @@ def main(self, children, meta): offset_initial = 1 if not crange and offset_initial: - crange = (*range(self._tbl.neighborhood[a], 1+self._tbl.trlen), *range(1, 1+self._tbl.neighborhood[b])) + crange = (*range(self._tbl.neighborhood[a], 1+trlen), *range(1, 1+self._tbl.neighborhood[b])) if idx != crange[0]: if idx == 1: @@ -295,6 +296,11 @@ def main(self, children, meta): idx = add_mod(idx, 1) pure_idx += 1 else: + if not offset_initial and pure_idx > trlen: + raise Error( + m, + f'Too many napkin terms (this is number {trlen+1}; expected no more than {trlen})' + ) all_cdir = False napkin[idx], = self.kill_strings(tr_state.children, m) idx = add_mod(idx, 1) @@ -304,11 +310,11 @@ def main(self, children, meta): [idx for idx in range(1, 1+len(self._tbl.neighborhood)) if idx not in napkin], self.vars['any'] )) - if len(napkin) != self._tbl.trlen: + if len(napkin) != trlen: raise Error( (meta.line, children[0].meta.column, children[-1].meta.end_column), f"Bad transition length for {self.directives['neighborhood']} neighborhood " - f'(expected {2+self._tbl.trlen} terms, got {2+len(napkin)})' + f'(expected {2+trlen} terms, got {2+len(napkin)})' ) return TransitionGroup(self._tbl, initial, napkin, resultant, context=fix(meta)) From eead5e0c7e7f18fedc1932a53ca6413788430900 Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 30 Dec 2018 00:28:26 -0800 Subject: [PATCH 17/33] Calculate symmetry transformations on class creation rather than for every instantiation --- .../AlternatingPermuteTest.rule | 22 ++- examples/compiled_ruletables/BeeZero.rule | 150 +++++++++--------- examples/compiled_ruletables/Brew.rule | 122 +++++++------- .../compiled_ruletables/DeficientLife.rule | 39 ++--- examples/compiled_ruletables/ExtendedX.rule | 48 +++--- examples/compiled_ruletables/XHistory.rule | 66 ++++---- nutshell/segment_types/table/_classes.py | 2 +- .../segment_types/table/_neighborhoods.py | 5 + nutshell/segment_types/table/_symutils.py | 119 +++++++------- nutshell/segment_types/table/table.py | 2 +- 10 files changed, 294 insertions(+), 281 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 29fff17..8b58e92 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -43,7 +43,7 @@ var _a0.3 = _a0.0 @TABLE neighborhood: Moore -symmetries: rotate4reflect +symmetries: none n_states: 4 var any.0 = {0,1,2,3} @@ -65,14 +65,26 @@ var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) #### line 48: 0, h, t, any, b, any, any, any, any, h #### +0, any.0, t.0, any.1, any.2, any.3, b.0, h.0, any.4, h.1 +0, any.0, t.0, any.1, any.2, h.0, b.0, any.3, any.4, h.1 +0, h.0, any.0, any.1, any.2, any.3, b.0, any.4, t.0, h.1 0, h.0, b.0, any.0, any.1, any.2, any.3, any.4, t.0, h.1 -0, any.0, b.0, any.1, any.2, any.3, any.4, h.0, t.0, h.1 -0, any.0, b.0, any.1, any.2, h.0, any.3, any.4, t.0, h.1 -0, any.0, b.0, h.0, any.1, any.2, any.3, any.4, t.0, h.1 +0, h.0, any.0, any.1, t.0, any.2, b.0, any.3, any.4, h.1 +0, h.0, t.0, any.0, any.1, any.2, b.0, any.3, any.4, h.1 +0, h.0, any.0, any.1, b.0, any.2, t.0, any.3, any.4, h.1 +0, h.0, any.0, any.1, b.0, any.2, any.3, any.4, t.0, h.1 0, h.0, any.0, any.1, t.0, any.2, any.3, any.4, b.0, h.1 -0, any.0, any.1, any.2, t.0, h.0, any.3, any.4, b.0, h.1 +0, h.0, t.0, any.0, b.0, any.1, any.2, any.3, any.4, h.1 +0, h.0, b.0, any.0, t.0, any.1, any.2, any.3, any.4, h.1 +0, h.0, t.0, any.0, any.1, any.2, any.3, any.4, b.0, h.1 +0, any.0, t.0, h.0, any.1, any.2, b.0, any.3, any.4, h.1 +0, h.0, any.0, any.1, any.2, any.3, t.0, any.4, b.0, h.1 +0, h.0, b.0, any.0, any.1, any.2, t.0, any.3, any.4, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### 0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +0, any.0, _a0.0, any.1, _a0.1, h.0, _a0.2, any.2, _a0.3, h.1 +0, any.0, _a0.0, h.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index d1cdc53..53ad7ed 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -26,109 +26,109 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations #### line 10: 0, <017 !hensel / 1 / 0>; 2 #### -0, 0, 0, 0, 1, 0, 0, 0, 1, 2 -0, 1, 0, 0, 0, 0, 0, 1, 0, 2 -0, 1, 0, 0, 1, 0, 0, 0, 0, 2 +0, 0, 0, 0, 0, 1, 0, 0, 1, 2 +0, 1, 0, 1, 0, 0, 0, 0, 0, 2 +0, 1, 0, 0, 0, 0, 0, 0, 1, 2 0, 0, 0, 1, 0, 0, 0, 1, 0, 2 -0, 0, 0, 0, 0, 1, 1, 0, 0, 2 -0, 0, 1, 0, 1, 0, 0, 0, 0, 2 -0, 0, 1, 0, 1, 1, 0, 0, 0, 2 +0, 0, 0, 0, 1, 0, 1, 0, 0, 2 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 1, 0, 2 +1, 0, 0, 1, 1, 0, 1, 1, 1, 2 +1, 0, 1, 1, 1, 1, 0, 1, 0, 2 +1, 1, 0, 0, 1, 0, 1, 1, 1, 2 +1, 1, 0, 1, 0, 1, 0, 1, 1, 2 +1, 0, 1, 1, 0, 1, 0, 1, 1, 2 +1, 1, 1, 0, 1, 1, 1, 1, 0, 2 1, 0, 1, 1, 1, 1, 1, 0, 1, 2 -1, 0, 1, 1, 0, 1, 1, 1, 1, 2 +1, 1, 1, 1, 0, 0, 1, 1, 1, 2 1, 1, 1, 0, 1, 1, 1, 0, 1, 2 -1, 0, 1, 1, 1, 1, 1, 1, 0, 2 1, 1, 1, 1, 0, 1, 0, 1, 1, 2 -1, 1, 1, 1, 1, 0, 1, 1, 1, 2 +1, 1, 0, 1, 1, 1, 0, 1, 1, 2 +1, 0, 1, 1, 1, 1, 1, 1, 1, 2 1, 1, 1, 1, 1, 1, 0, 1, 1, 2 # Birth - ODD generations #### line 16: 0, <01 b0-odd / 2 / 0>; 1 #### -0, 2, 2, 2, 2, 0, 2, 2, 2, 1 +0, 2, 2, 2, 2, 2, 2, 0, 2, 1 0, 2, 2, 2, 2, 2, 0, 2, 2, 1 # Survival - ODD generations #### line 19: 2, <017 b0-odd / 2 / 0>; 1 #### -2, 2, 2, 2, 2, 0, 2, 2, 2, 1 +2, 2, 2, 2, 2, 2, 2, 0, 2, 1 2, 2, 2, 2, 2, 2, 0, 2, 2, 1 -2, 0, 0, 2, 0, 0, 0, 0, 0, 1 -2, 0, 0, 0, 0, 0, 2, 0, 0, 1 +2, 2, 0, 0, 0, 0, 0, 0, 0, 1 +2, 0, 0, 0, 2, 0, 0, 0, 0, 1 #### line 21: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index 65fe91c..6f9e0f3 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, 1, _a0.4, _a0.5, 1 +_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 -_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1, 1 -_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, _a0.5, 1 _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 _a0.0, _a0.1, 1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1, 1 +_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -1, _a0.0, _a0.1, 1, 1, _a0.2, 1, _a0.3, _a0.4, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 -1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1, 1 -1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, 1 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 1, _a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, 1 -_b0.0, 2, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, _b0.5, 2, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +1, _a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, _a0.1, _a0.2, 1, 1, _a0.3, 1, _a0.4, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 +1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, 1 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, _b0.5, 2 _b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 -2, 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 +2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, 2 2, _b0.0, _b0.1, 2, 2, 2, _b0.2, _b0.3, _b0.4, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 -_c0.0, _c0.1, _c0.2, 3, 3, _c0.3, 3, _c0.4, _c0.5, 3 +2, _b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, 2 +2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, _c0.5, 3 +_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, _c0.2, _c0.3, 3, 3, _c0.4, _c0.5, 3, 3 _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, _c0.2, 3, 3, 3, _c0.3, _c0.4, _c0.5, 3 -_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3, 3 -_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, 3, 3, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 -3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 +3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -3, _c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 -3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 -3, _c0.0, 3, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3 -3, _c0.0, 3, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, 3, 3, 3, _c0.4, 3 +3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +3, _c0.0, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, 3, 3 3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, _c0.0, _c0.1, 3, 3, 3, _c0.2, _c0.3, _c0.4, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 +3, _c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index f5e900b..089ab44 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -21,7 +21,6 @@ var any.8 = any.0 var live.0 = {1,2,3,4,5,6,7,8,9,10,11} var live.1 = live.0 var live.2 = live.0 -var live.3 = live.0 var _a0.0 = {1,3,4,5,6,7,8,9,10,11} var _a0.1 = _a0.0 var _a0.2 = _a0.0 @@ -55,11 +54,11 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 0, 0, 2 +0, 0, 0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### 0, _b0.0, 0, _b0.1, 0, 0, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, _c0.0, 0, 0, _c0.1, 0, 0, _c0.2, 0, 4 +0, 0, 0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### 0, 0, 0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### @@ -67,33 +66,29 @@ var _j0.2 = _j0.0 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### 0, 0, 0, 0, 0, _f0.0, _f0.1, 0, _f0.2, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 0, 0, 8 +0, 0, 0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, _h0.0, 0, 0, _h0.1, 0, 0, 0, _h0.2, 9 +0, 0, 0, 0, _h0.0, 0, 0, _h0.1, _h0.2, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### 0, 0, 0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, _j0.0, _j0.1, 0, 0, _j0.2, 0, 0, 0, 11 +0, _j0.0, 0, 0, 0, _j0.1, _j0.2, 0, 0, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 # s2 -live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 -live.0, live.1, 0, 0, live.2, 0, 0, 0, 0, 1 -live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 -live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 -live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 +live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 # s2 +live.0, 0, 0, 0, 0, live.1, live.2, 0, 0, 1 +live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, live.1, live.2, live.3, 0, 0, 0, 0, 0, 1 # s3 -live.0, live.1, live.2, 0, live.3, 0, 0, 0, 0, 1 -live.0, live.1, live.2, 0, 0, live.3, 0, 0, 0, 1 -live.0, live.1, live.2, 0, 0, 0, live.3, 0, 0, 1 -live.0, live.1, live.2, 0, 0, 0, 0, live.3, 0, 1 -live.0, live.1, live.2, 0, 0, 0, 0, 0, live.3, 1 -live.0, live.1, 0, live.2, 0, live.3, 0, 0, 0, 1 -live.0, live.1, 0, live.2, 0, 0, live.3, 0, 0, 1 -live.0, live.1, 0, 0, live.2, 0, live.3, 0, 0, 1 -live.0, 0, live.1, 0, live.2, 0, live.3, 0, 0, 1 +live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 # s3 +live.0, 0, 0, 0, 0, live.1, live.2, 0, 0, 1 +live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index d8a25ee..bd66e3e 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,40 +41,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, off.0, off.1, on.0, on.1, off.2, on.2, off.3, off.4, 1 -0, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 -0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 -0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 -0, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -0, off.0, off.1, off.2, on.0, on.1, off.3, off.4, on.2, 1 +0, on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, 1 +0, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +0, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 +0, off.0, off.1, off.2, on.0, on.1, on.2, off.3, off.4, 1 +0, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 0, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 -0, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 -0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 -0, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 +0, off.0, on.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +0, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 +0, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 #### line 21: 0, birth ~ 1, any; 1 #### -0, birth.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 -0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 +0, any.0, any.1, birth.0, any.2, any.3, any.4, any.5, any.6, 1 +0, any.0, any.1, any.2, any.3, any.4, birth.0, any.5, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### 1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, off.5, 1 1, off.0, off.1, off.2, on.0, off.3, off.4, on.1, off.5, 1 -1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 +1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, 1 1, off.0, off.1, on.0, on.1, off.2, off.3, off.4, off.5, 1 -1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, off.5, 1 -1, off.0, off.1, on.0, on.1, off.2, on.2, off.3, off.4, 1 -1, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 -1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 -1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, on.2, 1 +1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 +1, off.0, off.1, off.2, off.3, off.4, on.0, off.5, on.1, 1 +1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 +1, on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, 1 +1, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +1, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 +1, off.0, off.1, off.2, on.0, on.1, on.2, off.3, off.4, 1 +1, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 1, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 -1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 -1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 -1, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 +1, off.0, on.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +1, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 +1, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index da9e6c5..edc0478 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,50 +63,50 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### +4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 +4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 +4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 4, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 _e0.0, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 -4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 4, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 _e0.0, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, _b0.3, on.0, on.1, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, on.0, on.1, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 1 -4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### -1, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 -1, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 -_g0.0, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 -_g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 +1, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 2 +1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 2 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 4 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, off.5, on.0 on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, off.5, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, off.5, on.0 on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, off.5, on.0 -on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, off.5, on.0 -on.0, off.0, off.1, on.1, on.2, off.2, on.3, off.3, off.4, on.0 -on.0, on.1, off.0, on.2, off.1, on.3, off.2, off.3, off.4, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, on.3, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 +on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, on.2, on.0 +on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 +on.0, on.1, off.0, off.1, on.2, off.2, off.3, on.3, off.4, on.0 +on.0, off.0, off.1, on.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, on.2, on.3, off.4, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, on.3, off.3, off.4, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, on.3, off.3, off.4, on.0 on.0, on.1, off.0, off.1, off.2, on.2, on.3, off.3, off.4, on.0 -on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, on.3, on.0 -on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, on.3, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, off.3, on.3, off.4, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, off.1, on.2, off.2, on.3, off.3, off.4, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/nutshell/segment_types/table/_classes.py b/nutshell/segment_types/table/_classes.py index 1717952..817a5da 100644 --- a/nutshell/segment_types/table/_classes.py +++ b/nutshell/segment_types/table/_classes.py @@ -340,7 +340,7 @@ def fix_final(self, tr): def in_symmetry(self, NewSymmetry): initial, *napkin, resultant = self.fix_partial() - return [self.fix_final([initial, *i, resultant]) for i in distinct(NewSymmetry(j) for j in self.symmetries(napkin).expand())] + return [self.fix_final([initial, *i, resultant]) for i in distinct(NewSymmetry(j) for j in self.symmetries(napkin).expanded)] class FinalTransition(list): diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 5fa5a06..763e8dc 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -150,6 +150,11 @@ def permutations(self, cdirs=None, *, as_cls=True): permuted_cdirs = set(cdirs) cls = Neighborhood if as_cls else tuple return [cls(next(permute) if c in permuted_cdirs else c for c in self) for permute in map(iter, permutations(cdirs))] + + def identity(self, *, as_cls=True): + if as_cls: + return (self,) + return (self.cdirs,) def get_gollyizer(tbl, nbhd, *, golly_nbhd=None): diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 0f2d975..d359672 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -1,7 +1,7 @@ from collections import OrderedDict from functools import lru_cache, reduce, partial from math import ceil -from operator import and_ as bitwise_and +from operator import and_ as bitwise_and, or_ as bitwise_or from nutshell.common.utils import multisplit from ._neighborhoods import Neighborhood @@ -9,14 +9,15 @@ class Napkin(tuple): - hash_func = None + permute_hash_indices = None nbhd = None + transformation_names = None transformations = None - nested_transformations = None tilde = None _RECENTS = {} def __init__(self, _): + self.cdir_map = dict(zip(self.nbhd, self)) self._expanded = None self._hash = None @@ -24,8 +25,13 @@ def __init__(self, _): def __init_subclass__(cls): # if cls.nbhd is None: # raise NotImplementedError('Please override class attribute `nbhd` in Napkin subclass') - if cls.transformations is None: - raise NotImplementedError('Please override class attribute `transformations` in Napkin subclass') + if cls.transformation_names is None: + raise NotImplementedError('Please override class attribute `transformation_names` in Napkin subclass') + if cls.transformations is None and cls.nbhd is not None: + if len(cls.transformation_names) > 1: + raise NotImplementedError('Please override class attribute `transformations` in Napkin subclass') + func, *args = cls.transformation_names[0] + cls.transformations = frozenset(getattr(cls.nbhd, func)(*args, as_cls=False)) cls._RECENTS = {} cls.test_nbhd() @@ -44,37 +50,40 @@ def __repr__(self): def compose(cls, other): if cls.nbhd != other.nbhd: raise TypeError(f'Cannot compose symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') - if cls.hash_func is None or other.hash_func is None: - hash_func = None + if cls.permute_hash_indices is None or other.permute_hash_indices is None: + hash_indices = None else: - def hash_func(nbhd, self): - cls_tuple, cls_permute = cls.hash_func(nbhd, self) - other_tuple, other_permute = other.hash_func(nbhd, self) - return ((frozenset(cls_tuple), other_permute), (frozenset(other_tuple), cls_permute)) + # Make sure we can compose them w/o headache + cls_stationary, cls_permutable = cls.permute_hash_indices + other_stationary, other_permutable = other.permute_hash_indices + both_stationary = cls_stationary | other_stationary + both_permutable = reduce(bitwise_or, cls_permutable) | reduce(bitwise_or, other_permutable) + + if reduce(bitwise_and, cls_permutable) or reduce(bitwise_and, other_permutable) \ + or both_permutable & both_stationary: + hash_indices = None + else: + hash_indices = ( + {i for i in both_stationary if i not in both_permutable}, + cls_permutable + other_permutable + ) return new_sym_type( cls.nbhd, f'{cls.__name__}+{other.__name__}', - cls.transformations + other.transformations, - lambda self: [j for i in other(self).expanded for j in cls(i).expanded], - nested_transformations=cls.nested_transformations | other.nested_transformations, - #hash_func=hash_func + cls.transformation_names + other.transformation_names, + transformations=frozenset([*other.transformations, *[j for i in other.transformations for j in cls(i).expanded]]), + permute_hash_indices=hash_indices ) @classmethod def combine(cls, other): if cls.nbhd != other.nbhd: raise TypeError(f'Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') - #if cls.hash_func is None or other.hash_func is None: - # hash_func = None - #else: - # hash_func = lambda nbhd, self: frozenset((other.hash_func(nbhd, self), cls.hash_func(nbhd, self))) return new_sym_type( cls.nbhd, f'{cls.__name__}/{other.__name__}', - cls.transformations + other.transformations, - lambda self: [*other(self).expand(), *cls(self).expand()], - nested_transformations=frozenset((cls.nested_transformations, other.nested_transformations)), - hash_func=None + cls.transformation_names + other.transformation_names, + transformations=cls.transformations|other.transformations ) @classmethod @@ -82,40 +91,42 @@ def test_nbhd(cls): if not cls.nbhd.supports(cls): raise ValueError(f'Neighborhood does not support {cls.__name__} symmetries') - @property - def cdir_map(self): - return dict(zip(self.nbhd, self)) - @property def expanded(self): if self._expanded is None: - self._expanded = frozenset(self.expand()) + cls = self.__class__ + if cls.permute_hash_indices is None: + self._expanded = frozenset(self._expand()) + else: + hashable = self._get_hashable() + if hashable not in cls._RECENTS: + cls._RECENTS[hashable] = frozenset(self._expand()) + self._expanded = cls._RECENTS[hashable] return self._expanded - def expand(self): - #cls = self.__class__ - #if cls.hash_func is None: - return self._expand() - #searchable = cls.hash_func(cls.nbhd, self) - #if searchable not in cls._RECENTS: - # cls._RECENTS[searchable] = self._expand() - #return cls._RECENTS[searchable] + def _get_hashable(self): + stationary, permutables = self.__class__.permute_hash_indices + return ( + tuple([self[i] for i in stationary]), + tuple([frozenset([self[i] for i in permutable]) for permutable in permutables]) + ) def _expand(self): - raise NotImplementedError('Please override method `_expand()` in Napkin subclass') + cdir_map = self.cdir_map + return {tuple(cdir_map[i] for i in transformation) for transformation in self.transformations} - def _convert(self, iterable): + def _expand_other(self, iterable): cdir_map = self.cdir_map return [tuple(cdir_map[j] for j in i) for i in iterable] def reflections_across(self, *args): - return self._convert(self.nbhd.reflections_across(*args, as_cls=False)) + return self._expand_other(self.nbhd.reflections_across(*args, as_cls=False)) def rotations_by(self, *args): - return self._convert(self.nbhd.rotations_by(*args, as_cls=False)) + return self._expand_other(self.nbhd.rotations_by(*args, as_cls=False)) def permutations(self, *args): - return self._convert(self.nbhd.permutations(*args, as_cls=False)) + return self._expand_other(self.nbhd.permutations(*args, as_cls=False)) def find_golly_sym_type(symmetries, nbhd): @@ -167,21 +178,13 @@ def get_sym_type(nbhd, string): return resultant_sym -def new_sym_type(nbhd, name, transformations, func=None, *, tilde=None, nested_transformations=None, hash_func=None): - if func is None: - method = getattr(Napkin, transformations[0]) - method_args = transformations[1:] - func = lambda self: method(self, *method_args) - transformations = (transformations,) - if nested_transformations is None: - nested_transformations = frozenset(transformations) +def new_sym_type(nbhd, name, transformation_names, *, transformations=None, tilde=None, permute_hash_indices=None): return type(name, (Napkin,), { - '_expand': func, + 'transformation_names': transformation_names, 'transformations': transformations, - 'nested_transformations': nested_transformations, 'nbhd': nbhd, 'tilde': tilde, - 'hash_func': hash_func + 'permute_hash_indices': permute_hash_indices }) @@ -204,7 +207,7 @@ def reflect(first=None, second=None): return lru_cache()(lambda nbhd: new_sym_type( nbhd, f'Reflect({first.name} {second.name})', - ('reflections_across', (first, second)) # lambda self: self.reflections_across((first, second)) + [('reflections_across', (first, second))] # lambda self: self.reflections_across((first, second)) )) @@ -213,7 +216,7 @@ def rotate(n): return lru_cache()(lambda nbhd: new_sym_type( nbhd, f'Rotate({n})', - ('rotations_by', int(n)) # lambda self: self.rotations_by(int(n)) + [('rotations_by', int(n))] # lambda self: self.rotations_by(int(n)) )) @@ -222,21 +225,19 @@ def permute(*cdirs, explicit=False): @lru_cache() def _(nbhd): not_cdirs = [i for i in nbhd if i not in cdirs] - def hash_func(nbhd, self): - return (tuple(self[nbhd[i]-1] for i in cdirs), frozenset(self[nbhd[i]-1] for i in not_cdirs)) return new_sym_type( nbhd, f"Permute({' '.join(cdirs) if cdirs else 'All'})", - ('permutations', cdirs or None), # lambda self: self.permutations(cdirs or None) + [('permutations', cdirs or None)], # lambda self: self.permutations(cdirs or None) tilde=permute_tilde_explicit if explicit or cdirs and len(cdirs) < len(nbhd) else permute_tilde, - #hash_func=hash_func + permute_hash_indices=({nbhd[i] - 1 for i in cdirs}, [{nbhd[i] - 1 for i in not_cdirs}]) ) return _ @lru_cache() def none(nbhd): - return new_sym_type(nbhd, 'NoSymmetry', (), lambda self, **_: [tuple(self)]) + return new_sym_type(nbhd, 'NoSymmetry', [('identity',)]) def permute_tilde_explicit(self, values): diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index 65a5fef..6e89a81 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -93,7 +93,7 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): self._data = transformer.transform(_parsed) MinSym, name = symutils.find_golly_sym_type(self.sym_types, self.neighborhood) - if len(self.sym_types) <= 1 and self.symmetries.nested_transformations == MinSym.nested_transformations: + if len(self.sym_types) <= 1 and self.symmetries.transformations == MinSym.transformations: self.final = [t.fix_vars() for t in self._data] else: self.final = [new_tr for tr in self._data for new_tr in tr.in_symmetry(MinSym)] From 06200c2d716e977b3643717a7c0f4999b45504de Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 30 Dec 2018 01:14:06 -0800 Subject: [PATCH 18/33] Fix composition somehow (I don't get it) --- .../AlternatingPermuteTest.rule | 22 +-- examples/compiled_ruletables/BeeZero.rule | 158 +++++++++--------- examples/compiled_ruletables/Brew.rule | 128 +++++++------- .../compiled_ruletables/DeficientLife.rule | 36 ++-- examples/compiled_ruletables/ExtendedX.rule | 48 +++--- examples/compiled_ruletables/XHistory.rule | 66 ++++---- nutshell/segment_types/table/_symutils.py | 6 +- 7 files changed, 227 insertions(+), 237 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 8b58e92..1bb7adc 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -43,7 +43,7 @@ var _a0.3 = _a0.0 @TABLE neighborhood: Moore -symmetries: none +symmetries: rotate4reflect n_states: 4 var any.0 = {0,1,2,3} @@ -65,26 +65,14 @@ var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) #### line 48: 0, h, t, any, b, any, any, any, any, h #### -0, any.0, t.0, any.1, any.2, any.3, b.0, h.0, any.4, h.1 -0, any.0, t.0, any.1, any.2, h.0, b.0, any.3, any.4, h.1 0, h.0, any.0, any.1, any.2, any.3, b.0, any.4, t.0, h.1 -0, h.0, b.0, any.0, any.1, any.2, any.3, any.4, t.0, h.1 -0, h.0, any.0, any.1, t.0, any.2, b.0, any.3, any.4, h.1 +0, any.0, b.0, any.1, any.2, h.0, any.3, any.4, t.0, h.1 +0, any.0, any.1, any.2, any.3, any.4, t.0, h.0, b.0, h.1 0, h.0, t.0, any.0, any.1, any.2, b.0, any.3, any.4, h.1 -0, h.0, any.0, any.1, b.0, any.2, t.0, any.3, any.4, h.1 -0, h.0, any.0, any.1, b.0, any.2, any.3, any.4, t.0, h.1 -0, h.0, any.0, any.1, t.0, any.2, any.3, any.4, b.0, h.1 -0, h.0, t.0, any.0, b.0, any.1, any.2, any.3, any.4, h.1 -0, h.0, b.0, any.0, t.0, any.1, any.2, any.3, any.4, h.1 -0, h.0, t.0, any.0, any.1, any.2, any.3, any.4, b.0, h.1 -0, any.0, t.0, h.0, any.1, any.2, b.0, any.3, any.4, h.1 -0, h.0, any.0, any.1, any.2, any.3, t.0, any.4, b.0, h.1 -0, h.0, b.0, any.0, any.1, any.2, t.0, any.3, any.4, h.1 +0, any.0, any.1, any.2, t.0, any.3, any.4, h.0, b.0, h.1 +0, any.0, any.1, h.0, b.0, any.2, t.0, any.3, any.4, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### 0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 -0, any.0, _a0.0, any.1, _a0.1, h.0, _a0.2, any.2, _a0.3, h.1 -0, any.0, _a0.0, h.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 -0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index 53ad7ed..af44e5f 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -26,109 +26,109 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations #### line 10: 0, <017 !hensel / 1 / 0>; 2 #### -0, 0, 0, 0, 0, 1, 0, 0, 1, 2 -0, 1, 0, 1, 0, 0, 0, 0, 0, 2 -0, 1, 0, 0, 0, 0, 0, 0, 1, 2 +0, 1, 0, 0, 0, 0, 0, 1, 0, 2 +0, 0, 1, 0, 1, 0, 0, 0, 0, 2 +0, 0, 0, 0, 0, 0, 0, 1, 1, 2 0, 0, 0, 1, 0, 0, 0, 1, 0, 2 -0, 0, 0, 0, 1, 0, 1, 0, 0, 2 -0, 0, 1, 0, 0, 0, 1, 0, 0, 2 -0, 0, 0, 1, 0, 1, 0, 0, 1, 2 -0, 1, 0, 1, 0, 0, 0, 1, 0, 2 -0, 1, 1, 1, 0, 0, 0, 0, 0, 2 -0, 1, 1, 0, 0, 0, 0, 0, 1, 2 -0, 0, 0, 0, 1, 1, 0, 0, 1, 2 -0, 0, 1, 1, 0, 0, 0, 1, 0, 2 -0, 1, 1, 0, 1, 0, 0, 0, 0, 2 -0, 1, 0, 1, 0, 0, 0, 0, 1, 2 +0, 0, 0, 0, 1, 0, 0, 0, 1, 2 +0, 0, 1, 0, 0, 1, 0, 0, 0, 2 +0, 1, 0, 0, 0, 0, 1, 1, 0, 2 0, 0, 1, 0, 1, 0, 0, 0, 1, 2 -0, 0, 1, 0, 0, 1, 0, 0, 1, 2 -0, 1, 1, 0, 1, 0, 0, 1, 0, 2 -0, 1, 0, 1, 0, 1, 0, 1, 0, 2 -0, 0, 1, 1, 0, 1, 1, 0, 0, 2 -0, 1, 1, 0, 0, 0, 0, 1, 1, 2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, 0, 1, 1, 2 1, 1, 0, 1, 1, 1, 0, 1, 1, 2 -1, 0, 1, 1, 1, 1, 1, 1, 1, 2 -1, 1, 1, 1, 1, 1, 0, 1, 1, 2 +1, 1, 1, 1, 0, 1, 1, 0, 1, 2 +1, 1, 1, 1, 1, 1, 1, 0, 1, 2 +1, 1, 1, 1, 1, 1, 1, 1, 0, 2 # Birth - ODD generations #### line 16: 0, <01 b0-odd / 2 / 0>; 1 #### -0, 2, 2, 2, 2, 2, 2, 0, 2, 1 +0, 2, 2, 0, 2, 2, 2, 2, 2, 1 0, 2, 2, 2, 2, 2, 0, 2, 2, 1 # Survival - ODD generations #### line 19: 2, <017 b0-odd / 2 / 0>; 1 #### -2, 2, 2, 2, 2, 2, 2, 0, 2, 1 +2, 2, 2, 0, 2, 2, 2, 2, 2, 1 2, 2, 2, 2, 2, 2, 0, 2, 2, 1 2, 2, 0, 0, 0, 0, 0, 0, 0, 1 -2, 0, 0, 0, 2, 0, 0, 0, 0, 1 +2, 0, 0, 0, 0, 0, 2, 0, 0, 1 #### line 21: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index 6f9e0f3..dc8b8d5 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 -_a0.0, _a0.1, 1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, 1, _a0.5, 1 +_a0.0, 1, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, 1, 1, _a0.4, _a0.5, 1 +_a0.0, _a0.1, 1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1, 1 _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### -1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 -1, _a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, _a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, _a0.0, _a0.1, _a0.2, 1, 1, _a0.3, 1, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 +1, 1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 +1, _a0.0, _a0.1, _a0.2, 1, 1, 1, _a0.3, _a0.4, 1 +1, _a0.0, 1, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +1, 1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1, 1 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, 2, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, _b0.5, 2, 2 +1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +_b0.0, 2, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2, 2 +_b0.0, 2, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, 2, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 -2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, 2 -2, _b0.0, _b0.1, 2, 2, 2, _b0.2, _b0.3, _b0.4, 2 -2, _b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 -2, 2, _b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +2, 2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, 2 +2, 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 +2, 2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2 +2, 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2 2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 +2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3, 3 +_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, 3, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3, 3 +_c0.0, _c0.1, _c0.2, 3, 3, _c0.3, 3, _c0.4, _c0.5, 3 _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, _c0.5, 3 -_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, _c0.2, _c0.3, 3, 3, _c0.4, _c0.5, 3, 3 _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, _c0.2, 3, 3, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 -3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3, 3 +3, _c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, 3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, 3 +3, _c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, 3 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, 3, 3, 3, _c0.4, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, _c0.0, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, 3, 3 3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, _c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index 089ab44..e573cf0 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -54,41 +54,41 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, 0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 2 +0, 0, _a0.0, 0, _a0.1, 0, 0, 0, _a0.2, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### -0, _b0.0, 0, _b0.1, 0, 0, 0, _b0.2, 0, 3 +0, 0, 0, _b0.0, 0, _b0.1, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, 0, 0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 4 +0, 0, _c0.0, 0, 0, _c0.1, 0, _c0.2, 0, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### -0, 0, 0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 5 +0, _d0.0, 0, 0, 0, 0, 0, _d0.1, _d0.2, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### 0, 0, _e0.0, _e0.1, _e0.2, 0, 0, 0, 0, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### -0, 0, 0, 0, 0, _f0.0, _f0.1, 0, _f0.2, 7 +0, _f0.0, _f0.1, 0, _f0.2, 0, 0, 0, 0, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### 0, 0, 0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, 0, 0, 0, _h0.0, 0, 0, _h0.1, _h0.2, 9 +0, 0, _h0.0, _h0.1, 0, 0, _h0.2, 0, 0, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### -0, 0, 0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 10 +0, _i0.0, _i0.1, 0, 0, 0, 0, _i0.2, 0, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, _j0.0, 0, 0, 0, _j0.1, _j0.2, 0, 0, 11 +0, 0, 0, _j0.0, _j0.1, 0, 0, _j0.2, 0, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 # s2 -live.0, 0, 0, 0, 0, live.1, live.2, 0, 0, 1 -live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 # s2 +live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 -#### line 19: live, live ~ 3, 0; 1 #### -live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 # s3 -live.0, 0, 0, 0, 0, live.1, live.2, 0, 0, 1 -live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 +live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 +#### line 19: live, live ~ 3, 0; 1 #### +live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 # s3 +live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 +live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 +live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index bd66e3e..69f4382 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,40 +41,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, 1 -0, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +0, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +0, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 0, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 0, off.0, off.1, off.2, on.0, on.1, on.2, off.3, off.4, 1 -0, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 -0, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 -0, off.0, on.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 -0, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 -0, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, 1 +0, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +0, on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 +0, on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, 1 0, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 #### line 21: 0, birth ~ 1, any; 1 #### -0, any.0, any.1, birth.0, any.2, any.3, any.4, any.5, any.6, 1 -0, any.0, any.1, any.2, any.3, any.4, birth.0, any.5, any.6, 1 +0, any.0, any.1, any.2, birth.0, any.3, any.4, any.5, any.6, 1 +0, any.0, any.1, any.2, any.3, any.4, any.5, birth.0, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### -1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 -1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 +1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, death.0, 0 +1, any.0, any.1, any.2, any.3, death.0, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, off.0, off.1, off.2, on.0, off.3, off.4, on.1, off.5, 1 -1, on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, 1 -1, off.0, off.1, on.0, on.1, off.2, off.3, off.4, off.5, 1 -1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 -1, off.0, off.1, off.2, off.3, off.4, on.0, off.5, on.1, 1 -1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 -1, on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 +1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 +1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, off.5, 1 +1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 +1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, off.5, 1 +1, off.0, off.1, off.2, off.3, on.0, off.4, off.5, on.1, 1 +1, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +1, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 1, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 1, off.0, off.1, off.2, on.0, on.1, on.2, off.3, off.4, 1 -1, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 -1, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 -1, off.0, on.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 -1, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 -1, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, 1 +1, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +1, on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 +1, on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, 1 1, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index edc0478..83a1426 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,50 +63,50 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 -4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 -4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 -4, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 -_e0.0, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 1 4, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 _e0.0, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 +4, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 3 +_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 1 +4, _b0.0, _b0.1, on.0, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 +4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 +4, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, _b0.4, on.1, on.2, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, _b0.4, on.1, on.2, 1 4, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 _e0.0, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 +4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### -1, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 2 -1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 2 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 4 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 4 +1, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 +1, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 +_g0.0, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 +_g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, off.0, off.1, off.2, on.1, off.3, off.4, on.2, off.5, on.0 -on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, off.5, on.0 -on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, off.5, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 -on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, on.2, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 -on.0, on.1, off.0, off.1, on.2, off.2, off.3, on.3, off.4, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, off.5, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, off.5, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, off.5, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, off.4, off.5, on.2, on.0 +on.0, off.0, on.1, on.2, off.1, on.3, off.2, off.3, off.4, on.0 +on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, on.3, on.0 on.0, off.0, off.1, off.2, off.3, on.1, on.2, on.3, off.4, on.0 on.0, off.0, off.1, off.2, on.1, on.2, on.3, off.3, off.4, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, on.3, off.3, off.4, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, on.3, off.3, off.4, on.0 -on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, on.3, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, off.3, on.3, off.4, on.0 -on.0, off.0, on.1, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, on.2, off.0, on.3, off.1, off.2, off.3, off.4, on.0 +on.0, off.0, off.1, on.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, on.1, off.0, off.1, on.2, on.3, off.2, off.3, off.4, on.0 +on.0, on.1, on.2, off.0, off.1, off.2, on.3, off.3, off.4, on.0 on.0, on.1, off.0, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index d359672..35aeb4c 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -67,11 +67,13 @@ def compose(cls, other): {i for i in both_stationary if i not in both_permutable}, cls_permutable + other_permutable ) + nbhd = cls.nbhd return new_sym_type( - cls.nbhd, + nbhd, f'{cls.__name__}+{other.__name__}', cls.transformation_names + other.transformation_names, - transformations=frozenset([*other.transformations, *[j for i in other.transformations for j in cls(i).expanded]]), + # I don't actually get why this works but not frozenset([j for i in cls.transformations for j in other(i).expanded]) + transformations=frozenset([tuple(a[nbhd[i]-1] for i in b) for a in cls.transformations for b in other.transformations]), permute_hash_indices=hash_indices ) From c310e1cd006ddff1e0397c6b6e7c3ae7a5d3a70d Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 30 Dec 2018 01:23:03 -0800 Subject: [PATCH 19/33] Get rid of files related to old symmetries --- nutshell/__init__.py | 3 +- nutshell/common/symmetries.py | 110 ---------- nutshell/segment_types/table/_napkins.py | 258 ----------------------- 3 files changed, 1 insertion(+), 370 deletions(-) delete mode 100644 nutshell/common/symmetries.py delete mode 100644 nutshell/segment_types/table/_napkins.py diff --git a/nutshell/__init__.py b/nutshell/__init__.py index 58b46c5..d760cfd 100644 --- a/nutshell/__init__.py +++ b/nutshell/__init__.py @@ -1,4 +1,3 @@ __version__ = '0.6.0a' from .common import * -from .segment_types.table import _napkins as napkin -from .segment_types.table._napkins import Napkin, OrthNapkin, HexNapkin +from . import segment_types diff --git a/nutshell/common/symmetries.py b/nutshell/common/symmetries.py deleted file mode 100644 index 78e0baf..0000000 --- a/nutshell/common/symmetries.py +++ /dev/null @@ -1,110 +0,0 @@ -from itertools import permutations, chain, repeat - -from nutshell.segment_types.table._napkins import * -from .utils import LazyProperty - - -class ReflectVertical(Napkin): - neighborhoods = vonNeumann, hexagonal, Moore - fallback = NoSymmetry - - _rotation_amounts = {vonNeumann: 1, hexagonal: 4, Moore: 3} # these values seem to be arbitrary, dunno - - @property - def expanded(self): - return sorted((tuple(self), self.rotate_by(self._rotation_amounts[len(self)])[::-1])) - - -class XReflectDiagonal(OrthNapkin): - neighborhoods = vonNeumann, Moore - fallback = NoSymmetry - - @property - def expanded(self): - rots = list(self.rotate(4))[1::2] - return sorted([tuple(self), *((i[0], *i[:0:-1]) for i in rots)]) - - -class _NWSWReflectDiagonal(OrthNapkin): - neighborhoods = vonNeumann, Moore - fallback = NoSymmetry - - @property - def expanded(self): - rot = self.rotate_by(len(self) // 4) - return sorted([tuple(self), (rot[0], *rot[:0:-1])]) - - -class _SENEReflectDiagonal(OrthNapkin): - neighborhoods = vonNeumann, Moore - fallback = NoSymmetry - - @property - def expanded(self): - rot = self.rotate_by(-len(self) // 4) - return sorted([tuple(self), (rot[0], *rot[:0:-1])]) - - -globals()['\\ReflectDiagonal'] = _NWSWReflectDiagonal -globals()['/ReflectDiagonal'] = _SENEReflectDiagonal - - -class Rotate2(OrthNapkin): - """ - Rotate2 allowing Moore and vonNeumann (and 1D, but...). - """ - neighborhoods = range(2, 9) # neighborhood of size 1 can't be rotated by 2 - fallback = {Any: NoSymmetry, hexagonal: Rotate2} # the Rotate2 is Golly's, not this one - - @property - def expanded(self): - return sorted(self.rotate(2)) - - -class ExplicitPermute(Permute): - @staticmethod - def special(values, length): - new = [] - for v, count in values: - if count is None: - count = '1' - if not count.isdigit(): - raise Exception(f"{v} ~ {count}; '{count}' is not a number") - new.extend([v] * int(count)) - if len(new) < length: - raise Exception(f'Expected {length} terms, got {len(new)}') - return new - - -class AlternatingPermute(ExplicitPermute): - """ - Permutational symmetry, but only between cells perpendicular to one - another in the Moore neighborhood. (both orthogonal and diag cells) - e.g. `0,1,2,3,4,5,6,7` is "symmetric" to `2,5,0,1,4,7,6,3` - - More specifically, this is permutational symmetry between two groups - of cells, one group being every second cell in a napkin and the other - the rest. - - In vonNeumann neighborhood, permutes between opposing cells. - """ - RECENTS = {} - HASHES = {} - neighborhoods = Any - fallback = {Any: Rotate4Reflect, hexagonal: NoSymmetry} - - @LazyProperty - def expanded(self): - t = orth, diag = map(tuple, map(sorted, (self[::2], self[1::2]))) - if t in self.RECENTS: - self._hash = self.HASHES[t] - return self.RECENTS[t] - self.RECENTS[t] = ret = [tuple(chain.from_iterable(zip(i, j))) for i in permutations(orth) for j in permutations(diag)] - self.HASHES[t] = self._hash = hash(tuple(sorted(ret))) - return ret - - @staticmethod - def special(values, length): - permute_sp, length = ExplicitPermute.special, length // 2 - orth, diag = values[::2], values[1::2] - return chain.from_iterable(zip(permute_sp(orth, length), permute_sp(diag, length))) diff --git a/nutshell/segment_types/table/_napkins.py b/nutshell/segment_types/table/_napkins.py deleted file mode 100644 index 24551a4..0000000 --- a/nutshell/segment_types/table/_napkins.py +++ /dev/null @@ -1,258 +0,0 @@ -from itertools import permutations -from math import ceil - -from nutshell.common.utils import LazyProperty, distinct -from ._classes import InlineBinding - -oneDimensional, vonNeumann, hexagonal, Moore = 2, 4, 6, 8 -Any = None - - -class _NapkinMeta(type): - def __init__(cls, name, bases, attrs): - if 'expanded' not in attrs or 'symmetries' in attrs: - # if it's some sort of base class like Napkin or OrthNapkin - # or has symmetries preimplemented itself - return - if isinstance(attrs.get('fallback'), (str, _NapkinMeta)): - cls.fallback = {Any: NAMES[cls.fallback] if isinstance(cls.fallback, str) else cls.fallback} - if isinstance(attrs.get('fallback'), dict): - cls.fallback = {k: NAMES[v] if isinstance(v, str) else v for k, v in cls.fallback.items()} - if Any in cls.fallback and cls.neighborhoods is not Any: - cls.fallback = { - **{k: cls.fallback[Any] for k in cls.neighborhoods}, - # We do want the user-set ones to override the - # cls.fallback[Any]s where possible, so this goes 2nd - **{k: v for k, v in cls.fallback.items() if k is not Any} - } - cls.symmetries = { - n: set(cls(range(n)).expanded) - for n in - (range(1, 9) if cls.neighborhoods is Any else cls.neighborhoods) - } - cls.sym_lens = {n: len(v) for n, v in cls.symmetries.items()} - if 'clear' in attrs: - cls.clear() - - -class Napkin(tuple, metaclass=_NapkinMeta): - """ - Term "napkin" by 83bismuth38. - Represents the 'neighborhood' segment of a transition. - """ - def __init__(self, iterable=None): - self._hash = None - - def __eq__(self, other): - return isinstance(other, tuple) and any(map(other.__eq__, self.expanded)) - - def __hash__(self): - if self._hash is None: - self._hash = hash(tuple(sorted(self.expanded_unique))) - return self._hash - - def __repr__(self): - return f'{type(self).__name__}({super().__repr__()})' - - def rotate_by(self, offset): - return self[offset:] + self[:offset] - - def rotate(self, n): - return map(self.rotate_by, range(0, len(self), len(self) // n)) - - @LazyProperty - def expanded_unique(self): - return distinct(self.expanded) - - def expand(self): - return map(type(self), self.expanded_unique) - - -class OrthNapkin(Napkin): - """Moore & vonNeumann""" - @staticmethod - def reflection_of(seq): - return sorted((seq, (seq[0], *seq[:0:-1]))) - - def rotated4(self): - return sorted(self.rotate(4)) - - def rotated8(self): - return sorted(self.rotate(8)) - - -class HexNapkin(Napkin): - @staticmethod - def reflection_of(seq): - return sorted((seq, tuple(seq[i] for i in (4, 2, 3, 1, 0, 5)))) - - def rotated2(self): - return sorted(self.rotate(2)) - - def rotated3(self): - return sorted(self.rotate(3)) - - def rotated6(self): - return sorted(self.rotate(6)) - - -class NoSymmetry(tuple, metaclass=_NapkinMeta): - neighborhoods = Any - name = ['none'] - - def expand(self): - return self, - - expanded = property(expand) - - -# Hexagonal napkins -class Rotate2(HexNapkin): - neighborhoods = hexagonal, - @property - def expanded(self): - return self.rotated2() - - -class Rotate3(HexNapkin): - neighborhoods = hexagonal, - @property - def expanded(self): - return self.rotated3() - - -class Rotate6(HexNapkin): - neighborhoods = hexagonal, - @property - def expanded(self): - return self.rotated6() - - -class Rotate6Reflect(HexNapkin): - neighborhoods = hexagonal, - @property - def expanded(self): - return (tup for i in self.rotated6() for tup in self.reflection_of(i)) - - -# Orthogonal napkins -class ReflectHorizontal(OrthNapkin): - neighborhoods = vonNeumann, Moore - name = ['reflect', 'reflect_horizontal'] - @LazyProperty - def expanded(self): - return self.reflection_of(tuple(self)) - - -class Rotate4(OrthNapkin): - neighborhoods = vonNeumann, Moore - @LazyProperty - def expanded(self): - return self.rotated4() - - -class Rotate4Reflect(OrthNapkin): - neighborhoods = vonNeumann, Moore - @property - def expanded(self): - return (tup for i in self.rotated4() for tup in self.reflection_of(i)) - - -class Rotate8(OrthNapkin): - neighborhoods = Moore, - @LazyProperty - def expanded(self): - return self.rotated8() - - -class Rotate8Reflect(OrthNapkin): - neighborhoods = Moore, - @property - def expanded(self): - return (tup for i in self.rotated8() for tup in self.reflection_of(i)) - - -# General -class Permute(Napkin): - neighborhoods = Any - RECENTS = {} - HASHES = {} - - def __hash__(self): - if self._hash is None: - self._hash = self.HASHES[tuple(sorted(self))] - return self._hash - - @LazyProperty - def expanded(self): - t = tuple(sorted(self)) - if t in self.RECENTS: - self._hash = self.HASHES[t] - return self.RECENTS[t] - self.RECENTS[t] = ret = list(permutations(t)) - self.HASHES[t] = self._hash = hash(tuple(ret)) - return ret - - @classmethod - def clear(cls): - cls.RECENTS.clear() - cls.HASHES.clear() - - @staticmethod - def special(values, length): - """ - Given a shorthand permutationally-symmetrical transition: - length=8 (Moore neighborhood) - ------- - 1, 0 - 1~4, 0~4 - 1~4, 0 - 1~3, 1, 0, 0 - Return its expanded representation: - 1, 1, 1, 1, 0, 0, 0, 0 - Order is not preserved. - """ - # filler algo courtesy of Thomas Russell on math.stackexchange - # https://math.stackexchange.com/a/1081084 - filler = Permute._fill( - length, - # How many cells filled - length - sum(int(i) for _, i in values if i), - # And how many empty slots left to fill - sum(1 for _, i in values if not i) - ) - return list(_AccumulativeContainer( - (val.set(idx) if isinstance(val, InlineBinding) else val, next(filler) if num is None else int(num)) - for idx, (val, num) in enumerate(values, 1) - )) - - @staticmethod - def _fill(length, tally, empties): - """Only in its own function to be able to raise error on 0""" - for k in range(1, 1 + empties): - v = ceil((tally - k + 1) / empties) - if v == 0: - raise ValueError(f'Too many terms given (expected no more than {length})') - yield v - -class _AccumulativeContainer(list): - def __init__(self, it): - for thing, count in it: - self.append((thing, 1 if count is None else count)) - - def __iter__(self): - return (i.give() if isinstance(i, InlineBinding) else i for k, v in super().__iter__() for i in [k]*v) - - -NAMES = { - name: cls - for cls in (i for i in globals().values() if hasattr(i, 'expanded')) - for name in getattr(cls, 'name', [cls.__name__.lower()]) - } -GOLLY_SYMS = { - # tuples sorted in order of expansion amount (listing it as well) - oneDimensional: ((Permute, 2), (NoSymmetry, 1)), - vonNeumann: ((Permute, 24), (Rotate4Reflect, 8), (Rotate4, 4), (ReflectHorizontal, 2), (NoSymmetry, 1)), - hexagonal: ((Permute, 720), (Rotate6Reflect, 12), (Rotate6, 6), (Rotate3, 3), (Rotate2, 2), (NoSymmetry, 1)), - Moore: ((Permute, 40320), (Rotate8Reflect, 16), (Rotate8, 8), (Rotate4Reflect, 8), (Rotate4, 4), (ReflectHorizontal, 2), (NoSymmetry, 1)) - } From 6318e94044d863cea4bd1198efd1541e9237b324 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 1 Jan 2019 00:07:24 -0800 Subject: [PATCH 20/33] Add descriptive nbhd/sym errors, update CHANGELOG --- CHANGELOG.md | 28 +- examples/compiled_ruletables/bf.rule | 3716 ++++++++--------- examples/nutshells/bf.ruel | 245 +- nutshell/common/errors.py | 4 - nutshell/segment_types/table/_classes.py | 2 +- .../{lark_assets/exceptions.py => _errors.py} | 15 + .../segment_types/table/_neighborhoods.py | 7 +- nutshell/segment_types/table/_symutils.py | 20 +- nutshell/segment_types/table/_transformer.py | 29 +- nutshell/segment_types/table/table.py | 36 +- 10 files changed, 2083 insertions(+), 2019 deletions(-) rename nutshell/segment_types/table/{lark_assets/exceptions.py => _errors.py} (70%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 475a6d1..19aca3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,17 +4,27 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)'s. ## [0.6.0] - In progress ### Planned -- A complete overhaul of symmetries and neighborhoods such that: - - Such transformations as reflection and rotation are handled from the *neighborhood* rather than the symmetry type - - Nutshell, given the compass directions composing a neighborhood, automatically determines what standard transformations - it can undergo - - ~~Symmetry types simply have to call, for instance, neighborhood.rotate4() -- rather than themselves reordering the napkin~~ - - Symmetry types can be composed from within Nutshell without my having to define a new Python class for each basic combination - of symmetries - - Also, apgsearch-like symmetry notation...? - Neighborhood-switching, a la symmetry-switching +- More modifiers, e.g. Langton's Ant and Deficient/genext -- also hex +- Extensions to macros and inline-rulestring modifiers: + - Macros that do their thing before statelists are re-resolved into names (to allow a macro to add new statelists) + - Maybe a `?` element, usable in transitions, indicating an unknown value that will be replaced by a macro? + - Simplify both APIs, maybe with \*args or something (there are currently a *lot* of parameters that need to be passed through) + - Allow macros and inline-rulestring modifiers to be defined either in their own `@MACROS` segment or at the headerless top + of a Nutshell (rather than needing to be in their own, separate file, which means that when I distribute a rule I either + have to share the extra file along with it or I have to add the macro/modifier to the stdlib) - A `prune` macro -- More modifiers, e.g. Langton's Ant and Deficient/genext -- also hex (although hex symmetries are scary) +### Changed +- Completely overhauled symmetries and neighborhoods such that: + - Transformations like reflection and rotation are handled from the *neighborhood* rather than the symmetry type + - Nutshell, given the compass directions composing a neighborhood, automatically determines what standard transformations + it can undergo + - Symmetry types only have to call, for instance, neighborhood.rotate4() -- rather than themselves reordering the napkin + - Symmetry types can be composed from within Nutshell **without** the user's having to define a new Python class for each basic + non-fundamental symmetry type +- Made errors reflect the new symmetry-type/neighborhood relationship: if a symmetry error occurs, the neighborhood's + `__str__()` is shown with a "does not support symmetries" message +- Tilde notation is no longer available for symmetries that aren't "permute all cells" ## [0.5.5] - 2018-12-24 ### Changed diff --git a/examples/compiled_ruletables/bf.rule b/examples/compiled_ruletables/bf.rule index 8d8108e..46a14ba 100644 --- a/examples/compiled_ruletables/bf.rule +++ b/examples/compiled_ruletables/bf.rule @@ -140,1663 +140,15 @@ horizontal (west-pointing) stacks of state-91 cells, delimited by state-93 cells the input tape will right itself automatically once the simulation starts.) + An example: -x = 61, y = 13, rule = bf -53.qR$52.qR$51.qR$50.qR$49.qR$47.2qR$42.qR3.2qR$41.qR3.2qR$41.qJ$43.pR -$7rSrU12rSrU10rSrUrTrU5rSrM$43.I$44.AB2DFHCHCEDGDBCEC! +x = 19, y = 5, rule = bf +4.qJ$6.pR$2rSrM$6.I$7.H2DF2AEBCFGC! -@COLORS -0 0 0 0 -70 255 255 255 -85 255 255 0 -93 255 255 0 - -@ICONS -XPM -"15 1440 13 2" -".. c #000000" -"AA c #FFDDFF" -"BB c #00AA00" -"CC c #CC0000" -"DD c #777777" -"EE c #CCBB00" -"FF c #00AABB" -"vc c #B7FFFF" -"t+ c #FFFFFF" -"_? c #DFFFFF" -"/7 c #FFFF00" -""\ c #E4FFFF" -"re c #F1FFFF" -/* #C Plus sign */ -/* icon for state 1 */ -"..........DDDDDDDDDD.........." -"........DDDDDDDDDDDDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -/* #C Minus sign */ -/* icon for state 2 */ -".............................." -".............................." -".............................." -".............................." -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -".............................." -".............................." -".............................." -".............................." -/* #C Right bracket */ -/* icon for state 3 */ -"......DDDDDDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDD........" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDDDDDDDDDDDDD........" -"......DDDDDDDDDDDDDD.........." -/* #C Left bracket */ -/* icon for state 4 */ -"..........DDDDDDDDDDDDDD......" -"........DDDDDDDDDDDDDDDD......" -"......DDDDDDAAAAAAAADDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDAAAADDDDDDDDDD......" -"......DDDDAAAADDDDDDDDDD......" -"......DDDDAAAADDDD............" -"......DDDDAAAADDDD............" -"......DDDDAAAADDDD............" -"......DDDDAAAADDDDDDDDDD......" -"......DDDDAAAADDDDDDDDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDDDAAAAAAAADDDD......" -"........DDDDDDDDDDDDDDDD......" -"..........DDDDDDDDDDDDDD......" -/* #C Left angle bracket */ -/* icon for state 5 */ -".............................." -"....................DDDDDDDDDD" -"................DDDDDDDDDDDDDD" -"............DDDDDDDDDDAAAADDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"DDDDDDAAAAAAAADDDDDDDDDDDD...." -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"............DDDDDDDDDDAAAADDDD" -"................DDDDDDDDDDDDDD" -"....................DDDDDDDDDD" -".............................." -/* #C Right angle bracket */ -/* icon for state 6 */ -".............................." -"DDDDDDDDDD...................." -"DDDDDDDDDDDDDD................" -"DDDDAAAADDDDDDDDDD............" -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"....DDDDDDDDDDDDAAAAAAAADDDDDD" -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDAAAADDDDDDDDDD............" -"DDDDDDDDDDDDDD................" -"DDDDDDDDDD...................." -".............................." -/* #C Period */ -/* icon for state 7 */ -".............................." -"..........DDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDAAAAAADDDDDDDD...." -"....DDDDAAAAAAAAAAAAAADDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAAAADDDD...." -"....DDDDDDDDAAAAAADDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -"..........DDDDDDDDDD.........." -".............................." -/* #C Comma */ -/* icon for state 8 */ -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDDDDDDDDDDDDDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAAAADDDD.." -"....DDDDDDDDDDDDAAAAAAAADDDD.." -"........DDDDDDDDAAAAAAAADDDD.." -"....DDDDDDDDDDAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAADDDDDDDD.." -"....DDDDDDDDDDDDDDDDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -/* #C "V" shape; instruction pointer */ -/* icon for state 9 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 10 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 11 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 12 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 13 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 14 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 15 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 16 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 17 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* #C empty space/shadow */ -/* icon for state 18 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C Plus sign */ -/* icon for state 19 */ -"..........DDDDDDDDDD.........." -"........DDDDDDDDDDDDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -/* #C Minus sign */ -/* icon for state 20 */ -".............................." -".............................." -".............................." -".............................." -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -".............................." -".............................." -".............................." -".............................." -/* #C Right bracket */ -/* icon for state 21 */ -"......DDDDDDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDD........" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDDDDDDDDDDDDD........" -"......DDDDDDDDDDDDDD.........." -/* #C Left angle bracket */ -/* icon for state 22 */ -".............................." -"....................DDDDDDDDDD" -"................DDDDDDDDDDDDDD" -"............DDDDDDDDDDAAAADDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"DDDDDDAAAAAAAADDDDDDDDDDDD...." -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"............DDDDDDDDDDAAAADDDD" -"................DDDDDDDDDDDDDD" -"....................DDDDDDDDDD" -".............................." -/* #C Right angle bracket */ -/* icon for state 23 */ -".............................." -"DDDDDDDDDD...................." -"DDDDDDDDDDDDDD................" -"DDDDAAAADDDDDDDDDD............" -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"....DDDDDDDDDDDDAAAAAAAADDDDDD" -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDAAAADDDDDDDDDD............" -"DDDDDDDDDDDDDD................" -"DDDDDDDDDD...................." -".............................." -/* #C Period */ -/* icon for state 24 */ -".............................." -"..........DDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDAAAAAADDDDDDDD...." -"....DDDDAAAAAAAAAAAAAADDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAAAADDDD...." -"....DDDDDDDDAAAAAADDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -"..........DDDDDDDDDD.........." -".............................." -/* #C Comma */ -/* icon for state 25 */ -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDDDDDDDDDDDDDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAAAADDDD.." -"....DDDDDDDDDDDDAAAAAAAADDDD.." -"........DDDDDDDDAAAAAAAADDDD.." -"....DDDDDDDDDDAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAADDDDDDDD.." -"....DDDDDDDDDDDDDDDDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -/* #C Plus sign */ -/* icon for state 26 */ -"..........DDDDDDDDDD.........." -"........DDDDDDDDDDDDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -/* #C Minus sign */ -/* icon for state 27 */ -".............................." -".............................." -".............................." -".............................." -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -".............................." -".............................." -".............................." -".............................." -/* #C Right bracket */ -/* icon for state 28 */ -"......DDDDDDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDD........" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDDDDDDDDDDDDD........" -"......DDDDDDDDDDDDDD.........." -/* #C Left angle bracket */ -/* icon for state 29 */ -".............................." -"....................DDDDDDDDDD" -"................DDDDDDDDDDDDDD" -"............DDDDDDDDDDAAAADDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"DDDDDDAAAAAAAADDDDDDDDDDDD...." -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"............DDDDDDDDDDAAAADDDD" -"................DDDDDDDDDDDDDD" -"....................DDDDDDDDDD" -".............................." -/* #C Right angle bracket */ -/* icon for state 30 */ -".............................." -"DDDDDDDDDD...................." -"DDDDDDDDDDDDDD................" -"DDDDAAAADDDDDDDDDD............" -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"....DDDDDDDDDDDDAAAAAAAADDDDDD" -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDAAAADDDDDDDDDD............" -"DDDDDDDDDDDDDD................" -"DDDDDDDDDD...................." -".............................." -/* #C Period */ -/* icon for state 31 */ -".............................." -"..........DDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDAAAAAADDDDDDDD...." -"....DDDDAAAAAAAAAAAAAADDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAAAADDDD...." -"....DDDDDDDDAAAAAADDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -"..........DDDDDDDDDD.........." -".............................." -/* #C Comma */ -/* icon for state 32 */ -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDDDDDDDDDDDDDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAAAADDDD.." -"....DDDDDDDDDDDDAAAAAAAADDDD.." -"........DDDDDDDDAAAAAAAADDDD.." -"....DDDDDDDDDDAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAADDDDDDDD.." -"....DDDDDDDDDDDDDDDDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -/* #C Plus sign */ -/* icon for state 33 */ -"..........DDDDDDDDDD.........." -"........DDDDDDDDDDDDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" -"..DDDDDDDDDDAAAAAADDDDDDDDDD.." -"........DDDDAAAAAADDDD........" -"........DDDDAAAAAADDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -/* #C Minus sign */ -/* icon for state 34 */ -".............................." -".............................." -".............................." -".............................." -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" -"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" -"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." -".............................." -".............................." -".............................." -".............................." -/* #C Right bracket */ -/* icon for state 35 */ -"......DDDDDDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDD........" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"............DDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDDDDDDDAAAADDDD......" -"......DDDDAAAAAAAAAADDDD......" -"......DDDDAAAAAAAADDDDDD......" -"......DDDDDDDDDDDDDDDD........" -"......DDDDDDDDDDDDDD.........." -/* #C Left angle bracket */ -/* icon for state 36 */ -".............................." -"....................DDDDDDDDDD" -"................DDDDDDDDDDDDDD" -"............DDDDDDDDDDAAAADDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"DDDDDDAAAAAAAADDDDDDDDDDDD...." -"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" -"....DDDDDDDDDDAAAAAAAADDDDDDDD" -"........DDDDDDDDDDAAAAAAAADDDD" -"............DDDDDDDDDDAAAADDDD" -"................DDDDDDDDDDDDDD" -"....................DDDDDDDDDD" -".............................." -/* #C Right angle bracket */ -/* icon for state 37 */ -".............................." -"DDDDDDDDDD...................." -"DDDDDDDDDDDDDD................" -"DDDDAAAADDDDDDDDDD............" -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"....DDDDDDDDDDDDAAAAAAAADDDDDD" -"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" -"DDDDDDDDAAAAAAAADDDDDDDDDD...." -"DDDDAAAAAAAADDDDDDDDDD........" -"DDDDAAAADDDDDDDDDD............" -"DDDDDDDDDDDDDD................" -"DDDDDDDDDD...................." -".............................." -/* #C Period */ -/* icon for state 38 */ -".............................." -"..........DDDDDDDDDD.........." -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDAAAAAADDDDDDDD...." -"....DDDDAAAAAAAAAAAAAADDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAAAADDDD...." -"....DDDDDDDDAAAAAADDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -"..........DDDDDDDDDD.........." -".............................." -/* #C Comma */ -/* icon for state 39 */ -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDDDDDDDDDDDDDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAAAADDDD.." -"....DDDDDDDDDDDDAAAAAAAADDDD.." -"........DDDDDDDDAAAAAAAADDDD.." -"....DDDDDDDDDDAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAADDDDDDDD.." -"....DDDDDDDDDDDDDDDDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -/* #C Comma */ -/* icon for state 40 */ -"......DDDDDDDDDDDDDDDDDD......" -"....DDDDDDDDDDDDDDDDDDDDDD...." -"..DDDDDDAAAAAAAAAAAAAADDDDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDAAAAAAAAAAAAAAAAAADDDD.." -"..DDDDDDAAAAAAAAAAAAAAAADDDD.." -"....DDDDDDDDDDDDAAAAAAAADDDD.." -"........DDDDDDDDAAAAAAAADDDD.." -"....DDDDDDDDDDAAAAAAAADDDDDD.." -"....DDDDAAAAAAAAAAAADDDDDDDD.." -"....DDDDDDDDDDDDDDDDDDDDDD...." -"......DDDDDDDDDDDDDDDDDD......" -/* #C empty space/shadow */ -/* icon for state 41 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 42 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 43 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 44 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 45 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 46 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 47 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 48 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 49 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 50 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 51 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 52 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 53 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 54 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 55 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 56 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C Darker "V" shape; delayed pointer */ -/* icon for state 57 */ -".............................." -"....DDDDDDDD......DDDDDDDD...." -"....DDDDDDDD......DDDDDDDD...." -"....DDDDDDDDDD..DDDDDDDDDD...." -"......DDDDDDDD..DDDDDDDD......" -"......DDDDDDDDDDDDDDDDDD......" -"........DDDDDDDDDDDDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -"..........DDDDDDDDDD.........." -"............DDDDDD............" -"............DDDDDD............" -"..............DD.............." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 58 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 59 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 60 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 61 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 62 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 63 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 64 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Data pointer */ -/* icon for state 65 */ -".............................." -".............................." -"............EEEEEE............" -"............EEEEEE............" -"..........EEEEEEEEEE.........." -"..........EEEEEEEEEE.........." -"........EEEEEEEEEEEEEE........" -"........EEEEEEEEEEEEEE........" -"......EEEEEEEEEEEEEEEEEE......" -"......EEEEEEEE..EEEEEEEE......" -"....EEEEEEEEEE..EEEEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -"....EEEEEEEE......EEEEEEEE...." -".............................." -".............................." -/* #C Inert data */ -/* icon for state 66 */ -".............................." -"................EEEEEEEE......" -"..............EEEEEEEEEEEE...." -"............EEEEEEEEEEEEEEEE.." -"..........EEEEEEEEEEEEEEEEEE.." -"........EEEEEEEEEEEEEEEEEEEE.." -"......EEEEEEEEEEEEEEEEEEEEEE.." -"....EEEEEEEEEEEEEEEEEEEEEE...." -"..EEEEEEEEEEEEEEEEEEEEEE......" -"..EEEEEEEEEEEEEEEEEEEE........" -"..EEEEEEEEEEEEEEEEEE.........." -"..EEEEEEEEEEEEEEEE............" -"....EEEEEEEEEEEE.............." -"......EEEEEEEE................" -".............................." -/* #C Active forward-moving data */ -/* icon for state 67 */ -"..........CCCCCCCCCCCCCCCCCC.." -"........CCCCCCCCCCCCCCCCCCCC.." -"........CCCCAAAAAAAAAAAACCCC.." -"........CCCCCCAAAAAAAAAACCCC.." -"........CCCCCCCCAAAAAAAACCCC.." -"......CCCCCCCCAAAAAAAAAACCCC.." -"....CCCCCCCCAAAAAACCAAAACCCC.." -"..CCCCCCCCAAAAAACCCCCCAACCCC.." -"CCCCCCCCAAAAAACCCCCCCCCCCCCC.." -"CCCCCCAAAAAACCCCCCCCCCCCCC...." -"CCCCCCAAAACCCCCCCC............" -"CCCCCCCCCCCCCCCC.............." -"..CCCCCCCCCCCC................" -"....CCCCCCCC.................." -".............................." -/* #C Active forward-moving data */ -/* icon for state 68 */ -"..........CCCCCCCCCCCCCCCCCC.." -"........CCCCCCCCCCCCCCCCCCCC.." -"........CCCCAAAAAAAAAAAACCCC.." -"........CCCCCCAAAAAAAAAACCCC.." -"........CCCCCCCCAAAAAAAACCCC.." -"......CCCCCCCCAAAAAAAAAACCCC.." -"....CCCCCCCCAAAAAACCAAAACCCC.." -"..CCCCCCCCAAAAAACCCCCCAACCCC.." -"CCCCCCCCAAAAAACCCCCCCCCCCCCC.." -"CCCCCCAAAAAACCCCCCCCCCCCCC...." -"CCCCCCAAAACCCCCCCC............" -"CCCCCCCCCCCCCCCC.............." -"..CCCCCCCCCCCC................" -"....CCCCCCCC.................." -".............................." -/* icon for state 69 */ -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" -/* icon for state 70 */ -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -/* #C Active forward-moving data */ -/* icon for state 71 */ -"..........CCCCCCCCCCCCCCCCCC.." -"........CCCCCCCCCCCCCCCCCCCC.." -"........CCCCAAAAAAAAAAAACCCC.." -"........CCCCCCAAAAAAAAAACCCC.." -"........CCCCCCCCAAAAAAAACCCC.." -"......CCCCCCCCAAAAAAAAAACCCC.." -"....CCCCCCCCAAAAAACCAAAACCCC.." -"..CCCCCCCCAAAAAACCCCCCAACCCC.." -"CCCCCCCCAAAAAACCCCCCCCCCCCCC.." -"CCCCCCAAAAAACCCCCCCCCCCCCC...." -"CCCCCCAAAACCCCCCCC............" -"CCCCCCCCCCCCCCCC.............." -"..CCCCCCCCCCCC................" -"....CCCCCCCC.................." -".............................." -/* #C Active backward-moving data */ -/* icon for state 72 */ -"................FFFFFFFF......" -"..............FFFFFFFFFFFF...." -"............FFFFFFFFFFFFFFFF.." -"..........FFFFFFFFAAAAFFFFFF.." -"..FFFFFFFFFFFFFFAAAAAAFFFFFF.." -"FFFFFFFFFFFFFFAAAAAAFFFFFFFF.." -"FFFFAAFFFFFFAAAAAAFFFFFFFF...." -"FFFFAAAAFFAAAAAAFFFFFFFF......" -"FFFFAAAAAAAAAAFFFFFFFF........" -"FFFFAAAAAAAAFFFFFFFF.........." -"FFFFAAAAAAAAAAFFFFFF.........." -"FFFFAAAAAAAAAAAAFFFF.........." -"FFFFFFFFFFFFFFFFFFFF.........." -"FFFFFFFFFFFFFFFFFF............" -".............................." -/* #C Darker "V" shape; delayed pointer */ -/* icon for state 73 */ -".............................." -"....DDDDDDDD......DDDDDDDD...." -"....DDDDDDDD......DDDDDDDD...." -"....DDDDDDDDDD..DDDDDDDDDD...." -"......DDDDDDDD..DDDDDDDD......" -"......DDDDDDDDDDDDDDDDDD......" -"........DDDDDDDDDDDDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -"..........DDDDDDDDDD.........." -"............DDDDDD............" -"............DDDDDD............" -"..............DD.............." -".............................." -".............................." -/* #C Check mark ('yes', aka 'loop') */ -/* icon for state 74 */ -".............................." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBAABB.." -"..BBBBBBBBBBBBBBBBBBBBAAAABB.." -"..BBBBBBBBBBBBBBBBBBAAAAAABB.." -"..BBBBBBBBBBBBBBBBAAAAAABBBB.." -"..BBBBAABBBBBBBBAAAAAABBBBBB.." -"..BBBBAAAABBBBAAAAAABBBBBBBB.." -"..BBBBAAAAAAAAAAAABBBBBBBBBB.." -"..BBBBBBAAAAAAAABBBBBBBBBBBB.." -"..BBBBBBBBAAAABBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -".............................." -/* #C Check mark ('yes', aka 'loop') */ -/* icon for state 75 */ -".............................." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBAABB.." -"..BBBBBBBBBBBBBBBBBBBBAAAABB.." -"..BBBBBBBBBBBBBBBBBBAAAAAABB.." -"..BBBBBBBBBBBBBBBBAAAAAABBBB.." -"..BBBBAABBBBBBBBAAAAAABBBBBB.." -"..BBBBAAAABBBBAAAAAABBBBBBBB.." -"..BBBBAAAAAAAAAAAABBBBBBBBBB.." -"..BBBBBBAAAAAAAABBBBBBBBBBBB.." -"..BBBBBBBBAAAABBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -".............................." -/* #C Check mark ('yes', aka 'loop') */ -/* icon for state 76 */ -".............................." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBAABB.." -"..BBBBBBBBBBBBBBBBBBBBAAAABB.." -"..BBBBBBBBBBBBBBBBBBAAAAAABB.." -"..BBBBBBBBBBBBBBBBAAAAAABBBB.." -"..BBBBAABBBBBBBBAAAAAABBBBBB.." -"..BBBBAAAABBBBAAAAAABBBBBBBB.." -"..BBBBAAAAAAAAAAAABBBBBBBBBB.." -"..BBBBBBAAAAAAAABBBBBBBBBBBB.." -"..BBBBBBBBAAAABBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." -".............................." -/* #C X sign ('no', aka 'break') */ -/* icon for state 77 */ -".............................." -"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." -"..CCAAAACCCCCCCCCCCCCCAAAACC.." -"..CCAAAAAACCCCCCCCCCAAAAAACC.." -"..CCCCAAAAAACCCCCCAAAAAACCCC.." -"..CCCCCCAAAAAACCAAAAAACCCCCC.." -"..CCCCCCCCAAAAAAAAAACCCCCCCC.." -"..CCCCCCCCCCAAAAAACCCCCCCCCC.." -"..CCCCCCCCAAAAAAAAAACCCCCCCC.." -"..CCCCCCAAAAAACCAAAAAACCCCCC.." -"..CCCCAAAAAACCCCCCAAAAAACCCC.." -"..CCAAAAAACCCCCCCCCCAAAAAACC.." -"..CCAAAACCCCCCCCCCCCCCAAAACC.." -"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." -".............................." -/* #C X sign ('no', aka 'break') */ -/* icon for state 78 */ -".............................." -"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." -"..CCAAAACCCCCCCCCCCCCCAAAACC.." -"..CCAAAAAACCCCCCCCCCAAAAAACC.." -"..CCCCAAAAAACCCCCCAAAAAACCCC.." -"..CCCCCCAAAAAACCAAAAAACCCCCC.." -"..CCCCCCCCAAAAAAAAAACCCCCCCC.." -"..CCCCCCCCCCAAAAAACCCCCCCCCC.." -"..CCCCCCCCAAAAAAAAAACCCCCCCC.." -"..CCCCCCAAAAAACCAAAAAACCCCCC.." -"..CCCCAAAAAACCCCCCAAAAAACCCC.." -"..CCAAAAAACCCCCCCCCCAAAAAACC.." -"..CCAAAACCCCCCCCCCCCCCAAAACC.." -"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." -".............................." -/* #C X sign ('no', aka 'break') */ -/* icon for state 79 */ -".............................." -"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." -"..CCAAAACCCCCCCCCCCCCCAAAACC.." -"..CCAAAAAACCCCCCCCCCAAAAAACC.." -"..CCCCAAAAAACCCCCCAAAAAACCCC.." -"..CCCCCCAAAAAACCAAAAAACCCCCC.." -"..CCCCCCCCAAAAAAAAAACCCCCCCC.." -"..CCCCCCCCCCAAAAAACCCCCCCCCC.." -"..CCCCCCCCAAAAAAAAAACCCCCCCC.." -"..CCCCCCAAAAAACCAAAAAACCCCCC.." -"..CCCCAAAAAACCCCCCAAAAAACCCC.." -"..CCAAAAAACCCCCCCCCCAAAAAACC.." -"..CCAAAACCCCCCCCCCCCCCAAAACC.." -"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." -".............................." -/* #C empty space/shadow */ -/* icon for state 80 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 81 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 82 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 83 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* icon for state 84 */ -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" -"_?_?_?_?_?_?_?_?_?_?_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/* icon for state 87 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 88 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C empty space/shadow */ -/* icon for state 89 */ -".............................." -"........AAAAAAAAAAAAAA........" -"....AAAAAADDDDDDDDDDAAAAAA...." -"....AADDDDDDDDDDDDDDDDDDAA...." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"..AADDDD......DD......DDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDDDDDD......DDDDDDDDAA.." -"..AADDDDDD..........DDDDDDAA.." -"..AADDDD......DD......DDDDAA.." -"..AAAADDDD..DDDDDD..DDDDAAAA.." -"....AADDDDDDDDDDDDDDDDDDAA...." -"....AAAAAADDDDDDDDDDAAAAAA...." -"........AAAAAAAAAAAAAA........" -".............................." -/* #C Digit zero */ -/* icon for state 90 */ -".............................." -"..........CCCCCCCCCC.........." -"........CCAAAAAAAAAACC........" -"......CCAAAAAAAAAAAAAACC......" -"......CCAAAACCCCCCAAAACC......" -"......CCAAAACCCCAAAAAACC......" -"......CCAAAACCAAAAAAAACC......" -"......CCAAAAAAAAAAAAAACC......" -"......CCAAAAAAAACCAAAACC......" -"......CCAAAAAACCCCAAAACC......" -"......CCAAAACCCCCCAAAACC......" -"......CCAAAAAAAAAAAAAACC......" -"........CCAAAAAAAAAACC........" -"..........CCCCCCCCCC.........." -".............................." -/* icon for state 91 */ -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -"rerererererererererererererere" -/* #C Digit zero */ -/* icon for state 92 */ -".............................." -"..........CCCCCCCCCC.........." -"........CCAAAAAAAAAACC........" -"......CCAAAAAAAAAAAAAACC......" -"......CCAAAACCCCCCAAAACC......" -"......CCAAAACCCCAAAAAACC......" -"......CCAAAACCAAAAAAAACC......" -"......CCAAAAAAAAAAAAAACC......" -"......CCAAAAAAAACCAAAACC......" -"......CCAAAAAACCCCAAAACC......" -"......CCAAAACCCCCCAAAACC......" -"......CCAAAAAAAAAAAAAACC......" -"........CCAAAAAAAAAACC........" -"..........CCCCCCCCCC.........." -".............................." -/* icon for state 93 */ -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" -/* #C Darker "V" shape; delayed pointer */ -/* icon for state 94 */ -".............................." -"....DDDDDDDD......DDDDDDDD...." -"....DDDDDDDD......DDDDDDDD...." -"....DDDDDDDDDD..DDDDDDDDDD...." -"......DDDDDDDD..DDDDDDDD......" -"......DDDDDDDDDDDDDDDDDD......" -"........DDDDDDDDDDDDDD........" -"........DDDDDDDDDDDDDD........" -"..........DDDDDDDDDD.........." -"..........DDDDDDDDDD.........." -"............DDDDDD............" -"............DDDDDD............" -"..............DD.............." -".............................." -".............................." -/* #C "V" shape; instruction pointer */ -/* icon for state 95 */ -".............................." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAA......AAAAAAAA...." -"....AAAAAAAAAA..AAAAAAAAAA...." -"......AAAAAAAA..AAAAAAAA......" -"......AAAAAAAAAAAAAAAAAA......" -"........AAAAAAAAAAAAAA........" -"........AAAAAAAAAAAAAA........" -"..........AAAAAAAAAA.........." -"..........AAAAAAAAAA.........." -"............AAAAAA............" -"............AAAAAA............" -"..............AA.............." -".............................." -".............................." -/* icon for state 96 */ -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" -"t+t+t+t+t+t+t+t+t+t+t+t+t+t+t+" - -@TABLE -neighborhood: Moore -symmetries: none -n_states: 96 +@TABLE +neighborhood: Moore +symmetries: none +n_states: 96 var any.0 = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95} var any.1 = any.0 @@ -1877,11 +229,11 @@ var _k1.0 = {9,10,11,12,13,14,15,16} var _l1.0 = {1,2,3,5,6,7,8} # Move uninitialized input data into proper position -#### line 286: (91, 92, 93), E live, SE..NE any; 0 #### +#### line 164: (91, 92, 93), E live, SE..NE any; 0 #### _a0.0, any.0, any.1, live.0, any.2, any.3, any.4, any.5, any.6, 0 -#### line 286: SE[0] #### +#### line 164: SE[0] #### any.0, live.0, any.1, any.2, any.3, any.4, any.5, any.6, _a0.0, _a0.0 -#### line 287: (91, 92, 93), N live, NE..NW any; [0: (84, 90, 85)] #### +#### line 165: (91, 92, 93), N live, NE..NW any; [0: (84, 90, 85)] #### 91, live.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 84 92, live.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 90 93, live.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 85 @@ -1889,61 +241,61 @@ any.0, live.0, any.1, any.2, any.3, any.4, any.5, any.6, _a0.0, _a0.0 ##### INITIAL TELESCOPING OF BRACKET-ENCLOSED STUFF ##### ######################################################### # move program cell down if it has a closing bracket to its east -#### line 294: (prgm, 3), E 3, SE..NW vac, N..NE 0; 0 #### +#### line 172: (prgm, 3), E 3, SE..NW vac, N..NE 0; 0 #### _b0.0, 0, 0, 3, vac.0, vac.1, vac.2, vac.3, vac.4, 0 -#### line 294: S[0] #### +#### line 172: S[0] #### vac.0, _b0.0, 3, vac.1, any.0, any.1, any.2, vac.2, vac.3, _b0.0 # move program cell down if the cell to its east is below it -#### line 297: (prgm, 3), SE anyPrgm, S..E vac; 0 #### +#### line 175: (prgm, 3), SE anyPrgm, S..E vac; 0 #### _b0.0, vac.0, vac.1, vac.2, anyPrgm.0, vac.3, vac.4, vac.5, vac.6, 0 -#### line 297: S[0] #### +#### line 175: S[0] #### vac.0, _b0.0, vac.1, anyPrgm.0, any.0, any.1, any.2, vac.2, vac.3, _b0.0 ## (NOTE: The above two groups aren't even necessary but symmetry finishes sooner) ## # move program cell down if it has an opening bracket to its west -#### line 302: (prgm, 4), W 4, any, 0, NE..SW vac; 0 #### +#### line 180: (prgm, 4), W 4, any, 0, NE..SW vac; 0 #### _c0.0, 0, vac.0, vac.1, vac.2, vac.3, vac.4, 4, any.0, 0 -#### line 302: S[0] #### +#### line 180: S[0] #### vac.0, _c0.0, vac.1, vac.2, any.0, any.1, any.2, vac.3, 4, _c0.0 # move program cell down if the cell to its west is below it -#### line 305: (prgm, 4), SW anyPrgm, W..S vac; 0 #### +#### line 183: (prgm, 4), SW anyPrgm, W..S vac; 0 #### _c0.0, vac.0, vac.1, vac.2, vac.3, vac.4, anyPrgm.0, vac.5, vac.6, 0 -#### line 305: S[0] #### +#### line 183: S[0] #### vac.0, _c0.0, vac.1, vac.2, any.0, any.1, any.2, anyPrgm.0, vac.3, _c0.0 # special-casing for ][, but could probably be handled above -#### line 308: 4, E..SE vac, S 0, SW 3, W..NE 0; 0 #### +#### line 186: 4, E..SE vac, S 0, SW 3, W..NE 0; 0 #### 4, 0, 0, vac.0, vac.1, 0, 3, 0, 0, 0 -#### line 308: S:4 #### +#### line 186: S:4 #### 0, 4, vac.0, vac.1, any.0, any.1, any.2, 3, 0, 4 -#### line 309: 3, SE 4, 0, vac, vac, NW..E 0; 0 #### +#### line 187: 3, SE 4, 0, vac, vac, NW..E 0; 0 #### 3, 0, 0, 0, 4, 0, vac.0, vac.1, 0, 0 -#### line 309: S:3 #### +#### line 187: S:3 #### 0, 3, 0, 4, any.0, any.1, any.2, vac.0, vac.1, 3 # if a bracket has nothing in its mouth, assume it needs to travel south # to catch up to a different level # In the same vein, spawn a bracket if there's an empty cell between a bracket (N) and # a prgm tape bit (SW/SE) -#### line 315: 4, N..SW 0, W vac, NW vac; 0 #### +#### line 193: 4, N..SW 0, W vac, NW vac; 0 #### 4, 0, 0, 0, 0, 0, 0, vac.0, vac.1, 0 -#### line 315: S:4 #### +#### line 193: S:4 #### 0, 4, 0, 0, any.0, any.1, any.2, 0, vac.0, 4 -#### line 316: 3, NE..E vac, SE..N 0; 0 #### +#### line 194: 3, NE..E vac, SE..N 0; 0 #### 3, 0, vac.0, vac.1, 0, 0, 0, 0, 0, 0 -#### line 316: S:3 #### +#### line 194: S:3 #### 0, 3, vac.0, 0, any.0, any.1, any.2, 0, 0, 3 # if the above happens, move the now-hanging-one-lvl-too-high prgm-tape data south -#### line 319: prgm, E prgm, 0, 0, SW 3, 0, NW..NE 0; 0 #### +#### line 197: prgm, E prgm, 0, 0, SW 3, 0, NW..NE 0; 0 #### prgm.0, 0, 0, prgm.1, 0, 0, 3, 0, 0, 0 # ]x -#### line 319: S[0] #### +#### line 197: S[0] #### 0, prgm.0, prgm.1, 0, any.0, any.1, any.2, 3, 0, prgm.0 # ]x -#### line 320: prgm, SE 4, 0, 0, W prgm, NW..E 0; 0 #### +#### line 198: prgm, SE 4, 0, 0, W prgm, NW..E 0; 0 #### prgm.0, 0, 0, 0, 4, 0, 0, prgm.1, 0, 0 # x[ -#### line 320: S[0] #### +#### line 198: S[0] #### 0, prgm.0, 0, 4, any.0, any.1, any.2, 0, prgm.1, prgm.0 # x[ ################ ##### 66 ##### ################ ### 66-pointer transformations ### -#### line 328: 58, W eastbound, NW..SW any; [W: datapointers] #### +#### line 206: 58, W eastbound, NW..SW any; [W: datapointers] #### 58, any.0, any.1, any.2, any.3, any.4, any.5, 33, any.6, 59 58, any.0, any.1, any.2, any.3, any.4, any.5, 34, any.6, 60 58, any.0, any.1, any.2, any.3, any.4, any.5, 35, any.6, 61 @@ -1951,7 +303,7 @@ prgm.0, 0, 0, 0, 4, 0, 0, prgm.1, 0, 0 # x[ 58, any.0, any.1, any.2, any.3, any.4, any.5, 37, any.6, 63 58, any.0, any.1, any.2, any.3, any.4, any.5, 38, any.6, 64 58, any.0, any.1, any.2, any.3, any.4, any.5, 39, any.6, 65 -#### line 329: 58, E westbound, SE..NE any; [E: datapointers] #### +#### line 207: 58, E westbound, SE..NE any; [E: datapointers] #### 58, any.0, any.1, 26, any.2, any.3, any.4, any.5, any.6, 59 58, any.0, any.1, 27, any.2, any.3, any.4, any.5, any.6, 60 58, any.0, any.1, 28, any.2, any.3, any.4, any.5, any.6, 61 @@ -1960,7 +312,7 @@ prgm.0, 0, 0, 0, 4, 0, 0, prgm.1, 0, 0 # x[ 58, any.0, any.1, 31, any.2, any.3, any.4, any.5, any.6, 64 58, any.0, any.1, 32, any.2, any.3, any.4, any.5, any.6, 65 # If a loaded shadow is directly below data pointer, pretend it's the same as a signal -#### line 331: 58, S (westshadows-42, eastshadows-41), SW..SE any; [S: datapointers*2] #### +#### line 209: 58, S (westshadows-42, eastshadows-41), SW..SE any; [S: datapointers*2] #### 58, any.0, any.1, any.2, any.3, 43, any.4, any.5, any.6, 59 58, any.0, any.1, any.2, any.3, 44, any.4, any.5, any.6, 60 58, any.0, any.1, any.2, any.3, 45, any.4, any.5, any.6, 61 @@ -1975,86 +327,86 @@ prgm.0, 0, 0, 0, 4, 0, 0, prgm.1, 0, 0 # x[ 58, any.0, any.1, any.2, any.3, 54, any.4, any.5, any.6, 63 58, any.0, any.1, any.2, any.3, 55, any.4, any.5, any.6, 64 58, any.0, any.1, any.2, any.3, 56, any.4, any.5, any.6, 65 -#### line 333: 60, N..NW any; 58 #### +#### line 211: 60, N..NW any; 58 #### 60, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 58 -#### line 333: N:72 #### +#### line 211: N:72 #### any.0, any.1, any.2, any.3, any.4, 60, any.5, any.6, any.7, 72 -#### line 334: 59, N..NW (66, any-66); 58 #### +#### line 212: 59, N..NW (66, any-66); 58 #### 59, _d0.0, _d0.1, _d0.2, _d0.3, _d0.4, _d0.5, _d0.6, _d0.7, 58 -#### line 334: N[(71, 66, ...)] #### +#### line 212: N[(71, 66, ...)] #### 66, any.0, any.1, _d0.0, _d0.1, 59, _d0.2, _d0.3, any.2, 71 _e0.0, any.0, any.1, _d0.0, _d0.1, 59, _d0.2, _d0.3, any.2, 66 -#### line 335: (63, 62), N..NW any; 0 #### +#### line 213: (63, 62), N..NW any; 0 #### _f0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 335: E[0: (58, _)] #### +#### line 213: E[0: (58, _)] #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, 63, any.7, 58 -#### line 335: W[0: (_, 58)] #### +#### line 213: W[0: (_, 58)] #### any.0, any.1, any.2, 62, any.3, any.4, any.5, any.6, any.7, 58 # Test to see whether there is data above the data pointer -- if yes, send back a LOOP signal ('keep looping'), and if no, send a BREAK ('stop looping') -#### line 338: 61, N 0, NE..SE any, S (0, 42, 41), SW..NW any; 58 #### +#### line 216: 61, N 0, NE..SE any, S (0, 42, 41), SW..NW any; 58 #### 61, 0, any.0, any.1, any.2, _g0.0, any.3, any.4, any.5, 58 -#### line 338: W[S: (_, 80, 82)] #### +#### line 216: W[S: (_, 80, 82)] #### any.0, any.1, 0, 61, 42, any.2, any.3, any.4, any.5, 80 any.0, any.1, 0, 61, 41, any.2, any.3, any.4, any.5, 82 -#### line 339: 61, N live, NE..SE any, S (0, 42, 41), SW..NW any; 58 #### +#### line 217: 61, N live, NE..SE any, S (0, 42, 41), SW..NW any; 58 #### 61, live.0, any.0, any.1, any.2, _g0.0, any.3, any.4, any.5, 58 -#### line 339: W[S: (_, 81, 83)] #### +#### line 217: W[S: (_, 81, 83)] #### any.0, any.1, live.0, 61, 42, any.2, any.3, any.4, any.5, 81 any.0, any.1, live.0, 61, 41, any.2, any.3, any.4, any.5, 83 # we can't send a signal from north to south directly (would exceed lightspeed) so we put it to the west first as a two-step sort of thing; this does delay things by one gen however -#### line 341: (42, 41), NW (80, 82, 81, 83), N 58, NE..W any; [NW] #### +#### line 219: (42, 41), NW (80, 82, 81, 83), N 58, NE..W any; [NW] #### _h0.0, 58, any.0, any.1, any.2, any.3, any.4, any.5, _i0.0, _i0.0 -#### line 341: NW:0 #### +#### line 219: NW:0 #### _i0.0, any.0, any.1, 58, _h0.0, any.2, any.3, any.4, any.5, 0 -#### line 341: W:0 #### +#### line 219: W:0 #### any.0, _i0.0, 58, _h0.0, any.1, any.2, any.3, any.4, any.5, 0 # continue on -#### line 343: 28, W 58, NW (0, data), N..SW any; [NW: (77, 74, ...)] #### +#### line 221: 28, W 58, NW (0, data), N..SW any; [NW: (77, 74, ...)] #### 28, any.0, any.1, any.2, any.3, any.4, any.5, 58, 0, 77 28, any.0, any.1, any.2, any.3, any.4, any.5, 58, data.0, 74 -#### line 344: 35, NE (0, data), E 58, SE..N any; [NE: (78, 75, ...)] #### +#### line 222: 35, NE (0, data), E 58, SE..N any; [NE: (78, 75, ...)] #### 35, any.0, 0, 58, any.1, any.2, any.3, any.4, any.5, 78 35, any.0, data.0, 58, any.1, any.2, any.3, any.4, any.5, 75 # Reroute west-/eastbound yes/no signals to the south because we need to get them to the program-tape pointer # ((not relevant at all but i am so proud of how nutshell just takes this and spits out a working translation with no issue)) -#### line 348: (42, 41), N (78, 77, 75, 74), NE..NW any; [N: (80, 82, 81, 83)] #### +#### line 226: (42, 41), N (78, 77, 75, 74), NE..NW any; [N: (80, 82, 81, 83)] #### _h0.0, 78, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 80 _h0.0, 77, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 82 _h0.0, 75, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 81 _h0.0, 74, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 83 -#### line 348: N:0 #### +#### line 226: N:0 #### _j0.0, any.0, any.1, any.2, any.3, _h0.0, any.4, any.5, any.6, 0 -#### line 348: NW[N: (0, _, 0, _)] #### +#### line 226: NW[N: (0, _, 0, _)] #### any.0, any.1, any.2, 78, _h0.0, any.3, any.4, any.5, any.6, 0 any.0, any.1, any.2, 75, _h0.0, any.3, any.4, any.5, any.6, 0 -#### line 348: NE[N: (_, 0, _, 0)] #### +#### line 226: NE[N: (_, 0, _, 0)] #### any.0, any.1, any.2, any.3, any.4, any.5, _h0.0, 77, any.6, 0 any.0, any.1, any.2, any.3, any.4, any.5, _h0.0, 74, any.6, 0 -#### line 349: (80, 82, 81, 83), N..NW any; [0: (41, 42, 41, 42)] #### +#### line 227: (80, 82, 81, 83), N..NW any; [0: (41, 42, 41, 42)] #### 80, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 41 82, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 42 81, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 41 83, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 42 -#### line 349: S[0: (79, 79, 76, ...)] #### +#### line 227: S[0: (79, 79, 76, ...)] #### any.0, 80, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 79 any.0, 82, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 79 any.0, _k0.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 76 # Finally, the r-brack receives the southbound yes/no signal from above # If it's BREAK ('yes'), delete the waiting pointer and move it up to where it can continue traveling # if it's LOOP ('no'), turn the waiting pointer into a westbound one to send it back to the appropriate l-brack -#### line 354: 3, N (79, 76), NE..NW any; [0] #### +#### line 232: 3, N (79, 76), NE..NW any; [0] #### 3, _l0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 3 -#### line 354: N[(12, 0)] #### +#### line 232: N[(12, 0)] #### 79, any.0, any.1, any.2, any.3, 3, any.4, any.5, any.6, 12 76, any.0, any.1, any.2, any.3, 3, any.4, any.5, any.6, 0 -#### line 354: W[N: (0, 17)] #### +#### line 232: W[N: (0, 17)] #### any.0, any.1, 79, 3, any.2, any.3, any.4, any.5, any.6, 0 any.0, any.1, 76, 3, any.2, any.3, any.4, any.5, any.6, 17 -#### line 356: any, SW 4, W 87, NW..S any; 21 #### +#### line 234: any, SW 4, W 87, NW..S any; 21 #### any.0, any.1, any.2, any.3, any.4, any.5, 4, 87, any.6, 21 -#### line 356: W:88 #### +#### line 234: W:88 #### 87, any.0, any.1, any.2, any.3, 4, any.4, any.5, any.6, 88 -#### line 357: 17, W 4, NW..SE any, S (4, prgm), SW any; [S: (87, pointerOps)] #### +#### line 235: 17, W 4, NW..SE any, S (4, prgm), SW any; [S: (87, pointerOps)] #### 17, any.0, any.1, any.2, any.3, 4, any.4, 4, any.5, 87 17, any.0, any.1, any.2, any.3, 1, any.4, 4, any.5, 10 17, any.0, any.1, any.2, any.3, 2, any.4, 4, any.5, 11 @@ -2062,211 +414,211 @@ any.0, any.1, any.2, any.3, any.4, any.5, 4, 87, any.6, 21 17, any.0, any.1, any.2, any.3, 6, any.4, 4, any.5, 14 17, any.0, any.1, any.2, any.3, 7, any.4, 4, any.5, 15 17, any.0, any.1, any.2, any.3, 8, any.4, 4, any.5, 16 -#### line 357: W:4 #### +#### line 235: W:4 #### 4, any.0, any.1, 17, _m0.0, any.2, any.3, any.4, any.5, 4 -#### line 358: 17, N..NW any; 0 #### +#### line 236: 17, N..NW any; 0 #### 17, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 358: W:17 #### +#### line 236: W:17 #### any.0, any.1, any.2, 17, any.3, any.4, any.5, any.6, any.7, 17 -#### line 358: N:18 #### +#### line 236: N:18 #### any.0, any.1, any.2, any.3, any.4, 17, any.5, any.6, any.7, 18 -#### line 360: (78, 75), N..NW any; 0 #### +#### line 238: (78, 75), N..NW any; 0 #### _n0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 360: W[0] #### +#### line 238: W[0] #### any.0, any.1, any.2, _n0.0, any.3, any.4, any.5, any.6, any.7, _n0.0 -#### line 361: (77, 74), N..NW any; 0 #### +#### line 239: (77, 74), N..NW any; 0 #### _o0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 361: E[0] #### +#### line 239: E[0] #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, _o0.0, any.7, _o0.0 # Input # make the comma signal stay put so the data pointer knows where to send the go-poll-for-input request (to have it reach the shadow cell) -#### line 365: 32, E 0, SE..SW any, W 58, NW..NE any; 87 #### +#### line 243: 32, E 0, SE..SW any, W 58, NW..NE any; 87 #### 32, any.0, any.1, 0, any.2, any.3, any.4, 58, any.5, 87 # just need a random nonmoving state -#### line 366: 39, E 58, SE..SW any, W 0, NW..NE any; 88 #### +#### line 244: 39, E 58, SE..SW any, W 0, NW..NE any; 88 #### 39, any.0, any.1, 58, any.2, any.3, any.4, 0, any.5, 88 # just need a random nonmoving state # when input is requested, get the data pointer to zero the current cell, -#### line 368: 65, N 66, NE..NW any; [0] #### +#### line 246: 65, N 66, NE..NW any; [0] #### 65, 66, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 65 -#### line 368: N:72 #### +#### line 246: N:72 #### 66, any.0, any.1, any.2, any.3, 65, any.4, any.5, any.6, 72 -#### line 369: 65, N 0, NE..NW any; 58 #### +#### line 247: 65, N 0, NE..NW any; 58 #### 65, 0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 58 # blank cell's cue # then once done tell the shadow cell to go poll for input ## if nothing to south, send it in appropriate direction -#### line 372: 87, W 58, NW 0, N..S any, SW 0; 0 #### +#### line 250: 87, W 58, NW 0, N..S any, SW 0; 0 #### 87, any.0, any.1, any.2, any.3, any.4, 0, 58, 0, 0 -#### line 372: S:39 #### +#### line 250: S:39 #### any.0, 87, any.1, any.2, any.3, any.4, any.5, 0, 58, 39 -#### line 373: 88, NE 0, E 58, SE 0, S..N any; 0 #### +#### line 251: 88, NE 0, E 58, SE 0, S..N any; 0 #### 88, any.0, 0, 58, 0, any.1, any.2, any.3, any.4, 0 -#### line 373: S:32 #### +#### line 251: S:32 #### any.0, 88, 58, 0, any.1, any.2, any.3, any.4, any.5, 32 ## elif shadow cell to south, stay put and do something stupid to give it the signal regardless #### (this could be merged into the above transition but I'm lazy) -#### line 376: 65, N 0, NE..SE any, S (42, 41), SW..NW any; 58 #### +#### line 254: 65, N 0, NE..SE any, S (42, 41), SW..NW any; 58 #### 65, 0, any.0, any.1, any.2, _h0.0, any.3, any.4, any.5, 58 -#### line 376: SW:39 #### +#### line 254: SW:39 #### any.0, any.1, 65, _h0.0, any.2, any.3, any.4, any.5, any.6, 39 # Also have these misc cells not destroy the shadow if it's to their south -#### line 378: (87, 88), S 42, SW..SE any; 0 #### +#### line 256: (87, 88), S 42, SW..SE any; 0 #### _p0.0, any.0, any.1, any.2, any.3, 42, any.4, any.5, any.6, 0 -#### line 378: S:42 #### +#### line 256: S:42 #### 42, _p0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 42 -#### line 378: SW:39 #### +#### line 256: SW:39 #### any.0, any.1, _p0.0, 42, any.2, any.3, any.4, any.5, any.6, 39 -#### line 379: (87, 88), S 41, SW..SE any; 0 #### +#### line 257: (87, 88), S 41, SW..SE any; 0 #### _p0.0, any.0, any.1, any.2, any.3, 41, any.4, any.5, any.6, 0 -#### line 379: S:41 #### +#### line 257: S:41 #### 41, _p0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 41 -#### line 379: SW:39 #### +#### line 257: SW:39 #### any.0, any.1, _p0.0, 41, any.2, any.3, any.4, any.5, any.6, 39 ## shadow cell receiving go-poll-for-input signal: (none of those commas would ever appear above it otherwise so we can always assume this'll be the cause) ## on receiving the signal it stays put and sends a comma to the west to ask the input-tape head for its stuff -#### line 382: (41, 42), N..NE any, E 32, SE..SW any, W 0, any; [0] #### +#### line 260: (41, 42), N..NE any, E 32, SE..SW any, W 0, any; [0] #### _q0.0, any.0, any.1, 32, any.2, any.3, any.4, 0, any.5, _q0.0 -#### line 382: S:32 #### +#### line 260: S:32 #### any.0, _q0.0, 32, any.1, any.2, any.3, any.4, any.5, 0, 32 -#### line 383: (41, 42), N..NE any, E 0, SE..SW any, W 39, any; [0] #### +#### line 261: (41, 42), N..NE any, E 0, SE..SW any, W 39, any; [0] #### _q0.0, any.0, any.1, 0, any.2, any.3, any.4, 39, any.5, _q0.0 -#### line 383: S:32 #### +#### line 261: S:32 #### any.0, _q0.0, 0, any.1, any.2, any.3, any.4, any.5, 39, 32 # Input head doubles as data delimiter so have it move east appropriately to move data with -#### line 385: 85, N 0, NE 84, E..NW any; 0 #### +#### line 263: 85, N 0, NE 84, E..NW any; 0 #### 85, 0, 84, any.0, any.1, any.2, any.3, any.4, any.5, 0 # if it's the next up -#### line 385: N:85 #### +#### line 263: N:85 #### 0, any.0, any.1, 84, any.2, 85, any.3, any.4, any.5, 85 # if it's the next up -#### line 386: 0, (84, 90), NE..SE any, 85, SW..NW any; 85 #### +#### line 264: 0, (84, 90), NE..SE any, 85, SW..NW any; 85 #### 0, _r0.0, any.0, any.1, any.2, 85, any.3, any.4, any.5, 85 # if it's farther down -#### line 387: 85, N 85, NE..NW any; 0 #### +#### line 265: 85, N 85, NE..NW any; 0 #### 85, 85, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 # Input head is otherwise invincible -#### line 389: 85, N..NW any; [0] #### +#### line 267: 85, N..NW any; [0] #### 85, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 85 # When the west comma finds the input head, # move the comma down one to let the input (if any) know it's there -#### line 392: 85, NE 32, E..N any; [0] #### +#### line 270: 85, NE 32, E..N any; [0] #### 85, any.0, 32, any.1, any.2, any.3, any.4, any.5, any.6, 85 -#### line 392: N:0 #### +#### line 270: N:0 #### any.0, any.1, any.2, 32, any.3, 85, any.4, any.5, any.6, 0 -#### line 392: E:32 #### +#### line 270: E:32 #### any.0, 32, any.1, any.2, any.3, any.4, any.5, 85, any.6, 32 -#### line 393: 90, NE 32, E..N any; 85 #### +#### line 271: 90, NE 32, E..N any; 85 #### 90, any.0, 32, any.1, any.2, any.3, any.4, any.5, any.6, 85 # Move input up and then send it back to the shadow cell -#### line 395: 84, NE (32, 84), E..SE any, S..N any; 0 #### +#### line 273: 84, NE (32, 84), E..SE any, S..N any; 0 #### 84, any.0, _s0.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 -#### line 395: E:84 #### +#### line 273: E:84 #### any.0, _s0.0, any.1, any.2, any.3, any.4, any.5, 84, any.6, 84 -#### line 396: 84, W 85, NW..SW any; 0 #### +#### line 274: 84, W 85, NW..SW any; 0 #### 84, any.0, any.1, any.2, any.3, any.4, any.5, 85, any.6, 0 -#### line 396: N:86 #### +#### line 274: N:86 #### any.0, any.1, any.2, any.3, any.4, 84, 85, any.5, any.6, 86 -#### line 397: (84, 90), N..SE 0, S any, SW..NW any; 0 #### +#### line 275: (84, 90), N..SE 0, S any, SW..NW any; 0 #### _r0.0, 0, 0, 0, 0, any.0, any.1, any.2, any.3, 0 -#### line 397: N[0] #### +#### line 275: N[0] #### 0, any.0, any.1, 0, 0, _r0.0, any.2, any.3, any.4, _r0.0 # When shadow cell receives eastbound input, relay it as an "inc" signal -#### line 399: 58, S (42, 41), SW 86, W..SE any; 59 #### +#### line 277: 58, S (42, 41), SW 86, W..SE any; 59 #### 58, any.0, any.1, any.2, any.3, _h0.0, 86, any.4, any.5, 59 -#### line 400: (41, 42), W 86, NW..SW any; [0] #### +#### line 278: (41, 42), W 86, NW..SW any; [0] #### _q0.0, any.0, any.1, any.2, any.3, any.4, any.5, 86, any.6, _q0.0 -#### line 400: N[0: (33, 26)] #### +#### line 278: N[0: (33, 26)] #### any.0, any.1, any.2, any.3, any.4, 41, 86, any.5, any.6, 33 any.0, any.1, any.2, any.3, any.4, 42, 86, any.5, any.6, 26 # When it receives the "we're done" signal, restore the program-tape pointer & send it on its way -#### line 402: (41, 42), W 89, NW..SW any; [0] #### +#### line 280: (41, 42), W 89, NW..SW any; [0] #### _q0.0, any.0, any.1, any.2, any.3, any.4, any.5, 89, any.6, _q0.0 -#### line 402: S:40 #### +#### line 280: S:40 #### any.0, _q0.0, any.1, any.2, any.3, any.4, any.5, any.6, 89, 40 -#### line 403: 0, W 87, NW 40, N..SE any, S 4, SW 8; 88 #### +#### line 281: 0, W 87, NW 40, N..SE any, S 4, SW 8; 88 #### 0, any.0, any.1, any.2, any.3, 4, 8, 87, 40, 88 # emulate l-brack test from below -#### line 403: W:21 #### +#### line 281: W:21 #### 87, 40, any.0, 0, 4, 8, any.1, any.2, any.3, 21 # emulate l-brack test from below -#### line 404: 87, N 40, NE any, E (3, prgm, 0), SE..NW vac; 9 #### +#### line 282: 87, N 40, NE any, E (3, prgm, 0), SE..NW vac; 9 #### 87, 40, any.0, _t0.0, vac.0, vac.1, vac.2, vac.3, vac.4, 9 -#### line 404: NE[E: (21, _, ...)] #### +#### line 282: NE[E: (21, _, ...)] #### any.0, any.1, any.2, any.3, any.4, 3, 87, 40, any.5, 21 # Also move eastbound input eastward -#### line 406: 86, N..NW any; 0 #### +#### line 284: 86, N..NW any; 0 #### 86, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 406: E:86 #### +#### line 284: E:86 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, 86, any.7, 86 # Send a "we're done" signal when there's no data or none left -#### line 408: 85, E (32, 84), SE..NE any; [0] #### +#### line 286: 85, E (32, 84), SE..NE any; [0] #### 85, any.0, any.1, _s0.0, any.2, any.3, any.4, any.5, any.6, 85 -#### line 408: SE:87 #### +#### line 286: SE:87 #### any.0, _s0.0, any.1, any.2, any.3, any.4, any.5, any.6, 85, 87 # Move "we're done" signal -#### line 410: 87, W 0, NW 85, N..SW any; 0 #### +#### line 288: 87, W 0, NW 85, N..SW any; 0 #### 87, any.0, any.1, any.2, any.3, any.4, any.5, 0, 85, 0 -#### line 410: N:87 #### +#### line 288: N:87 #### any.0, any.1, any.2, any.3, any.4, 87, 0, 85, any.5, 87 -#### line 411: 87, W 85, NW 0, N..SW any; 0 #### +#### line 289: 87, W 85, NW 0, N..SW any; 0 #### 87, any.0, any.1, any.2, any.3, any.4, any.5, 85, 0, 0 -#### line 411: N:89 #### +#### line 289: N:89 #### any.0, any.1, any.2, any.3, any.4, 87, 85, 0, any.5, 89 -#### line 412: 89, N..NW any; 0 #### +#### line 290: 89, N..NW any; 0 #### 89, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 412: E:89 #### +#### line 290: E:89 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, 89, any.7, 89 ### Actual handling of data ### -#### line 415: 64, N..NW any; 58 #### +#### line 293: 64, N..NW any; 58 #### 64, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 58 # don't output if there's nothing to output -#### line 415: N[(0, _, ...)] #### +#### line 293: N[(0, _, ...)] #### 0, any.0, any.1, any.2, any.3, 64, any.4, any.5, any.6, 0 # don't output if there's nothing to output # Output -#### line 417: 66, S 64, SW..SE any; 67 #### +#### line 295: 66, S 64, SW..SE any; 67 #### 66, any.0, any.1, any.2, any.3, 64, any.4, any.5, any.6, 67 -#### line 418: vacdata, E 0, SE any, S (69, 67), SW..NE any; [0: (70, 68)] #### +#### line 296: vacdata, E 0, SE any, S (69, 67), SW..NE any; [0: (70, 68)] #### 0, any.0, any.1, 0, any.2, _u0.0, any.3, any.4, any.5, 70 66, any.0, any.1, 0, any.2, _u0.0, any.3, any.4, any.5, 68 -#### line 419: (70, 68), N..NW (vacdata, any-vacdata); [0: vacdata] #### +#### line 297: (70, 68), N..NW (vacdata, any-vacdata); [0: vacdata] #### 70, _v0.0, _v0.1, _v0.2, _v0.3, _v0.4, _v0.5, _v0.6, _v0.7, 0 68, _v0.0, _v0.1, _v0.2, _v0.3, _v0.4, _v0.5, _v0.6, _v0.7, 66 -#### line 419: N[(70, 68, _, ...)] #### +#### line 297: N[(70, 68, _, ...)] #### 0, any.0, any.1, _v0.0, _v0.1, _w0.0, _v0.2, _v0.3, any.2, 70 66, any.0, any.1, _v0.0, _v0.1, _w0.0, _v0.2, _v0.3, any.2, 68 -#### line 421: 67, N..NW (vacdata, any-vacdata); 66 #### +#### line 299: 67, N..NW (vacdata, any-vacdata); 66 #### 67, _v0.0, _v0.1, _v0.2, _v0.3, _v0.4, _v0.5, _v0.6, _v0.7, 66 -#### line 421: N[(69, 67, _, ...)] #### +#### line 299: N[(69, 67, _, ...)] #### 0, any.0, any.1, _v0.0, _v0.1, 67, _v0.2, _v0.3, any.2, 69 66, any.0, any.1, _v0.0, _v0.1, 67, _v0.2, _v0.3, any.2, 67 -#### line 422: (69, 67), N..NW (vacdata, any-vacdata); [0: vacdata] #### +#### line 300: (69, 67), N..NW (vacdata, any-vacdata); [0: vacdata] #### 69, _v0.0, _v0.1, _v0.2, _v0.3, _v0.4, _v0.5, _v0.6, _v0.7, 0 67, _v0.0, _v0.1, _v0.2, _v0.3, _v0.4, _v0.5, _v0.6, _v0.7, 66 -#### line 422: N[(69, 67, _, ...)] #### +#### line 300: N[(69, 67, _, ...)] #### 0, any.0, any.1, _v0.0, _v0.1, _u0.0, _v0.2, _v0.3, any.2, 69 66, any.0, any.1, _v0.0, _v0.1, _u0.0, _v0.2, _v0.3, any.2, 67 -#### line 422: NE[(_, 67, _, ...)] #### +#### line 300: NE[(_, 67, _, ...)] #### 66, any.0, any.1, any.2, any.3, _v0.0, _u0.0, _v0.1, any.4, 67 # inc/dec instructions -#### line 425: 66, SW 72, W..S any; [NE: (0, 72, ...)] #### +#### line 303: 66, SW 72, W..S any; [NE: (0, 72, ...)] #### 66, any.0, 0, any.1, any.2, any.3, 72, any.4, any.5, 0 66, any.0, live.0, any.1, any.2, any.3, 72, any.4, any.5, 72 -#### line 426: vacdata, SW 71, W..S any; [0: (66, 71)] #### +#### line 304: vacdata, SW 71, W..S any; [0: (66, 71)] #### 0, any.0, any.1, any.2, any.3, any.4, 71, any.5, any.6, 66 66, any.0, any.1, any.2, any.3, any.4, 71, any.5, any.6, 71 -#### line 427: 0, SW 71, W..S any; [NE: (66, 71, ...)] #### +#### line 305: 0, SW 71, W..S any; [NE: (66, 71, ...)] #### 0, any.0, 0, any.1, any.2, any.3, 71, any.4, any.5, 66 0, any.0, live.0, any.1, any.2, any.3, 71, any.4, any.5, 71 -#### line 429: 72, SW 0, W..S any; [NE: (0, 66, ...)] #### +#### line 307: 72, SW 0, W..S any; [NE: (0, 66, ...)] #### 72, any.0, 0, any.1, any.2, any.3, 0, any.4, any.5, 0 72, any.0, live.0, any.1, any.2, any.3, 0, any.4, any.5, 66 -#### line 430: 72, NE 0, E..N any; 0 #### +#### line 308: 72, NE 0, E..N any; 0 #### 72, any.0, 0, any.1, any.2, any.3, any.4, any.5, any.6, 0 -#### line 431: (71, 72), N..NW any; 66 #### +#### line 309: (71, 72), N..NW any; 66 #### _x0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 66 ####################### ##### SHADOW CELL ##### ####################### # If shadow is touching data pointer, flip direction before moving to it -#### line 439: 41, NW 58, N..W any; 42 #### +#### line 317: 41, NW 58, N..W any; 42 #### 41, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 58, 42 -#### line 440: 42, NE 58, E..N any; 41 #### +#### line 318: 42, NE 58, E..N any; 41 #### 42, any.0, 58, any.1, any.2, any.3, any.4, any.5, any.6, 41 -#### line 441: eastshadows, SE northboundNOP, S..NW any, N 58, NE..E any; 0 #### +#### line 319: eastshadows, SE northboundNOP, S..NW any, N 58, NE..E any; 0 #### eastshadows.0, 58, any.0, any.1, northboundNOP.0, any.2, any.3, any.4, any.5, 0 -#### line 441: E[SE: westshadows] #### +#### line 319: E[SE: westshadows] #### any.0, any.1, any.2, any.3, any.4, 19, any.5, eastshadows.0, 58, 43 any.0, any.1, any.2, any.3, any.4, 20, any.5, eastshadows.0, 58, 44 any.0, any.1, any.2, any.3, any.4, 21, any.5, eastshadows.0, 58, 45 @@ -2275,9 +627,9 @@ any.0, any.1, any.2, any.3, any.4, 23, any.5, eastshadows.0, 58, 47 any.0, any.1, any.2, any.3, any.4, 24, any.5, eastshadows.0, 58, 48 any.0, any.1, any.2, any.3, any.4, 25, any.5, eastshadows.0, 58, 49 any.0, any.1, any.2, any.3, any.4, 18, any.5, eastshadows.0, 58, 42 -#### line 442: westshadows, SW northboundNOP, W..NW any, N 58, NE..S any; 0 #### +#### line 320: westshadows, SW northboundNOP, W..NW any, N 58, NE..S any; 0 #### westshadows.0, 58, any.0, any.1, any.2, any.3, northboundNOP.0, any.4, any.5, 0 -#### line 442: W[SW: eastshadows] #### +#### line 320: W[SW: eastshadows] #### any.0, any.1, 58, westshadows.0, any.2, 19, any.3, any.4, any.5, 50 any.0, any.1, 58, westshadows.0, any.2, 20, any.3, any.4, any.5, 51 any.0, any.1, 58, westshadows.0, any.2, 21, any.3, any.4, any.5, 52 @@ -2287,9 +639,9 @@ any.0, any.1, 58, westshadows.0, any.2, 24, any.3, any.4, any.5, 55 any.0, any.1, 58, westshadows.0, any.2, 25, any.3, any.4, any.5, 56 any.0, any.1, 58, westshadows.0, any.2, 18, any.3, any.4, any.5, 41 # If a northbound cell is coming at shadow from a corner, move toward it & load self with it -#### line 445: eastshadows, SW northboundNOP, W..S any; 0 #### +#### line 323: eastshadows, SW northboundNOP, W..S any; 0 #### eastshadows.0, any.0, any.1, any.2, any.3, any.4, northboundNOP.0, any.5, any.6, 0 -#### line 445: W[SW: eastshadows] #### +#### line 323: W[SW: eastshadows] #### any.0, any.1, any.2, eastshadows.0, any.3, 19, any.4, any.5, any.6, 50 any.0, any.1, any.2, eastshadows.0, any.3, 20, any.4, any.5, any.6, 51 any.0, any.1, any.2, eastshadows.0, any.3, 21, any.4, any.5, any.6, 52 @@ -2298,9 +650,9 @@ any.0, any.1, any.2, eastshadows.0, any.3, 23, any.4, any.5, any.6, 54 any.0, any.1, any.2, eastshadows.0, any.3, 24, any.4, any.5, any.6, 55 any.0, any.1, any.2, eastshadows.0, any.3, 25, any.4, any.5, any.6, 56 any.0, any.1, any.2, eastshadows.0, any.3, 18, any.4, any.5, any.6, 41 -#### line 446: westshadows, SW northboundNOP, W..S any; 0 #### +#### line 324: westshadows, SW northboundNOP, W..S any; 0 #### westshadows.0, any.0, any.1, any.2, any.3, any.4, northboundNOP.0, any.5, any.6, 0 -#### line 446: W[SW: westshadows] #### +#### line 324: W[SW: westshadows] #### any.0, any.1, any.2, westshadows.0, any.3, 19, any.4, any.5, any.6, 43 any.0, any.1, any.2, westshadows.0, any.3, 20, any.4, any.5, any.6, 44 any.0, any.1, any.2, westshadows.0, any.3, 21, any.4, any.5, any.6, 45 @@ -2309,9 +661,9 @@ any.0, any.1, any.2, westshadows.0, any.3, 23, any.4, any.5, any.6, 47 any.0, any.1, any.2, westshadows.0, any.3, 24, any.4, any.5, any.6, 48 any.0, any.1, any.2, westshadows.0, any.3, 25, any.4, any.5, any.6, 49 any.0, any.1, any.2, westshadows.0, any.3, 18, any.4, any.5, any.6, 42 -#### line 448: eastshadows, SE northboundNOP, S..E any; 0 #### +#### line 326: eastshadows, SE northboundNOP, S..E any; 0 #### eastshadows.0, any.0, any.1, any.2, northboundNOP.0, any.3, any.4, any.5, any.6, 0 -#### line 448: E[SE: eastshadows] #### +#### line 326: E[SE: eastshadows] #### any.0, any.1, any.2, any.3, any.4, 19, any.5, eastshadows.0, any.6, 50 any.0, any.1, any.2, any.3, any.4, 20, any.5, eastshadows.0, any.6, 51 any.0, any.1, any.2, any.3, any.4, 21, any.5, eastshadows.0, any.6, 52 @@ -2320,9 +672,9 @@ any.0, any.1, any.2, any.3, any.4, 23, any.5, eastshadows.0, any.6, 54 any.0, any.1, any.2, any.3, any.4, 24, any.5, eastshadows.0, any.6, 55 any.0, any.1, any.2, any.3, any.4, 25, any.5, eastshadows.0, any.6, 56 any.0, any.1, any.2, any.3, any.4, 18, any.5, eastshadows.0, any.6, 41 -#### line 449: westshadows, SE northboundNOP, S..E any; 0 #### +#### line 327: westshadows, SE northboundNOP, S..E any; 0 #### westshadows.0, any.0, any.1, any.2, northboundNOP.0, any.3, any.4, any.5, any.6, 0 -#### line 449: E[SE: westshadows] #### +#### line 327: E[SE: westshadows] #### any.0, any.1, any.2, any.3, any.4, 19, any.5, westshadows.0, any.6, 43 any.0, any.1, any.2, any.3, any.4, 20, any.5, westshadows.0, any.6, 44 any.0, any.1, any.2, any.3, any.4, 21, any.5, westshadows.0, any.6, 45 @@ -2332,7 +684,7 @@ any.0, any.1, any.2, any.3, any.4, 24, any.5, westshadows.0, any.6, 48 any.0, any.1, any.2, any.3, any.4, 25, any.5, westshadows.0, any.6, 49 any.0, any.1, any.2, any.3, any.4, 18, any.5, westshadows.0, any.6, 42 # If it's coming from right below, just load without moving -#### line 452: eastshadows, S northboundNOP, SW..SE any; [S: eastshadows] #### +#### line 330: eastshadows, S northboundNOP, SW..SE any; [S: eastshadows] #### eastshadows.0, any.0, any.1, any.2, any.3, 19, any.4, any.5, any.6, 50 eastshadows.0, any.0, any.1, any.2, any.3, 20, any.4, any.5, any.6, 51 eastshadows.0, any.0, any.1, any.2, any.3, 21, any.4, any.5, any.6, 52 @@ -2341,7 +693,7 @@ eastshadows.0, any.0, any.1, any.2, any.3, 23, any.4, any.5, any.6, 54 eastshadows.0, any.0, any.1, any.2, any.3, 24, any.4, any.5, any.6, 55 eastshadows.0, any.0, any.1, any.2, any.3, 25, any.4, any.5, any.6, 56 eastshadows.0, any.0, any.1, any.2, any.3, 18, any.4, any.5, any.6, 41 -#### line 453: westshadows, S northboundNOP, SW..SE any; [S: westshadows] #### +#### line 331: westshadows, S northboundNOP, SW..SE any; [S: westshadows] #### westshadows.0, any.0, any.1, any.2, any.3, 19, any.4, any.5, any.6, 43 westshadows.0, any.0, any.1, any.2, any.3, 20, any.4, any.5, any.6, 44 westshadows.0, any.0, any.1, any.2, any.3, 21, any.4, any.5, any.6, 45 @@ -2351,9 +703,9 @@ westshadows.0, any.0, any.1, any.2, any.3, 24, any.4, any.5, any.6, 48 westshadows.0, any.0, any.1, any.2, any.3, 25, any.4, any.5, any.6, 49 westshadows.0, any.0, any.1, any.2, any.3, 18, any.4, any.5, any.6, 42 # A "loaded" shadow cell turns into a normal one and releases its signal -#### line 456: eastshadows, N..NW any; 41 #### +#### line 334: eastshadows, N..NW any; 41 #### eastshadows.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 41 -#### line 456: N[0: (eastbound, _)] #### +#### line 334: N[0: (eastbound, _)] #### any.0, any.1, any.2, any.3, any.4, 50, any.5, any.6, any.7, 33 any.0, any.1, any.2, any.3, any.4, 51, any.5, any.6, any.7, 34 any.0, any.1, any.2, any.3, any.4, 52, any.5, any.6, any.7, 35 @@ -2361,9 +713,9 @@ any.0, any.1, any.2, any.3, any.4, 53, any.5, any.6, any.7, 36 any.0, any.1, any.2, any.3, any.4, 54, any.5, any.6, any.7, 37 any.0, any.1, any.2, any.3, any.4, 55, any.5, any.6, any.7, 38 any.0, any.1, any.2, any.3, any.4, 56, any.5, any.6, any.7, 39 -#### line 457: westshadows, N..NW any; 42 #### +#### line 335: westshadows, N..NW any; 42 #### westshadows.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 42 -#### line 457: N[0: (westbound, _)] #### +#### line 335: N[0: (westbound, _)] #### any.0, any.1, any.2, any.3, any.4, 43, any.5, any.6, any.7, 26 any.0, any.1, any.2, any.3, any.4, 44, any.5, any.6, any.7, 27 any.0, any.1, any.2, any.3, any.4, 45, any.5, any.6, any.7, 28 @@ -2372,76 +724,76 @@ any.0, any.1, any.2, any.3, any.4, 47, any.5, any.6, any.7, 30 any.0, any.1, any.2, any.3, any.4, 48, any.5, any.6, any.7, 31 any.0, any.1, any.2, any.3, any.4, 49, any.5, any.6, any.7, 32 # override northbound-signal transitions from ptr-movement section -#### line 460: (41, 42), N..NW any; [0] #### +#### line 338: (41, 42), N..NW any; [0] #### _q0.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, _q0.0 ############################ ##### 9 MOVEMENT ##### ############################ # Stop moving after reaching a comma or l-brack -#### line 468: 16, E (3, vac), SE..NE any; 87 #### +#### line 346: 16, E (3, vac), SE..NE any; 87 #### 16, any.0, any.1, _y0.0, any.2, any.3, any.4, any.5, any.6, 87 # just needs a random non-moving state, so blank_1 works -#### line 468: NE:0 #### +#### line 346: NE:0 #### any.0, any.1, any.2, any.3, any.4, _y0.0, 16, any.5, any.6, 0 # just needs a random non-moving state, so blank_1 works ## l-brack test stuff -#### line 470: (9, pointerOps), SE 4, S anyPrgm-8, SW..E any; 21 #### +#### line 348: (9, pointerOps), SE 4, S anyPrgm-8, SW..E any; 21 #### _z0.0, any.0, any.1, any.2, 4, _a1.0, any.3, any.4, any.5, 21 # send out a test signal -#### line 470: E:88 #### +#### line 348: E:88 #### any.0, any.1, any.2, any.3, any.4, 4, _a1.0, _z0.0, any.5, 88 # send out a test signal -#### line 471: 21, N northbound, NE..NW any; 87 #### +#### line 349: 21, N northbound, NE..NW any; 87 #### 21, northbound.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 87 -#### line 471: N:0 #### +#### line 349: N:0 #### northbound.0, any.0, any.1, any.2, any.3, 21, any.4, any.5, any.6, 0 -#### line 472: (87, 88), E 88, SE..NE any; [0: (88, 21)] #### +#### line 350: (87, 88), E 88, SE..NE any; [0: (88, 21)] #### 87, any.0, any.1, 88, any.2, any.3, any.4, any.5, any.6, 88 88, any.0, any.1, 88, any.2, any.3, any.4, any.5, any.6, 21 ### for most cases: -#### line 474: 88, NW (76, 79), N..SE any, S 4, SW..W any; [NW: (9, 95)] #### +#### line 352: 88, NW (76, 79), N..SE any, S 4, SW..W any; [NW: (9, 95)] #### 88, any.0, any.1, any.2, any.3, 4, any.4, any.5, 76, 9 88, any.0, any.1, any.2, any.3, 4, any.4, any.5, 79, 95 -#### line 474: W:0 #### +#### line 352: W:0 #### any.0, _b1.0, any.1, 88, 4, any.2, any.3, any.4, any.5, 0 -#### line 474: N:18 #### +#### line 352: N:18 #### any.0, any.1, any.2, any.3, any.4, 88, any.5, _b1.0, any.6, 18 ### and for when it's on an l-brack that's right after a first l-brack: -#### line 476: 88, N (76, 79), NE..SE any, S 4, SW..NW any; [N: (9, 95)] #### +#### line 354: 88, N (76, 79), NE..SE any, S 4, SW..NW any; [N: (9, 95)] #### 88, 76, any.0, any.1, any.2, 4, any.3, any.4, any.5, 9 88, 79, any.0, any.1, any.2, 4, any.3, any.4, any.5, 95 ### and one more edge case: -#### line 478: 88, NE (76, 79), E..SE any, S 4, SW..N any; [NE: (9, 95)] #### +#### line 356: 88, NE (76, 79), E..SE any, S 4, SW..N any; [NE: (9, 95)] #### 88, any.0, 76, any.1, any.2, 4, any.3, any.4, any.5, 9 88, any.0, 79, any.1, any.2, 4, any.3, any.4, any.5, 95 -#### line 478: E:0 #### +#### line 356: E:0 #### any.0, _b1.0, any.1, any.2, any.3, any.4, 4, 88, any.5, 0 ## keep moving eastward till pointer_skip finds an r-brack -#### line 480: 95, SE (3, 0), S..E any; 0 #### +#### line 358: 95, SE (3, 0), S..E any; 0 #### 95, any.0, any.1, any.2, _c1.0, any.3, any.4, any.5, any.6, 0 -#### line 480: E[SE: (9, 95, ...)] #### +#### line 358: E[SE: (9, 95, ...)] #### any.0, any.1, any.2, any.3, any.4, 3, any.5, 95, any.6, 9 any.0, any.1, any.2, any.3, any.4, _d1.0, any.5, 95, any.6, 95 -#### line 480: NE:18 #### +#### line 358: NE:18 #### any.0, any.1, any.2, any.3, any.4, any.5, 95, any.6, any.7, 18 # Also don't put out north-bound signals after hitting r-brack -#### line 482: pointerOps, N..NE any, E 3, SE..NW any; 9 #### +#### line 360: pointerOps, N..NE any, E 3, SE..NW any; 9 #### pointerOps.0, any.0, any.1, 3, any.2, any.3, any.4, any.5, any.6, 9 -#### line 482: NE:21 #### +#### line 360: NE:21 #### any.0, any.1, any.2, any.3, any.4, 3, pointerOps.0, any.5, any.6, 21 # But elsewhere do so as normal -#### line 484: (9, pointerOps), any, 0, vac, SE (4, prgm), S..SW vac, (4, vac), any; 57 #### +#### line 362: (9, pointerOps), any, 0, vac, SE (4, prgm), S..SW vac, (4, vac), any; 57 #### _z0.0, any.0, 0, vac.0, _m0.0, vac.1, vac.2, _e1.0, any.1, 57 -#### line 484: N[0: (_, northboundOps)] #### +#### line 362: N[0: (_, northboundOps)] #### any.0, any.1, any.2, 0, vac.0, 10, _e1.0, any.3, any.4, 19 any.0, any.1, any.2, 0, vac.0, 11, _e1.0, any.3, any.4, 20 any.0, any.1, any.2, 0, vac.0, 13, _e1.0, any.3, any.4, 22 any.0, any.1, any.2, 0, vac.0, 14, _e1.0, any.3, any.4, 23 any.0, any.1, any.2, 0, vac.0, 15, _e1.0, any.3, any.4, 24 any.0, any.1, any.2, 0, vac.0, 16, _e1.0, any.3, any.4, 25 -#### line 485: 57, N..NW any; 73 #### +#### line 363: 57, N..NW any; 73 #### 57, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 73 -#### line 486: 73, N..NW any; 94 #### +#### line 364: 73, N..NW any; 94 #### 73, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 94 # need 3 delay states to give data pointer breathing room from both sides -#### line 487: 94, any, 0, vac, SE (4, prgm), S..SW vac, (4, vac), any; 0 #### +#### line 365: 94, any, 0, vac, SE (4, prgm), S..SW vac, (4, vac), any; 0 #### 94, any.0, 0, vac.0, _m0.0, vac.1, vac.2, _e1.0, any.1, 0 -#### line 487: E[SE: (9, pointerOps)] #### +#### line 365: E[SE: (9, pointerOps)] #### vac.0, 0, any.0, any.1, any.2, 4, vac.1, 94, any.3, 9 vac.0, 0, any.0, any.1, any.2, 1, vac.1, 94, any.3, 10 vac.0, 0, any.0, any.1, any.2, 2, vac.1, 94, any.3, 11 @@ -2449,11 +801,11 @@ vac.0, 0, any.0, any.1, any.2, 5, vac.1, 94, any.3, 13 vac.0, 0, any.0, any.1, any.2, 6, vac.1, 94, any.3, 14 vac.0, 0, any.0, any.1, any.2, 7, vac.1, 94, any.3, 15 vac.0, 0, any.0, any.1, any.2, 8, vac.1, 94, any.3, 16 -#### line 488: 4, N 9, NE..E 0, SE (4, prgm), S..NW any; 4 #### +#### line 366: 4, N 9, NE..E 0, SE (4, prgm), S..NW any; 4 #### 4, 9, 0, 0, _m0.0, any.0, any.1, any.2, any.3, 4 -#### line 488: N:18 #### +#### line 366: N:18 #### 9, any.0, any.1, 0, 0, 4, any.2, any.3, any.4, 18 -#### line 488: E[SE: (88, pointerOps)] #### +#### line 366: E[SE: (88, pointerOps)] #### 0, 0, any.0, any.1, any.2, 4, any.3, 4, 9, 88 0, 0, any.0, any.1, any.2, 1, any.3, 4, 9, 10 0, 0, any.0, any.1, any.2, 2, any.3, 4, 9, 11 @@ -2461,55 +813,1701 @@ vac.0, 0, any.0, any.1, any.2, 8, vac.1, 94, any.3, 16 0, 0, any.0, any.1, any.2, 6, any.3, 4, 9, 14 0, 0, any.0, any.1, any.2, 7, any.3, 4, 9, 15 0, 0, any.0, any.1, any.2, 8, any.3, 4, 9, 16 -#### line 489: 0, S 88, SW 4, W 18, NW..SE 0; 21 #### +#### line 367: 0, S 88, SW 4, W 18, NW..SE 0; 21 #### 0, 0, 0, 0, 0, 88, 4, 18, 0, 21 -#### line 490: 0, S 21, SW 0, W 18, NW..SE any; 21 #### +#### line 368: 0, S 21, SW 0, W 18, NW..SE any; 21 #### 0, any.0, any.1, any.2, any.3, 21, 0, 18, any.4, 21 -#### line 490: S:0 #### +#### line 368: S:0 #### 21, 0, any.0, any.1, any.2, any.3, any.4, 0, 18, 0 # Replicate the above NE-output behavior if a bare pointer is on top of an 3 with another to its east # (this needs a special case; nothing happens otherwise) -#### line 493: 12, E (3, any), SE..NE any; 9 #### +#### line 371: 12, E (3, any), SE..NE any; 9 #### 12, any.0, any.1, _f1.0, any.2, any.3, any.4, any.5, any.6, 9 -#### line 493: NE[E: (21, _, ...)] #### +#### line 371: NE[E: (21, _, ...)] #### any.0, any.1, any.2, any.3, any.4, 3, 12, any.5, any.6, 21 # Make north_r_brack wait 4 generations before going up to absolutely make sure it won't collide badly with the data pointer -#### line 496: 21, W northbound, NW..SW any; [0] #### +#### line 374: 21, W northbound, NW..SW any; [0] #### 21, any.0, any.1, any.2, any.3, any.4, any.5, northbound.0, any.6, 21 -#### line 496: N:0 #### +#### line 374: N:0 #### any.0, any.1, any.2, any.3, any.4, 21, northbound.0, any.5, any.6, 0 -#### line 497: 21, NW northbound, N..W any; 87 #### +#### line 375: 21, NW northbound, N..W any; 87 #### 21, any.0, any.1, any.2, any.3, any.4, any.5, any.6, northbound.0, 87 # random non-interfering state (any would do) -#### line 497: N:0 #### +#### line 375: N:0 #### any.0, any.1, any.2, any.3, any.4, 21, any.5, northbound.0, any.6, 0 # random non-interfering state (any would do) -#### line 498: 87, S 3, SW..SE any; 3 #### +#### line 376: 87, S 3, SW..SE any; 3 #### 87, any.0, any.1, any.2, any.3, 3, any.4, any.5, any.6, 3 -#### line 499: 3, S 3, SW..SE any; 21 #### +#### line 377: 3, S 3, SW..SE any; 21 #### 3, any.0, any.1, any.2, any.3, 3, any.4, any.5, any.6, 21 # Move signals -#### line 501: N[0] #### +#### line 379: N[0] #### any.0, any.1, any.2, any.3, any.4, _g1.0, any.5, any.6, any.7, _g1.0 -#### line 501: (21, northboundNOP), N..NW any; 0 #### +#### line 379: (21, northboundNOP), N..NW any; 0 #### _g1.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 502: W[0] #### +#### line 380: W[0] #### any.0, any.1, any.2, _h1.0, any.3, any.4, any.5, any.6, any.7, _h1.0 -#### line 502: (28, westbound), N..NW any; 0 #### +#### line 380: (28, westbound), N..NW any; 0 #### _h1.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 503: E[0] #### +#### line 381: E[0] #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, _i1.0, any.7, _i1.0 -#### line 503: (35, eastbound), N..NW any; 0 #### +#### line 381: (35, eastbound), N..NW any; 0 #### _i1.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 504: (40, 79, 76), N..NW any; 0 #### +#### line 382: (40, 79, 76), N..NW any; 0 #### _j1.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 -#### line 504: S[0] #### +#### line 382: S[0] #### any.0, _j1.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, _j1.0 # 9 stops after reaching end -#### line 507: (9, 12, pointerOps), E..SE 0, S anyPrgm-4, SW..NE any; 0 #### +#### line 385: (9, 12, pointerOps), E..SE 0, S anyPrgm-4, SW..NE any; 0 #### _k1.0, any.0, any.1, 0, 0, _l1.0, any.2, any.3, any.4, 0 -#### line 507: E:9 #### +#### line 385: E:9 #### 0, any.0, any.1, any.2, any.3, 0, _l1.0, _k1.0, any.4, 9 # ...with some edge-case handling -#### line 509: 9, E 9, SE 0, S 3, SW..NE any; 0 #### +#### line 387: 9, E 9, SE 0, S 3, SW..NE any; 0 #### 9, any.0, any.1, 9, 0, 3, any.2, any.3, any.4, 0 # avoid double pointer if r-brack is the last character -#### line 510: 9, W 87, NW..S 0, SW any; 0 #### +#### line 388: 9, W 87, NW..S 0, SW any; 0 #### 9, 0, 0, 0, 0, 0, any.0, 87, 0, 0 # avoid punching through the prgm tape if comma is the last character + +@COLORS +0 0 0 0 +70 255 255 255 +85 255 255 0 +93 255 255 0 + +@ICONS +XPM +"15 1440 12 2" +".. c #000000" +"AA c #FFFFFF" +"BB c #00AA00" +"CC c #CC0000" +"DD c #666666" +"EE c #CCBB00" +"FF c #00AAFF" +"vc c #B7FFFF" +"_? c #DFFFFF" +"/7 c #FFFF00" +""\ c #E4FFFF" +"re c #F1FFFF" +/* #C Plus sign */ +/* icon for state 1 */ +"..........DDDDDDDDDD.........." +"........DDDDDDDDDDDDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +/* #C Minus sign */ +/* icon for state 2 */ +".............................." +".............................." +".............................." +".............................." +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +".............................." +".............................." +".............................." +".............................." +/* #C Right bracket */ +/* icon for state 3 */ +"......DDDDDDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDD........" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDDDDDDDDDDDDD........" +"......DDDDDDDDDDDDDD.........." +/* #C Left bracket */ +/* icon for state 4 */ +"..........DDDDDDDDDDDDDD......" +"........DDDDDDDDDDDDDDDD......" +"......DDDDDDAAAAAAAADDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDAAAADDDDDDDDDD......" +"......DDDDAAAADDDDDDDDDD......" +"......DDDDAAAADDDD............" +"......DDDDAAAADDDD............" +"......DDDDAAAADDDD............" +"......DDDDAAAADDDDDDDDDD......" +"......DDDDAAAADDDDDDDDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDDDAAAAAAAADDDD......" +"........DDDDDDDDDDDDDDDD......" +"..........DDDDDDDDDDDDDD......" +/* #C Left angle bracket */ +/* icon for state 5 */ +".............................." +"....................DDDDDDDDDD" +"................DDDDDDDDDDDDDD" +"............DDDDDDDDDDAAAADDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"DDDDDDAAAAAAAADDDDDDDDDDDD...." +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"............DDDDDDDDDDAAAADDDD" +"................DDDDDDDDDDDDDD" +"....................DDDDDDDDDD" +".............................." +/* #C Right angle bracket */ +/* icon for state 6 */ +".............................." +"DDDDDDDDDD...................." +"DDDDDDDDDDDDDD................" +"DDDDAAAADDDDDDDDDD............" +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"....DDDDDDDDDDDDAAAAAAAADDDDDD" +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDAAAADDDDDDDDDD............" +"DDDDDDDDDDDDDD................" +"DDDDDDDDDD...................." +".............................." +/* #C Period */ +/* icon for state 7 */ +".............................." +"..........DDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDAAAAAADDDDDDDD...." +"....DDDDAAAAAAAAAAAAAADDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAAAADDDD...." +"....DDDDDDDDAAAAAADDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +"..........DDDDDDDDDD.........." +".............................." +/* #C Comma */ +/* icon for state 8 */ +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDDDDDDDDDDDDDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAAAADDDD.." +"....DDDDDDDDDDDDAAAAAAAADDDD.." +"........DDDDDDDDAAAAAAAADDDD.." +"....DDDDDDDDDDAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAADDDDDDDD.." +"....DDDDDDDDDDDDDDDDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +/* #C "V" shape; instruction pointer */ +/* icon for state 9 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 10 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 11 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 12 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 13 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 14 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 15 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 16 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 17 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* #C empty space/shadow */ +/* icon for state 18 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C Plus sign */ +/* icon for state 19 */ +"..........DDDDDDDDDD.........." +"........DDDDDDDDDDDDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +/* #C Minus sign */ +/* icon for state 20 */ +".............................." +".............................." +".............................." +".............................." +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +".............................." +".............................." +".............................." +".............................." +/* #C Right bracket */ +/* icon for state 21 */ +"......DDDDDDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDD........" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDDDDDDDDDDDDD........" +"......DDDDDDDDDDDDDD.........." +/* #C Left angle bracket */ +/* icon for state 22 */ +".............................." +"....................DDDDDDDDDD" +"................DDDDDDDDDDDDDD" +"............DDDDDDDDDDAAAADDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"DDDDDDAAAAAAAADDDDDDDDDDDD...." +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"............DDDDDDDDDDAAAADDDD" +"................DDDDDDDDDDDDDD" +"....................DDDDDDDDDD" +".............................." +/* #C Right angle bracket */ +/* icon for state 23 */ +".............................." +"DDDDDDDDDD...................." +"DDDDDDDDDDDDDD................" +"DDDDAAAADDDDDDDDDD............" +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"....DDDDDDDDDDDDAAAAAAAADDDDDD" +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDAAAADDDDDDDDDD............" +"DDDDDDDDDDDDDD................" +"DDDDDDDDDD...................." +".............................." +/* #C Period */ +/* icon for state 24 */ +".............................." +"..........DDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDAAAAAADDDDDDDD...." +"....DDDDAAAAAAAAAAAAAADDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAAAADDDD...." +"....DDDDDDDDAAAAAADDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +"..........DDDDDDDDDD.........." +".............................." +/* #C Comma */ +/* icon for state 25 */ +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDDDDDDDDDDDDDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAAAADDDD.." +"....DDDDDDDDDDDDAAAAAAAADDDD.." +"........DDDDDDDDAAAAAAAADDDD.." +"....DDDDDDDDDDAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAADDDDDDDD.." +"....DDDDDDDDDDDDDDDDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +/* #C Plus sign */ +/* icon for state 26 */ +"..........DDDDDDDDDD.........." +"........DDDDDDDDDDDDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +/* #C Minus sign */ +/* icon for state 27 */ +".............................." +".............................." +".............................." +".............................." +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +".............................." +".............................." +".............................." +".............................." +/* #C Right bracket */ +/* icon for state 28 */ +"......DDDDDDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDD........" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDDDDDDDDDDDDD........" +"......DDDDDDDDDDDDDD.........." +/* #C Left angle bracket */ +/* icon for state 29 */ +".............................." +"....................DDDDDDDDDD" +"................DDDDDDDDDDDDDD" +"............DDDDDDDDDDAAAADDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"DDDDDDAAAAAAAADDDDDDDDDDDD...." +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"............DDDDDDDDDDAAAADDDD" +"................DDDDDDDDDDDDDD" +"....................DDDDDDDDDD" +".............................." +/* #C Right angle bracket */ +/* icon for state 30 */ +".............................." +"DDDDDDDDDD...................." +"DDDDDDDDDDDDDD................" +"DDDDAAAADDDDDDDDDD............" +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"....DDDDDDDDDDDDAAAAAAAADDDDDD" +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDAAAADDDDDDDDDD............" +"DDDDDDDDDDDDDD................" +"DDDDDDDDDD...................." +".............................." +/* #C Period */ +/* icon for state 31 */ +".............................." +"..........DDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDAAAAAADDDDDDDD...." +"....DDDDAAAAAAAAAAAAAADDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAAAADDDD...." +"....DDDDDDDDAAAAAADDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +"..........DDDDDDDDDD.........." +".............................." +/* #C Comma */ +/* icon for state 32 */ +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDDDDDDDDDDDDDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAAAADDDD.." +"....DDDDDDDDDDDDAAAAAAAADDDD.." +"........DDDDDDDDAAAAAAAADDDD.." +"....DDDDDDDDDDAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAADDDDDDDD.." +"....DDDDDDDDDDDDDDDDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +/* #C Plus sign */ +/* icon for state 33 */ +"..........DDDDDDDDDD.........." +"........DDDDDDDDDDDDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDAAAAAADDDDDDDDDDDD" +"..DDDDDDDDDDAAAAAADDDDDDDDDD.." +"........DDDDAAAAAADDDD........" +"........DDDDAAAAAADDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +/* #C Minus sign */ +/* icon for state 34 */ +".............................." +".............................." +".............................." +".............................." +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDAAAAAAAAAAAAAAAAAAAAAADDDD" +"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" +"..DDDDDDDDDDDDDDDDDDDDDDDDDD.." +".............................." +".............................." +".............................." +".............................." +/* #C Right bracket */ +/* icon for state 35 */ +"......DDDDDDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDD........" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"............DDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDDDDDDDAAAADDDD......" +"......DDDDAAAAAAAAAADDDD......" +"......DDDDAAAAAAAADDDDDD......" +"......DDDDDDDDDDDDDDDD........" +"......DDDDDDDDDDDDDD.........." +/* #C Left angle bracket */ +/* icon for state 36 */ +".............................." +"....................DDDDDDDDDD" +"................DDDDDDDDDDDDDD" +"............DDDDDDDDDDAAAADDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"DDDDDDAAAAAAAADDDDDDDDDDDD...." +"DDDDDDDDDDAAAAAAAADDDDDDDDDDDD" +"....DDDDDDDDDDAAAAAAAADDDDDDDD" +"........DDDDDDDDDDAAAAAAAADDDD" +"............DDDDDDDDDDAAAADDDD" +"................DDDDDDDDDDDDDD" +"....................DDDDDDDDDD" +".............................." +/* #C Right angle bracket */ +/* icon for state 37 */ +".............................." +"DDDDDDDDDD...................." +"DDDDDDDDDDDDDD................" +"DDDDAAAADDDDDDDDDD............" +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"....DDDDDDDDDDDDAAAAAAAADDDDDD" +"DDDDDDDDDDDDAAAAAAAADDDDDDDDDD" +"DDDDDDDDAAAAAAAADDDDDDDDDD...." +"DDDDAAAAAAAADDDDDDDDDD........" +"DDDDAAAADDDDDDDDDD............" +"DDDDDDDDDDDDDD................" +"DDDDDDDDDD...................." +".............................." +/* #C Period */ +/* icon for state 38 */ +".............................." +"..........DDDDDDDDDD.........." +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDAAAAAADDDDDDDD...." +"....DDDDAAAAAAAAAAAAAADDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAAAADDDD...." +"....DDDDDDDDAAAAAADDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +"..........DDDDDDDDDD.........." +".............................." +/* #C Comma */ +/* icon for state 39 */ +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDDDDDDDDDDDDDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAAAADDDD.." +"....DDDDDDDDDDDDAAAAAAAADDDD.." +"........DDDDDDDDAAAAAAAADDDD.." +"....DDDDDDDDDDAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAADDDDDDDD.." +"....DDDDDDDDDDDDDDDDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +/* #C Comma */ +/* icon for state 40 */ +"......DDDDDDDDDDDDDDDDDD......" +"....DDDDDDDDDDDDDDDDDDDDDD...." +"..DDDDDDAAAAAAAAAAAAAADDDDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDAAAAAAAAAAAAAAAAAADDDD.." +"..DDDDDDAAAAAAAAAAAAAAAADDDD.." +"....DDDDDDDDDDDDAAAAAAAADDDD.." +"........DDDDDDDDAAAAAAAADDDD.." +"....DDDDDDDDDDAAAAAAAADDDDDD.." +"....DDDDAAAAAAAAAAAADDDDDDDD.." +"....DDDDDDDDDDDDDDDDDDDDDD...." +"......DDDDDDDDDDDDDDDDDD......" +/* #C empty space/shadow */ +/* icon for state 41 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 42 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 43 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 44 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 45 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 46 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 47 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 48 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 49 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 50 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 51 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 52 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 53 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 54 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 55 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 56 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C Darker "V" shape; delayed pointer */ +/* icon for state 57 */ +".............................." +"....DDDDDDDD......DDDDDDDD...." +"....DDDDDDDD......DDDDDDDD...." +"....DDDDDDDDDD..DDDDDDDDDD...." +"......DDDDDDDD..DDDDDDDD......" +"......DDDDDDDDDDDDDDDDDD......" +"........DDDDDDDDDDDDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +"..........DDDDDDDDDD.........." +"............DDDDDD............" +"............DDDDDD............" +"..............DD.............." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 58 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 59 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 60 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 61 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 62 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 63 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 64 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Data pointer */ +/* icon for state 65 */ +".............................." +".............................." +"............EEEEEE............" +"............EEEEEE............" +"..........EEEEEEEEEE.........." +"..........EEEEEEEEEE.........." +"........EEEEEEEEEEEEEE........" +"........EEEEEEEEEEEEEE........" +"......EEEEEEEEEEEEEEEEEE......" +"......EEEEEEEE..EEEEEEEE......" +"....EEEEEEEEEE..EEEEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +"....EEEEEEEE......EEEEEEEE...." +".............................." +".............................." +/* #C Inert data */ +/* icon for state 66 */ +".............................." +"................EEEEEEEE......" +"..............EEEEEEEEEEEE...." +"............EEEEEEEEEEEEEEEE.." +"..........EEEEEEEEEEEEEEEEEE.." +"........EEEEEEEEEEEEEEEEEEEE.." +"......EEEEEEEEEEEEEEEEEEEEEE.." +"....EEEEEEEEEEEEEEEEEEEEEE...." +"..EEEEEEEEEEEEEEEEEEEEEE......" +"..EEEEEEEEEEEEEEEEEEEE........" +"..EEEEEEEEEEEEEEEEEE.........." +"..EEEEEEEEEEEEEEEE............" +"....EEEEEEEEEEEE.............." +"......EEEEEEEE................" +".............................." +/* #C Active forward-moving data */ +/* icon for state 67 */ +"....AAAAAAAAAAAAAAAAAAAAAAAAAA" +"......AABBBBBBBBBBBBBBBBBBBBAA" +"........AABBBBBBBBBBBBBBBBBBAA" +"........AABBBBBBBBBBBBBBBBBBAA" +"......AABBBBBBBBBBBBBBBBBBBBAA" +"....AABBBBBBBBBBBBBBBBBBBBBBAA" +"..AABBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"..AABBBBBBBBBBBBBBBBBBAAAABBAA" +"....AABBBBBBBBBBBBBBAA....AAAA" +"......AABBBBBBBBBBAA........AA" +"........AABBBBBBAA............" +"..........AAAAAA.............." +/* #C Active forward-moving data */ +/* icon for state 68 */ +"....AAAAAAAAAAAAAAAAAAAAAAAAAA" +"......AABBBBBBBBBBBBBBBBBBBBAA" +"........AABBBBBBBBBBBBBBBBBBAA" +"........AABBBBBBBBBBBBBBBBBBAA" +"......AABBBBBBBBBBBBBBBBBBBBAA" +"....AABBBBBBBBBBBBBBBBBBBBBBAA" +"..AABBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"..AABBBBBBBBBBBBBBBBBBAAAABBAA" +"....AABBBBBBBBBBBBBBAA....AAAA" +"......AABBBBBBBBBBAA........AA" +"........AABBBBBBAA............" +"..........AAAAAA.............." +/* icon for state 69 */ +"vcvcvcvcvcvcvcvcvcvcvcvcvcvcvc" +"vcvcvcvc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BBBBBBBBBBBBBBBBAA" +"........AABBBBBBBBBBBBBBBBBBAA" +"........AABBBBBBBBBBBBBBBBBBAA" +"......AABBBBBBBBBBBBBBBBBBBBAA" +"....AABBBBBBBBBBBBBBBBBBBBBBAA" +"..AABBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"AABBBBBBBBBBBBBBBBBBBBBBBBBBAA" +"..AABBBBBBBBBBBBBBBBBBAAAABBAA" +"....AABBBBBBBBBBBBBBAA....AAAA" +"......AABBBBBBBBBBAA........AA" +"........AABBBBBBAA............" +"..........AAAAAA.............." +/* #C Active backward-moving data */ +/* icon for state 72 */ +"..............AAAAAA.........." +"............AAFFFFFFAA........" +"AA........AAFFFFFFFFFFAA......" +"AAAA....AAFFFFFFFFFFFFFFAA...." +"AAFFAAAAFFFFFFFFFFFFFFFFFFAA.." +"AAFFFFFFFFFFFFFFFFFFFFFFFFFFAA" +"AAFFFFFFFFFFFFFFFFFFFFFFFFFFAA" +"AAFFFFFFFFFFFFFFFFFFFFFFFFFFAA" +"AAFFFFFFFFFFFFFFFFFFFFFFFFAA.." +"AAFFFFFFFFFFFFFFFFFFFFFFAA...." +"AAFFFFFFFFFFFFFFFFFFFFAA......" +"AAFFFFFFFFFFFFFFFFFFAA........" +"AAFFFFFFFFFFFFFFFFFFAA........" +"AAFFFFFFFFFFFFFFFFFFFFAA......" +"AAAAAAAAAAAAAAAAAAAAAAAAAA...." +/* #C Darker "V" shape; delayed pointer */ +/* icon for state 73 */ +".............................." +"....DDDDDDDD......DDDDDDDD...." +"....DDDDDDDD......DDDDDDDD...." +"....DDDDDDDDDD..DDDDDDDDDD...." +"......DDDDDDDD..DDDDDDDD......" +"......DDDDDDDDDDDDDDDDDD......" +"........DDDDDDDDDDDDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +"..........DDDDDDDDDD.........." +"............DDDDDD............" +"............DDDDDD............" +"..............DD.............." +".............................." +".............................." +/* #C Check mark ('yes', aka 'loop') */ +/* icon for state 74 */ +".............................." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBAABB.." +"..BBBBBBBBBBBBBBBBBBBBAAAABB.." +"..BBBBBBBBBBBBBBBBBBAAAAAABB.." +"..BBBBBBBBBBBBBBBBAAAAAABBBB.." +"..BBBBAABBBBBBBBAAAAAABBBBBB.." +"..BBBBAAAABBBBAAAAAABBBBBBBB.." +"..BBBBAAAAAAAAAAAABBBBBBBBBB.." +"..BBBBBBAAAAAAAABBBBBBBBBBBB.." +"..BBBBBBBBAAAABBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +".............................." +/* #C Check mark ('yes', aka 'loop') */ +/* icon for state 75 */ +".............................." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBAABB.." +"..BBBBBBBBBBBBBBBBBBBBAAAABB.." +"..BBBBBBBBBBBBBBBBBBAAAAAABB.." +"..BBBBBBBBBBBBBBBBAAAAAABBBB.." +"..BBBBAABBBBBBBBAAAAAABBBBBB.." +"..BBBBAAAABBBBAAAAAABBBBBBBB.." +"..BBBBAAAAAAAAAAAABBBBBBBBBB.." +"..BBBBBBAAAAAAAABBBBBBBBBBBB.." +"..BBBBBBBBAAAABBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +".............................." +/* #C Check mark ('yes', aka 'loop') */ +/* icon for state 76 */ +".............................." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBAABB.." +"..BBBBBBBBBBBBBBBBBBBBAAAABB.." +"..BBBBBBBBBBBBBBBBBBAAAAAABB.." +"..BBBBBBBBBBBBBBBBAAAAAABBBB.." +"..BBBBAABBBBBBBBAAAAAABBBBBB.." +"..BBBBAAAABBBBAAAAAABBBBBBBB.." +"..BBBBAAAAAAAAAAAABBBBBBBBBB.." +"..BBBBBBAAAAAAAABBBBBBBBBBBB.." +"..BBBBBBBBAAAABBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +"..BBBBBBBBBBBBBBBBBBBBBBBBBB.." +".............................." +/* #C X sign ('no', aka 'break') */ +/* icon for state 77 */ +".............................." +"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." +"..CCAAAACCCCCCCCCCCCCCAAAACC.." +"..CCAAAAAACCCCCCCCCCAAAAAACC.." +"..CCCCAAAAAACCCCCCAAAAAACCCC.." +"..CCCCCCAAAAAACCAAAAAACCCCCC.." +"..CCCCCCCCAAAAAAAAAACCCCCCCC.." +"..CCCCCCCCCCAAAAAACCCCCCCCCC.." +"..CCCCCCCCAAAAAAAAAACCCCCCCC.." +"..CCCCCCAAAAAACCAAAAAACCCCCC.." +"..CCCCAAAAAACCCCCCAAAAAACCCC.." +"..CCAAAAAACCCCCCCCCCAAAAAACC.." +"..CCAAAACCCCCCCCCCCCCCAAAACC.." +"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." +".............................." +/* #C X sign ('no', aka 'break') */ +/* icon for state 78 */ +".............................." +"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." +"..CCAAAACCCCCCCCCCCCCCAAAACC.." +"..CCAAAAAACCCCCCCCCCAAAAAACC.." +"..CCCCAAAAAACCCCCCAAAAAACCCC.." +"..CCCCCCAAAAAACCAAAAAACCCCCC.." +"..CCCCCCCCAAAAAAAAAACCCCCCCC.." +"..CCCCCCCCCCAAAAAACCCCCCCCCC.." +"..CCCCCCCCAAAAAAAAAACCCCCCCC.." +"..CCCCCCAAAAAACCAAAAAACCCCCC.." +"..CCCCAAAAAACCCCCCAAAAAACCCC.." +"..CCAAAAAACCCCCCCCCCAAAAAACC.." +"..CCAAAACCCCCCCCCCCCCCAAAACC.." +"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." +".............................." +/* #C X sign ('no', aka 'break') */ +/* icon for state 79 */ +".............................." +"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." +"..CCAAAACCCCCCCCCCCCCCAAAACC.." +"..CCAAAAAACCCCCCCCCCAAAAAACC.." +"..CCCCAAAAAACCCCCCAAAAAACCCC.." +"..CCCCCCAAAAAACCAAAAAACCCCCC.." +"..CCCCCCCCAAAAAAAAAACCCCCCCC.." +"..CCCCCCCCCCAAAAAACCCCCCCCCC.." +"..CCCCCCCCAAAAAAAAAACCCCCCCC.." +"..CCCCCCAAAAAACCAAAAAACCCCCC.." +"..CCCCAAAAAACCCCCCAAAAAACCCC.." +"..CCAAAAAACCCCCCCCCCAAAAAACC.." +"..CCAAAACCCCCCCCCCCCCCAAAACC.." +"..CCCCCCCCCCCCCCCCCCCCCCCCCC.." +".............................." +/* #C empty space/shadow */ +/* icon for state 80 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 81 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 82 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 83 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* icon for state 84 */ +"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" +"_?_?_?_?_?_?_?_?_?_?_?_?_?_?_?" +"_?_?_?_?_?_?_?_?_?_?_?_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"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +""\"\"\"\"\"\"\"\"\"\"\"\"\"\"\" +/* #C empty space/shadow */ +/* icon for state 87 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 88 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C empty space/shadow */ +/* icon for state 89 */ +".............................." +"........AAAAAAAAAAAAAA........" +"....AAAAAADDDDDDDDDDAAAAAA...." +"....AADDDDDDDDDDDDDDDDDDAA...." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"..AADDDD......DD......DDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDDDDDD......DDDDDDDDAA.." +"..AADDDDDD..........DDDDDDAA.." +"..AADDDD......DD......DDDDAA.." +"..AAAADDDD..DDDDDD..DDDDAAAA.." +"....AADDDDDDDDDDDDDDDDDDAA...." +"....AAAAAADDDDDDDDDDAAAAAA...." +"........AAAAAAAAAAAAAA........" +".............................." +/* #C Digit zero */ +/* icon for state 90 */ +".............................." +"..........CCCCCCCCCC.........." +"........CCAAAAAAAAAACC........" +"......CCAAAAAAAAAAAAAACC......" +"......CCAAAACCCCCCAAAACC......" +"......CCAAAACCCCAAAAAACC......" +"......CCAAAACCAAAAAAAACC......" +"......CCAAAAAAAAAAAAAACC......" +"......CCAAAAAAAACCAAAACC......" +"......CCAAAAAACCCCAAAACC......" +"......CCAAAACCCCCCAAAACC......" +"......CCAAAAAAAAAAAAAACC......" +"........CCAAAAAAAAAACC........" +"..........CCCCCCCCCC.........." +".............................." +/* icon for state 91 */ +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +"rerererererererererererererere" +/* #C Digit zero */ +/* icon for state 92 */ +".............................." +"..........CCCCCCCCCC.........." +"........CCAAAAAAAAAACC........" +"......CCAAAAAAAAAAAAAACC......" +"......CCAAAACCCCCCAAAACC......" +"......CCAAAACCCCAAAAAACC......" +"......CCAAAACCAAAAAAAACC......" +"......CCAAAAAAAAAAAAAACC......" +"......CCAAAAAAAACCAAAACC......" +"......CCAAAAAACCCCAAAACC......" +"......CCAAAACCCCCCAAAACC......" +"......CCAAAAAAAAAAAAAACC......" +"........CCAAAAAAAAAACC........" +"..........CCCCCCCCCC.........." +".............................." +/* icon for state 93 */ +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +"/7/7/7/7/7/7/7/7/7/7/7/7/7/7/7" +/* #C Darker "V" shape; delayed pointer */ +/* icon for state 94 */ +".............................." +"....DDDDDDDD......DDDDDDDD...." +"....DDDDDDDD......DDDDDDDD...." +"....DDDDDDDDDD..DDDDDDDDDD...." +"......DDDDDDDD..DDDDDDDD......" +"......DDDDDDDDDDDDDDDDDD......" +"........DDDDDDDDDDDDDD........" +"........DDDDDDDDDDDDDD........" +"..........DDDDDDDDDD.........." +"..........DDDDDDDDDD.........." +"............DDDDDD............" +"............DDDDDD............" +"..............DD.............." +".............................." +".............................." +/* #C "V" shape; instruction pointer */ +/* icon for state 95 */ +".............................." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAA......AAAAAAAA...." +"....AAAAAAAAAA..AAAAAAAAAA...." +"......AAAAAAAA..AAAAAAAA......" +"......AAAAAAAAAAAAAAAAAA......" +"........AAAAAAAAAAAAAA........" +"........AAAAAAAAAAAAAA........" +"..........AAAAAAAAAA.........." +"..........AAAAAAAAAA.........." +"............AAAAAA............" +"............AAAAAA............" +"..............AA.............." +".............................." +".............................." +/* icon for state 96 */ +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" diff --git a/examples/nutshells/bf.ruel b/examples/nutshells/bf.ruel index d2914a4..b49a628 100644 --- a/examples/nutshells/bf.ruel +++ b/examples/nutshells/bf.ruel @@ -136,130 +136,8 @@ Brainfuck. the input tape will right itself automatically once the simulation starts.) + An example: - x = 61, y = 13, rule = bf - 53.qR$52.qR$51.qR$50.qR$49.qR$47.2qR$42.qR3.2qR$41.qR3.2qR$41.qJ$43.pR - $7rSrU12rSrU10rSrUrTrU5rSrM$43.I$44.AB2DFHCHCEDGDBCEC! - - -@COLORS -000: 0 -FFF: FinalZeroOut -FF0: InputHead, FreshInputHead - - -@ICONS -? 0FF .. FFF -0: 000 -1: FDF -2: 0A0 -3: C00 -4: 777 -5: CB0 -6: 0AB - -#C empty space/shadow -#C NorthNOP, EastShadow..EastShadowComma, WestShadowBreak..EastShadowLoop, Blank1..BlankEast -x = 13, y = 13, rule = bf -3.7A$.3A5D3A$.A9DA$2A2D.3D.2D2A$A2D3.D3.2DA$A3D5.3DA$A4D3.4DA$A3D5.3D -A$A2D3.D3.2DA$2A2D.3D.2D2A$.A9DA$.3A5D3A$3.7A! - -#C Left bracket -#C LBrack -x = 9, y = 15, rule = bf -2.7D$.8D$3D4A2D$2D5A2D$2D2A5D$2D2A5D$2D2A2D$2D2A2D$2D2A2D$2D2A5D$2D2A -5D$2D5A2D$3D4A2D$.8D$2.7D! - -#C Right bracket -#C RBrack, NorthRBrack, WestRBrack, EastRBrack -x = 9, y = 15, rule = bf -7D$8D$2D4A3D$2D5A2D$5D2A2D$5D2A2D$3.2D2A2D$3.2D2A2D$3.2D2A2D$5D2A2D$ -5D2A2D$2D5A2D$2D4A3D$8D$7D! - -#C Plus sign -#C Plus, NorthPlus, WestPlus, EastPlus -x = 15, y = 15, rule = bf -5.5D$4.7D$4.2D3A2D$4.2D3A2D$.5D3A5D$6D3A6D$2D11A2D$2D11A2D$2D11A2D$6D -3A6D$.5D3A5D$4.2D3A2D$4.2D3A2D$4.7D$5.5D! - -#C Minus sign -#C Minus, NorthMinus, WestMinus, EastMinus -x = 15, y = 7, rule = bf -.13D$15D$2D11A2D$2D11A2D$2D11A2D$15D$.13D! - -#C Left angle bracket -#C LAngle, NorthLAngle, WestLAngle, EastLAngle -x = 15, y = 13, rule = bf -10.5D$8.7D$6.5D2A2D$4.5D4A2D$2.5D4A4D$5D4A6D$3D4A6D$5D4A6D$2.5D4A4D$ -4.5D4A2D$6.5D2A2D$8.7D$10.5D! - -#C Right angle bracket -#C RAngle, NorthRAngle, WestRAngle, EastRAngle -x = 15, y = 13, rule = bf -5D$7D$2D2A5D$2D4A5D$4D4A5D$6D4A5D$2.6D4A3D$6D4A5D$4D4A5D$2D4A5D$2D2A -5D$7D$5D! - -#C Comma -#C Comma, NorthComma, WestComma, EastComma, SouthComma -x = 13, y = 15, rule = bf -2.9D$.11D$3D7A3D$2D9A2D$2D9A2D$2D9A2D$2D9A2D$2D9A2D$3D8A2D$.6D4A2D$3. -4D4A2D$.5D4A3D$.2D6A4D$.11D$2.9D! - -#C Period -#C Dot, NorthDot, WestDot, EastDot -x = 13, y = 13, rule = bf -4.5D$2.9D$.4D3A4D$.2D7A2D$3D7A3D$2D9A2D$2D9A2D$2D9A2D$3D7A3D$.2D7A2D$ -.4D3A4D$2.9D$4.5D! - -#C "V" shape; instruction pointer -#C Pointer..WestPointer, PointerSkip -x = 11, y = 12, rule = bf -4A3.4A$4A3.4A$5A.5A$.4A.4A$.9A$2.7A$2.7A$3.5A$3.5A$4.3A$4.3A$5.A! - -#C Darker "V" shape; delayed pointer -#C DelayedPointer, DelayedPointer2, DelayedPointer3 -x = 11, y = 12, rule = bf -4D3.4D$4D3.4D$5D.5D$.4D.4D$.9D$2.7D$2.7D$3.5D$3.5D$4.3D$4.3D$5.D! - -#C Data pointer -#C DataPointer..DataPointerComma -x = 11, y = 11, rule = bf -4.3E$4.3E$3.5E$3.5E$2.7E$2.7E$.9E$.4E.4E$5E.5E$4E3.4E$4E3.4E! - -#C Inert data -#C Data -x = 13, y = 13, rule = bf -7.4E$6.6E$5.8E$4.9E$3.10E$2.11E$.11E$11E$10E$9E$8E$.6E$2.4E! - -#C Active forward-moving data -#C DataOut, FinalDataOut, DataPlus -x = 14, y = 14, rule = bf -5.9C$4.10C$4.2C6A2C$4.3C5A2C$4.4C4A2C$3.4C5A2C$2.4C3AC2A2C$.4C3A3CA2C -$4C3A7C$3C3A7C$3C2A4C$8C$.6C$2.4C! - -#C Active backward-moving data -#C DataMinus -x = 14, y = 14, rule = bf -8.4F$7.6F$6.8F$5.4F2A3F$.7F3A3F$7F3A4F$2FA3F3A4F$2F2AF3A4F$2F5A4F$2F -4A4F$2F5A3F$2F6A2F$10F$9F! - - -#C Check mark ('yes', aka 'loop') -#C EastLoop..SouthLoop -x = 13, y = 13, rule = bf -13B$13B$11BAB$10B2AB$9B3AB$8B3A2B$2BA4B3A3B$2B2A2B3A4B$2B6A5B$3B4A6B$ -4B2A7B$13B$13B! - -#C X sign ('no', aka 'break') -#C EastBreak..SouthBreak -x = 13, y = 13, rule = bf -13C$C2A7C2AC$C3A5C3AC$2C3A3C3A2C$3C3AC3A3C$4C5A4C$5C3A5C$4C5A4C$3C3AC -3A3C$2C3A3C3A2C$C3A5C3AC$C2A7C2AC$13C! - -#C Digit zero -#C Input0, FreshInput0 -x = 9, y = 13, rule = bf -2.5C$.C5AC$C7AC$C2A3C2AC$C2A2C3AC$C2AC4AC$C7AC$C4AC2AC$C3A2C2AC$C2A3C -2AC$C7AC$.C5AC$2.5C! +x = 19, y = 5, rule = bf +4.qJ$6.pR$2rSrM$6.I$7.H2DF2AEBCFGC! @TABLE @@ -508,3 +386,122 @@ RBrack, S RBrack, SW..SE any; NorthRBrack # ...with some edge-case handling Pointer, E Pointer, SE 0, S RBrack, SW..NE any; 0 # avoid double pointer if r-brack is the last character Pointer, W Blank1, NW..S 0, SW any; 0 # avoid punching through the prgm tape if comma is the last character + +@COLORS +000: 0 +FFF: FinalZeroOut +FF0: InputHead, FreshInputHead + + +@ICONS +? 0FF .. FFF +0: 000 +1: FFF +2: 0A0 +3: C00 +4: 666 +5: CB0 +6: 0AF + +#C empty space/shadow +#C NorthNOP, EastShadow..EastShadowComma, WestShadowBreak..EastShadowLoop, Blank1..BlankEast +x = 13, y = 13, rule = bf +3.7A$.3A5D3A$.A9DA$2A2D.3D.2D2A$A2D3.D3.2DA$A3D5.3DA$A4D3.4DA$A3D5.3D +A$A2D3.D3.2DA$2A2D.3D.2D2A$.A9DA$.3A5D3A$3.7A! + +#C Left bracket +#C LBrack +x = 9, y = 15, rule = bf +2.7D$.8D$3D4A2D$2D5A2D$2D2A5D$2D2A5D$2D2A2D$2D2A2D$2D2A2D$2D2A5D$2D2A +5D$2D5A2D$3D4A2D$.8D$2.7D! + +#C Right bracket +#C RBrack, NorthRBrack, WestRBrack, EastRBrack +x = 9, y = 15, rule = bf +7D$8D$2D4A3D$2D5A2D$5D2A2D$5D2A2D$3.2D2A2D$3.2D2A2D$3.2D2A2D$5D2A2D$ +5D2A2D$2D5A2D$2D4A3D$8D$7D! + +#C Plus sign +#C Plus, NorthPlus, WestPlus, EastPlus +x = 15, y = 15, rule = bf +5.5D$4.7D$4.2D3A2D$4.2D3A2D$.5D3A5D$6D3A6D$2D11A2D$2D11A2D$2D11A2D$6D +3A6D$.5D3A5D$4.2D3A2D$4.2D3A2D$4.7D$5.5D! + +#C Minus sign +#C Minus, NorthMinus, WestMinus, EastMinus +x = 15, y = 7, rule = bf +.13D$15D$2D11A2D$2D11A2D$2D11A2D$15D$.13D! + +#C Left angle bracket +#C LAngle, NorthLAngle, WestLAngle, EastLAngle +x = 15, y = 13, rule = bf +10.5D$8.7D$6.5D2A2D$4.5D4A2D$2.5D4A4D$5D4A6D$3D4A6D$5D4A6D$2.5D4A4D$ +4.5D4A2D$6.5D2A2D$8.7D$10.5D! + +#C Right angle bracket +#C RAngle, NorthRAngle, WestRAngle, EastRAngle +x = 15, y = 13, rule = bf +5D$7D$2D2A5D$2D4A5D$4D4A5D$6D4A5D$2.6D4A3D$6D4A5D$4D4A5D$2D4A5D$2D2A +5D$7D$5D! + +#C Comma +#C Comma, NorthComma, WestComma, EastComma, SouthComma +x = 13, y = 15, rule = bf +2.9D$.11D$3D7A3D$2D9A2D$2D9A2D$2D9A2D$2D9A2D$2D9A2D$3D8A2D$.6D4A2D$3. +4D4A2D$.5D4A3D$.2D6A4D$.11D$2.9D! + +#C Period +#C Dot, NorthDot, WestDot, EastDot +x = 13, y = 13, rule = bf +4.5D$2.9D$.4D3A4D$.2D7A2D$3D7A3D$2D9A2D$2D9A2D$2D9A2D$3D7A3D$.2D7A2D$ +.4D3A4D$2.9D$4.5D! + +#C "V" shape; instruction pointer +#C Pointer..WestPointer, PointerSkip +x = 11, y = 12, rule = bf +4A3.4A$4A3.4A$5A.5A$.4A.4A$.9A$2.7A$2.7A$3.5A$3.5A$4.3A$4.3A$5.A! + +#C Darker "V" shape; delayed pointer +#C DelayedPointer, DelayedPointer2, DelayedPointer3 +x = 11, y = 12, rule = bf +4D3.4D$4D3.4D$5D.5D$.4D.4D$.9D$2.7D$2.7D$3.5D$3.5D$4.3D$4.3D$5.D! + +#C Data pointer +#C DataPointer..DataPointerComma +x = 11, y = 11, rule = bf +4.3E$4.3E$3.5E$3.5E$2.7E$2.7E$.9E$.4E.4E$5E.5E$4E3.4E$4E3.4E! + +#C Inert data +#C Data +x = 13, y = 13, rule = bf +7.4E$6.6E$5.8E$4.9E$3.10E$2.11E$.11E$11E$10E$9E$8E$.6E$2.4E! + +#C Active forward-moving data +#C DataOut, FinalDataOut, DataPlus +x = 15, y = 15, rule = bf +2.13A$3.A10BA$4.A9BA$4.A9BA$3.A10BA$2.A11BA$.A12BA$A13BA$A13BA$A13BA$ +.A9B2ABA$2.A7BA2.2A$3.A5BA4.A$4.A3BA$5.3A! + +#C Active backward-moving data +#C DataMinus +x = 15, y = 15, rule = bf +7.3A$6.A3FA$A4.A5FA$2A2.A7FA$AF2A9FA$A13FA$A13FA$A13FA$A12FA$A11FA$A +10FA$A9FA$A9FA$A10FA$13A! + +#C Check mark ('yes', aka 'loop') +#C EastLoop..SouthLoop +x = 13, y = 13, rule = bf +13B$13B$11BAB$10B2AB$9B3AB$8B3A2B$2BA4B3A3B$2B2A2B3A4B$2B6A5B$3B4A6B$ +4B2A7B$13B$13B! + +#C X sign ('no', aka 'break') +#C EastBreak..SouthBreak +x = 13, y = 13, rule = bf +13C$C2A7C2AC$C3A5C3AC$2C3A3C3A2C$3C3AC3A3C$4C5A4C$5C3A5C$4C5A4C$3C3AC +3A3C$2C3A3C3A2C$C3A5C3AC$C2A7C2AC$13C! + +#C Digit zero +#C Input0, FreshInput0 +x = 9, y = 13, rule = bf +2.5C$.C5AC$C7AC$C2A3C2AC$C2A2C3AC$C2AC4AC$C7AC$C4AC2AC$C3A2C2AC$C2A3C +2AC$C7AC$.C5AC$2.5C! diff --git a/nutshell/common/errors.py b/nutshell/common/errors.py index 6cb3f30..56cfa27 100644 --- a/nutshell/common/errors.py +++ b/nutshell/common/errors.py @@ -47,7 +47,3 @@ class SyntaxErr(NutshellException): class UnsupportedFeature(NutshellException): pass - - -class CoordOutOfBounds(NutshellException): - pass diff --git a/nutshell/segment_types/table/_classes.py b/nutshell/segment_types/table/_classes.py index 817a5da..ce29bca 100644 --- a/nutshell/segment_types/table/_classes.py +++ b/nutshell/segment_types/table/_classes.py @@ -5,7 +5,7 @@ from nutshell.common.utils import random, distinct from nutshell.common.errors import * -from .lark_assets.exceptions import * +from ._errors import * class VarName: diff --git a/nutshell/segment_types/table/lark_assets/exceptions.py b/nutshell/segment_types/table/_errors.py similarity index 70% rename from nutshell/segment_types/table/lark_assets/exceptions.py rename to nutshell/segment_types/table/_errors.py index e1c0bf2..b6d5dec 100644 --- a/nutshell/segment_types/table/lark_assets/exceptions.py +++ b/nutshell/segment_types/table/_errors.py @@ -1,3 +1,18 @@ +from nutshell.common.errors import NutshellException + + +class CoordOutOfBounds(NutshellException): + pass + + +class InvalidSymmetries(NutshellException): + pass + + +class NeighborhoodError(Exception): + pass + + class Reshape(Exception): def __init__(self, cdir, backup=None): self.cdir = cdir diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segment_types/table/_neighborhoods.py index 763e8dc..a9456e5 100644 --- a/nutshell/segment_types/table/_neighborhoods.py +++ b/nutshell/segment_types/table/_neighborhoods.py @@ -1,6 +1,7 @@ from collections import OrderedDict from itertools import takewhile, permutations from ._classes import Coord +from ._errors import NeighborhoodError NBHD_SETS = OrderedDict( # for containment-checking @@ -109,7 +110,7 @@ def reflect_across(self, endpoint, *, as_cls=True): raise ValueError('Endpoint compass directions of a line of reflection must be both adjacent and given in clockwise order') to_check = [cdir for cdir in self.coord_cdirs if cdir not in {a, b, a.inv, b.inv}] if len(to_check) % 2 or any(c.inv.name not in self for c in to_check): - raise ValueError('Neighborhood is asymmetrical across the requested line of reflection') + raise NeighborhoodError('Neighborhood is asymmetrical across the requested line of reflection') if a == b: # i think the naive approach is the only way to go :( while a.name not in self: @@ -121,7 +122,7 @@ def reflect_across(self, endpoint, *, as_cls=True): for cdir in self.coord_cdirs: d[cdir.name] = a.cw(b.ccw_distance(cdir, self), self).name except KeyError as e: - raise ValueError(f'Neighborhood does not contain {e}') + raise NeighborhoodError(f'Neighborhood does not contain {e}') r = {cdir: self[orig_cdir] for orig_cdir, cdir in d.items()} if as_cls: return Neighborhood(sorted(r, key=r.get)) @@ -139,7 +140,7 @@ def rotate_by(self, offset, *, as_cls=True): def rotations_by(self, amt, *, as_cls=True): if len(self) % amt: - raise ValueError(f'Neighborhood cannot be rotated evenly by {amt}') + raise NeighborhoodError(f'Neighborhood cannot be rotated evenly by {amt}') #if not self.symmetrical: # raise ValueError('Neighborhood is asymmetrical, cannot be rotated except by 1') return [self.rotate_by(offset, as_cls=as_cls) for offset in range(0, len(self), len(self) // amt)] diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segment_types/table/_symutils.py index 35aeb4c..6a8968e 100644 --- a/nutshell/segment_types/table/_symutils.py +++ b/nutshell/segment_types/table/_symutils.py @@ -4,6 +4,7 @@ from operator import and_ as bitwise_and, or_ as bitwise_or from nutshell.common.utils import multisplit +from ._errors import NeighborhoodError from ._neighborhoods import Neighborhood from ._classes import Coord, InlineBinding @@ -33,7 +34,8 @@ def __init_subclass__(cls): func, *args = cls.transformation_names[0] cls.transformations = frozenset(getattr(cls.nbhd, func)(*args, as_cls=False)) cls._RECENTS = {} - cls.test_nbhd() + if not cls.test_nbhd(): + raise NeighborhoodError(f'Symmetry type {cls.__name__!r} is not supported by its neighborhood {cls.nbhd.cdirs}') def __hash__(self): if self._hash is None: @@ -46,6 +48,17 @@ def __eq__(self, other): def __repr__(self): return f'{self.__class__.__name__}{super().__repr__()}' + @classmethod + def with_neighborhood(cls, nbhd): + return new_sym_type( + nbhd, + cls.__name__, + cls.transformation_names, + transformations=cls.transformations, + tilde=cls.tilde, + permute_hash_indices=cls.permute_hash_indices + ) + @classmethod def compose(cls, other): if cls.nbhd != other.nbhd: @@ -90,8 +103,9 @@ def combine(cls, other): @classmethod def test_nbhd(cls): - if not cls.nbhd.supports(cls): - raise ValueError(f'Neighborhood does not support {cls.__name__} symmetries') + if cls.nbhd is None: + return + return cls.nbhd.supports(cls) @property def expanded(self): diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segment_types/table/_transformer.py index a1bf88a..1c4cf17 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segment_types/table/_transformer.py @@ -10,6 +10,7 @@ from nutshell.common.utils import KILL_WS from nutshell.common.errors import * +from ._errors import InvalidSymmetries, NeighborhoodError from ._classes import * from . import _symutils as symutils, _neighborhoods as nbhoods, inline_rulestring @@ -131,7 +132,7 @@ def end_bs(self, meta, text): @inline def directive(self, meta, name, val): - cmt_val = val + cmt_val = str(val) if '#' in val: # since comments are not handled otherwise val = val[:val.index('#')].rstrip() if name == 'macros': @@ -154,17 +155,29 @@ def directive(self, meta, name, val): self._tbl.neighborhood = val except ValueError as e: raise Error(meta, str(e)) + except NeighborhoodError: + nbhd_str = ' ' + '\n '.join(map(' '.join, self._tbl.neighborhood.to_list())) + raise InvalidSymmetries( + meta, + 'Chosen neighborhood\n' + f"{nbhd_str}\n" + f' does not support current symmetry type {self._tbl.symmetries.__name__!r}' + ) self._nbhd_assigned = True else: # directives are more like comments than they are source self._tbl.comments[meta[0]] = f'#### {name}: {cmt_val}' if name == 'symmetries': try: - self._tbl.add_sym_type(val) - except ImportError as e: - raise Error(meta, str(e)) - except (Exception, SyntaxError) as e: - raise Error(meta, f'Error in Python symmetry file: {e}') + self._tbl.symmetries = cmt_val + except NeighborhoodError as e: + nbhd_str = ' ' + '\n '.join(map(' '.join, self._tbl.neighborhood.to_list())) + raise InvalidSymmetries( + meta, + 'Current neighborhood\n' + f"{nbhd_str}\n" + f' does not support chosen symmetry type {cmt_val!r}' + ) raise Discard @inline @@ -344,7 +357,7 @@ def cdir_delay(self, children, meta): @inline def symmetried_aux(self, meta, symmetries, *auxiliaries): self._tbl.add_sym_type(symmetries) - symmetries = symutils.get_sym_type(symmetries) + symmetries = symutils.get_sym_type(self._tbl.neighborhood, symmetries) for aux in auxiliaries: aux.symmetries = symmetries return auxiliaries @@ -352,7 +365,7 @@ def symmetried_aux(self, meta, symmetries, *auxiliaries): @inline def stationary_symmetried_aux(self, meta, symmetries, *auxiliaries): self._tbl.add_sym_type(symmetries) - symmetries = symutils.get_sym_type(symmetries) + symmetries = symutils.get_sym_type(self._tbl.neighborhood, symmetries) for aux in auxiliaries: aux.symmetries = symmetries aux.stationary = True diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index 6e89a81..aeb0cec 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -12,6 +12,7 @@ from nutshell.common.utils import printq, multisplit from nutshell.common import macros from nutshell.common.errors import * +from ._errors import NeighborhoodError from .lark_assets import parser as lark_standalone from ._transformer import Preprocess from ._classes import VarName, StateList @@ -31,7 +32,7 @@ class Bidict(bidict.bidict): class TableSegment: - CARDINALS = generate_cardinals(nbhoods.ORDERED_NBHDS) + NEIGHBORHOODS = generate_cardinals(nbhoods.ORDERED_NBHDS) def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): # parser (lexer?) dies if there are blank lines right at the start @@ -44,7 +45,7 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): self.start = start self._n_states = 0 self.comments = {} - self._nbhd = self._trlen = None + self._trlen = None dep, = dep if dep is not None: @@ -54,6 +55,9 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): self._n_states = 1 + max(self._constants.values()) self.directives = {'neighborhood': 'Moore', 'symmetries': 'none', 'states': self._n_states} + self._nbhd = None + self._symmetries = None # these go together + self.symmetries = 'none' # these go together self.gollyize_nbhd = None self.default_sym_used = False self.vars = Bidict() # {VarName(name) | str(name) :: Variable(value)} @@ -150,7 +154,7 @@ def _iter_final_transitions(self): @property def neighborhood(self): if self._nbhd is None: - self._nbhd = self.CARDINALS[self.directives['neighborhood']] + self._nbhd = self.NEIGHBORHOODS[self.directives['neighborhood']] return self._nbhd @neighborhood.setter @@ -161,10 +165,16 @@ def neighborhood(self, val): raise ValueError('Duplicate compass directions in neighborhood') self._nbhd = nbhoods.Neighborhood(nbhd) self.gollyize_nbhd = self._nbhd.gollyizer_for(self) - elif val in self.CARDINALS: - self._nbhd = self.CARDINALS[val] + elif val in self.NEIGHBORHOODS: + self._nbhd = self.NEIGHBORHOODS[val] else: raise ValueError('Unknown or invalid neighborhood') + self.symmetries = self._symmetries.with_neighborhood(self.neighborhood) + if not self.neighborhood.supports_transformations(self.symmetries.transformation_names): + raise NeighborhoodError( + f'Symmetry type {self.symmetries.__name__!r} is not supported ' + f'by neighborhood {self.neighborhood.cdirs}' + ) self._trlen = None @property @@ -175,7 +185,14 @@ def trlen(self): @property def symmetries(self): - return symutils.get_sym_type(self.neighborhood, self.directives['symmetries']) + if self._symmetries is None: + self._symmetries = symutils.get_sym_type(self.neighborhood, self.directives['symmetries']) + return self._symmetries + + @symmetries.setter + def symmetries(self, value): + self.directives['symmetries'] = value + self._symmetries = symutils.get_sym_type(self.neighborhood, value) if isinstance(value, str) else value @property def n_states(self): @@ -201,8 +218,11 @@ def update_special_vars(self, value=None): self.vars[self.specials['any']] = StateList(range(self.n_states), context=None) self.vars[self.specials['live']] = StateList(range(1, self.n_states), context=None) - def add_sym_type(self, string): - self.sym_types.add(symutils.get_sym_type(self.neighborhood, string)) + def add_sym_type(self, sym): + if isinstance(sym, str): + self.sym_types.add(symutils.get_sym_type(self.neighborhood, sym)) + else: + self.sym_types.add(sym) def add_macros(self, path): with open(path) as f: From 69efd9aa9dc9e5eb672505f13d857dc67e9c453c Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 1 Jan 2019 22:45:55 -0800 Subject: [PATCH 21/33] Break symmetries accidentally but add @DEFINE --- examples/nutshells/MacroTest.ruel | 42 ++++++++++++++++++++ nutshell/segment_types/__init__.py | 1 + nutshell/segment_types/define/__init__.py | 1 + nutshell/segment_types/define/define.py | 35 ++++++++++++++++ nutshell/segment_types/table/_transformer.py | 6 --- nutshell/segment_types/table/table.py | 22 +++++----- nutshell/segmentor.py | 22 +++++++--- 7 files changed, 107 insertions(+), 22 deletions(-) create mode 100644 examples/nutshells/MacroTest.ruel create mode 100644 nutshell/segment_types/define/__init__.py create mode 100644 nutshell/segment_types/define/define.py diff --git a/examples/nutshells/MacroTest.ruel b/examples/nutshells/MacroTest.ruel new file mode 100644 index 0000000..8c1d287 --- /dev/null +++ b/examples/nutshells/MacroTest.ruel @@ -0,0 +1,42 @@ +@NUTSHELL MacroTest +test macros and colors and stuff + +@DEFINE +from itertools import count +FinalTransition = nutshell.macro.FinalTransition + +MACRO-AFTER split_colors(transitions, start_state: int, *, table): + return [ + FinalTransition(tr[:-1] + [resultant], context=tr.ctx) + for tr, resultant in zip(transitions, count(start_state)) + ] + +@TABLE +symmetries: permute + +# this is annoying for now because we still have to "know" +# that the table's final n_states will be 11 (even though we're +# using the macro) +# i should probably make it so that macros are executed before +# references and variables and stuff are resolved + +split_colors: 2 +0, <3 / live / 0>; 11 # end state will be modified by macro +split_colors: \ + +live, <23 / live / 0>; [0] +any, any; 0 + +@COLORS +F00 .. 0CF: live +# FFFFFF: 1 +# FF0000: 2 +# 0000FF: 3 +# FF8000: 4 +# 808080: 5 +# FFFF00: 6 +# 00FFFF: 7 +# 800000: 8 +# FF00FF: 9 +# 008000: 10 +# 8000FF: 11 \ No newline at end of file diff --git a/nutshell/segment_types/__init__.py b/nutshell/segment_types/__init__.py index 665571e..2480d98 100644 --- a/nutshell/segment_types/__init__.py +++ b/nutshell/segment_types/__init__.py @@ -2,3 +2,4 @@ from .icons import IconSegment from .table import TableSegment from .nutshell import NutshellSegment +from .define import DefineSegment diff --git a/nutshell/segment_types/define/__init__.py b/nutshell/segment_types/define/__init__.py new file mode 100644 index 0000000..4fef98a --- /dev/null +++ b/nutshell/segment_types/define/__init__.py @@ -0,0 +1 @@ +from .define import DefineSegment diff --git a/nutshell/segment_types/define/define.py b/nutshell/segment_types/define/define.py new file mode 100644 index 0000000..7e05a40 --- /dev/null +++ b/nutshell/segment_types/define/define.py @@ -0,0 +1,35 @@ +from types import SimpleNamespace + +from nutshell import macro + + +class DefineSegment: + def __init__(self, segment, start=0): + self.macros_after = {} + self.macros_during = {} + self.modifiers = {} + deco_names = ('MACRO-AFTER', 'MACRO-DURING', 'MODIFIER') + segment = segment.copy() + for i, line in enumerate(segment): + if line.startswith(deco_names): + first, rest = line.split(None, 1) + segment[i] = f"@{first.replace('-', '_')}\ndef {rest}" + exec( '\n'.join(segment), { + 'MACRO_AFTER': self.after, + 'MACRO_DURING': self.during, + 'MODIFIER': self.modifier, + 'nutshell': SimpleNamespace(macro=macro), + }) + + def after(self, func): + self.macros_after[func.__name__] = func + return func + + def during(self, func): + self.macros_during[func.__name__] = func + return func + + def modifier(self, func): + self.modifiers[func.__name__] = func + return func + diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segment_types/table/_transformer.py index 1c4cf17..db272b0 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segment_types/table/_transformer.py @@ -135,12 +135,6 @@ def directive(self, meta, name, val): cmt_val = str(val) if '#' in val: # since comments are not handled otherwise val = val[:val.index('#')].rstrip() - if name == 'macros': - try: - self._tbl.add_macros(val.translate(KILL_WS)) - except (Exception, SyntaxError) as e: - raise Error(meta, f'Error in Python macro file: {e}') - raise Discard if name in self._tbl.available_macros: self._tbl.set_macro(meta, name, val) raise Discard diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index aeb0cec..eec1dd3 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -34,7 +34,7 @@ class Bidict(bidict.bidict): class TableSegment: NEIGHBORHOODS = generate_cardinals(nbhoods.ORDERED_NBHDS) - def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): + def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None)): # parser (lexer?) dies if there are blank lines right at the start # so idk tbl = list(tbl) @@ -46,28 +46,31 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL'] = (None,)): self._n_states = 0 self.comments = {} self._trlen = None - dep, = dep + _nutshell, _define = dep - if dep is not None: - dep.replace(self._src) - self._constants = dep.constants + if _nutshell is not None: + _nutshell.replace(self._src) + self._constants = _nutshell.constants if self._constants: self._n_states = 1 + max(self._constants.values()) self.directives = {'neighborhood': 'Moore', 'symmetries': 'none', 'states': self._n_states} + self.sym_types = set() + self.transitions = [] self._nbhd = None self._symmetries = None # these go together self.symmetries = 'none' # these go together self.gollyize_nbhd = None self.default_sym_used = False self.vars = Bidict() # {VarName(name) | str(name) :: Variable(value)} - self.sym_types = set() - self.transitions = [] self._constants = {} self.current_macros = [] self._prepped_macros = {} self.available_macros = macros.__dict__.copy() + if _define is not None: + self.available_macros.update(_define.macros_after) + self.specials = {'any': VarName('any'), 'live': VarName('live')} self.new_varname = VarName.new_generator() @@ -193,6 +196,7 @@ def symmetries(self): def symmetries(self, value): self.directives['symmetries'] = value self._symmetries = symutils.get_sym_type(self.neighborhood, value) if isinstance(value, str) else value + self.add_sym_type(self._symmetries) @property def n_states(self): @@ -224,10 +228,6 @@ def add_sym_type(self, sym): else: self.sym_types.add(sym) - def add_macros(self, path): - with open(path) as f: - exec(f.read(), self.available_macros) - def set_macro(self, meta, name, args): self.current_macros.append((meta.lno, self._prep_macro(self.available_macros[name]), args.split())) diff --git a/nutshell/segmentor.py b/nutshell/segmentor.py index 6ad6293..2a2d198 100644 --- a/nutshell/segmentor.py +++ b/nutshell/segmentor.py @@ -1,19 +1,28 @@ import inspect -from .segment_types import NutshellSegment, TableSegment, ColorSegment, IconSegment from .common import errors, utils +from .segment_types import ( + ColorSegment, + DefineSegment, + IconSegment, + NutshellSegment, + TableSegment + ) +NUTSHELL_ONLY_SEGMENTS = set() -def seg(name, modifiers, cls=None, *, include_bare=True): +def seg(name, modifiers, cls=None, *, include_bare=True, delete=False): name = f'@{name}' + if delete: + NUTSHELL_ONLY_SEGMENTS.add(name) if cls is None: # then modifiers holds cls return [(name, modifiers)] base = [(name, cls)] if include_bare else [] return base + [(f'{name}:{modifier}', cls) for modifier in modifiers] - CONVERTERS = [ + *seg('DEFINE', DefineSegment, delete=True), *seg('NUTSHELL', NutshellSegment), *seg('TABLE', TableSegment), *seg('COLORS', ColorSegment), @@ -31,13 +40,13 @@ def parse(fp): seg = None # Gather all @-headed segments - for lno, line in enumerate(map(str.strip, fp), 1): + for lno, line in enumerate(fp, 1): if line.startswith('@'): # Splat operator ensures that a list will always be placed # under the `seg` key, and that if it's phrased (as can be # done in @RULE) with the segment's first "argument" on the # same line, then it will still be the list's first element - seg, *name = line.split(None, 1) + seg, *name = line.strip().split(None, 1) segments[seg], lines[seg] = name, lno continue # May change in the future to allow things to be defined at the top @@ -74,4 +83,7 @@ def parse(fp): if ':' in name: segments.setdefault(name.split(':')[0], []).extend(segments[name]) del segments[name] + elif name in NUTSHELL_ONLY_SEGMENTS: + del segments[name] + return segments From 3f161bab3aa19121c84f75606db0b47d861f99e6 Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 13 Jan 2019 16:59:34 -0800 Subject: [PATCH 22/33] Add modifiers to @DEFINE --- examples/nutshells/BeeZero.ruel | 40 ++++++++++++++++++- nutshell/segment_types/define/define.py | 14 +++++-- nutshell/segment_types/table/_transformer.py | 11 ++--- .../table/inline_rulestring/__init__.py | 1 - .../table/inline_rulestring/default_rs.py | 33 --------------- nutshell/segment_types/table/table.py | 4 +- 6 files changed, 56 insertions(+), 47 deletions(-) diff --git a/examples/nutshells/BeeZero.ruel b/examples/nutshells/BeeZero.ruel index 4586d6b..3abdc2b 100644 --- a/examples/nutshells/BeeZero.ruel +++ b/examples/nutshells/BeeZero.ruel @@ -3,6 +3,42 @@ Demo of kind-of-automatic B0 rule creation. Demonstrated rule is B017/S01. Can be changed to any Hensel-notation B0 rule by separating the B/S parts of its rulestring, placing its birth rule in place of the two "017"s and its survival rule in place of the two "01"s. +@DEFINE +FOUR_NEIGHBOR = { + 'c': 'e', + 'e': 'c', + 'k': 'k', + 'a': 'a', + 'i': 't', + 'n': 'r', + 'y': 'j', + 'q': 'w', + 'j': 'y', + 'r': 'n', + 't': 'i', + 'w': 'q', + 'z': 'z', +} + + +# The modifier API really needs simplification + documentation. I'll take +# care of both before merging to master. +MODIFIER odd_b0(meta, initial, fg, bg, resultant, rulestring, variables, table): + max_neighbors = table.trlen + nbhds = nutshell.rulestring_tr.parse_rulestring(rulestring, meta, table) + new_nbhds = {} + for count, letters in nbhds.items(): + count = int(count) + new_count = max_neighbors - count + new_key = str(new_count) + if count == 4: + new_letters = {FOUR_NEIGHBOR[i] for i in letters} + else: + new_letters = letters.intersection(nutshell.hensel.R4R_NBHDS[new_key]) + if new_letters or new_count == max_neighbors: + new_nbhds[new_key] = new_letters + return nutshell.rulestring_tr.standard(meta, initial, fg, bg, resultant, new_nbhds, variables, table) + @TABLE symmetries: permute @@ -13,9 +49,9 @@ symmetries: permute 1, <01 !hensel / 1 / 0>; 2 # Birth - ODD generations -0, <01 b0-odd / 2 / 0>; 1 +0, <01 odd_b0 / 2 / 0>; 1 # Survival - ODD generations -2, <017 b0-odd / 2 / 0>; 1 +2, <017 odd_b0 / 2 / 0>; 1 any, any; 0 \ No newline at end of file diff --git a/nutshell/segment_types/define/define.py b/nutshell/segment_types/define/define.py index 7e05a40..c9186e5 100644 --- a/nutshell/segment_types/define/define.py +++ b/nutshell/segment_types/define/define.py @@ -1,6 +1,14 @@ from types import SimpleNamespace -from nutshell import macro +from nutshell import macro, segment_types, common + +NUTSHELL_NAMESPACE = SimpleNamespace( + common=common, + hensel=segment_types.table.inline_rulestring.hensel, + rulestring_tr=segment_types.table.inline_rulestring.default_rs, + macro=macro, + segment_types=segment_types, +) class DefineSegment: @@ -14,11 +22,11 @@ def __init__(self, segment, start=0): if line.startswith(deco_names): first, rest = line.split(None, 1) segment[i] = f"@{first.replace('-', '_')}\ndef {rest}" - exec( '\n'.join(segment), { + exec('\n'.join(segment), { 'MACRO_AFTER': self.after, 'MACRO_DURING': self.during, 'MODIFIER': self.modifier, - 'nutshell': SimpleNamespace(macro=macro), + 'nutshell': NUTSHELL_NAMESPACE, }) def after(self, func): diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segment_types/table/_transformer.py index db272b0..32378e7 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segment_types/table/_transformer.py @@ -521,20 +521,17 @@ def rulestring_napkin(self, meta, rulestring, foreground, background): @inline def modified_rulestring_napkin(self, meta, rulestring, modifier, foreground, background): - imp = modifier.split('.', 1) - try: - func = inline_rulestring.funcs.get(modifier, None) or getattr(import_module(imp[0]), imp[1]) - except (ImportError, ModuleNotFoundError): + if modifier not in self._tbl.modifiers: raise UndefinedErr(meta, f"Unknown modifier '{modifier}'") - return func, { + return self._tbl.modifiers[modifier], { 'rulestring': str(rulestring), 'fg': self.kill_string(foreground, meta), 'bg': self.kill_string(background, meta) } @inline - def rulestring_tr(self, meta, initial, func__napkin, resultant): - func, napkin = func__napkin + def rulestring_tr(self, meta, initial, func_and_napkin, resultant): + func, napkin = func_and_napkin args = { **napkin, 'initial': self.kill_string(initial, meta), diff --git a/nutshell/segment_types/table/inline_rulestring/__init__.py b/nutshell/segment_types/table/inline_rulestring/__init__.py index ae6bc3c..8c6a7cf 100644 --- a/nutshell/segment_types/table/inline_rulestring/__init__.py +++ b/nutshell/segment_types/table/inline_rulestring/__init__.py @@ -3,5 +3,4 @@ funcs = { 'hensel': default_rs.standard, '!hensel': default_rs.inverted, - 'b0-odd': default_rs.odd_invert } diff --git a/nutshell/segment_types/table/inline_rulestring/default_rs.py b/nutshell/segment_types/table/inline_rulestring/default_rs.py index d9a2606..5afaf06 100644 --- a/nutshell/segment_types/table/inline_rulestring/default_rs.py +++ b/nutshell/segment_types/table/inline_rulestring/default_rs.py @@ -6,22 +6,6 @@ from . import hensel from .. import _symutils as symutils -FOUR_NEIGHBOR = { - 'c': 'e', - 'e': 'c', - 'k': 'k', - 'a': 'a', - 'i': 't', - 'n': 'r', - 'y': 'j', - 'q': 'w', - 'j': 'y', - 'r': 'n', - 't': 'i', - 'w': 'q', - 'z': 'z', -} - def standard(meta, initial, fg, bg, resultant, rulestring, variables, table): # r4r only, permute's a headache for some reason @@ -80,23 +64,6 @@ def inverted(meta, initial, fg, bg, resultant, rulestring, variables, table): return standard(meta, initial, fg, bg, resultant, nbhds, variables, table) -def odd_invert(meta, initial, fg, bg, resultant, rulestring, variables, table): - max_neighbors = table.trlen - nbhds = parse_rulestring(rulestring, meta, table) - new_nbhds = {} - for count, letters in nbhds.items(): - count = int(count) - new_count = max_neighbors - count - new_key = str(new_count) - if count == 4: - new_letters = {FOUR_NEIGHBOR[i] for i in letters} - else: - new_letters = letters.intersection(hensel.R4R_NBHDS[new_key]) - if new_letters or new_count == max_neighbors: - new_nbhds[new_key] = new_letters - return standard(meta, initial, fg, bg, resultant, new_nbhds, variables, table) - - def parse_rulestring(rs, meta, table): nbhds = hensel.validate(rs) if not nbhds: diff --git a/nutshell/segment_types/table/table.py b/nutshell/segment_types/table/table.py index eec1dd3..1d3d0b1 100644 --- a/nutshell/segment_types/table/table.py +++ b/nutshell/segment_types/table/table.py @@ -16,7 +16,7 @@ from .lark_assets import parser as lark_standalone from ._transformer import Preprocess from ._classes import VarName, StateList -from . import _symutils as symutils, _neighborhoods as nbhoods +from . import _symutils as symutils, _neighborhoods as nbhoods, inline_rulestring # no need to catch \s*,\s* because directive values are translated with KILL_WS CUSTOM_NBHD = re.compile(r'(?:[NS][EW]?|[EW])(?:,(?:[NS][EW]?|[EW]))*') @@ -67,9 +67,11 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self.current_macros = [] self._prepped_macros = {} self.available_macros = macros.__dict__.copy() + self.modifiers = inline_rulestring.funcs if _define is not None: self.available_macros.update(_define.macros_after) + self.modifiers.update(_define.modifiers) self.specials = {'any': VarName('any'), 'live': VarName('live')} self.new_varname = VarName.new_generator() From aa54fb5a1c0a584d85876f107c8087b504c7a3f6 Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 13 Jan 2019 20:07:36 -0800 Subject: [PATCH 23/33] Rename `segment_types' to `segments' --- nutshell/__init__.py | 2 +- nutshell/macro.py | 2 +- nutshell/segmentor.py | 16 ++++++++-------- nutshell/{segment_types => segments}/__init__.py | 0 .../colors/__init__.py | 0 .../{segment_types => segments}/colors/colors.py | 0 .../define/__init__.py | 0 .../{segment_types => segments}/define/define.py | 8 ++++---- nutshell/segments/flag_def.py | 0 .../icons/__init__.py | 0 .../{segment_types => segments}/icons/_utils.py | 0 .../{segment_types => segments}/icons/icons.py | 0 .../nutshell/__init__.py | 0 .../nutshell/nutshell.py | 0 .../table/__init__.py | 0 .../table/_classes.py | 0 .../{segment_types => segments}/table/_errors.py | 0 .../table/_neighborhoods.py | 0 .../table/_symutils.py | 0 .../table/_transformer.py | 2 -- .../table/inline_rulestring/__init__.py | 0 .../table/inline_rulestring/default_rs.py | 2 +- .../table/inline_rulestring/hensel.py | 0 .../table/lark_assets/grammar.lark | 0 .../table/lark_assets/parser.py | 0 .../{segment_types => segments}/table/table.py | 0 26 files changed, 15 insertions(+), 17 deletions(-) rename nutshell/{segment_types => segments}/__init__.py (100%) rename nutshell/{segment_types => segments}/colors/__init__.py (100%) rename nutshell/{segment_types => segments}/colors/colors.py (100%) rename nutshell/{segment_types => segments}/define/__init__.py (100%) rename nutshell/{segment_types => segments}/define/define.py (84%) create mode 100644 nutshell/segments/flag_def.py rename nutshell/{segment_types => segments}/icons/__init__.py (100%) rename nutshell/{segment_types => segments}/icons/_utils.py (100%) rename nutshell/{segment_types => segments}/icons/icons.py (100%) rename nutshell/{segment_types => segments}/nutshell/__init__.py (100%) rename nutshell/{segment_types => segments}/nutshell/nutshell.py (100%) rename nutshell/{segment_types => segments}/table/__init__.py (100%) rename nutshell/{segment_types => segments}/table/_classes.py (100%) rename nutshell/{segment_types => segments}/table/_errors.py (100%) rename nutshell/{segment_types => segments}/table/_neighborhoods.py (100%) rename nutshell/{segment_types => segments}/table/_symutils.py (100%) rename nutshell/{segment_types => segments}/table/_transformer.py (99%) rename nutshell/{segment_types => segments}/table/inline_rulestring/__init__.py (100%) rename nutshell/{segment_types => segments}/table/inline_rulestring/default_rs.py (99%) rename nutshell/{segment_types => segments}/table/inline_rulestring/hensel.py (100%) rename nutshell/{segment_types => segments}/table/lark_assets/grammar.lark (100%) rename nutshell/{segment_types => segments}/table/lark_assets/parser.py (100%) rename nutshell/{segment_types => segments}/table/table.py (100%) diff --git a/nutshell/__init__.py b/nutshell/__init__.py index d760cfd..04d8a1f 100644 --- a/nutshell/__init__.py +++ b/nutshell/__init__.py @@ -1,3 +1,3 @@ __version__ = '0.6.0a' from .common import * -from . import segment_types +from . import segments diff --git a/nutshell/macro.py b/nutshell/macro.py index a4c78aa..4c3f785 100644 --- a/nutshell/macro.py +++ b/nutshell/macro.py @@ -1,5 +1,5 @@ """Macro-related utilities""" -from .segment_types.table._classes import FinalTransition +from .segments.table._classes import FinalTransition def consolidate(transitions): lnos = {} diff --git a/nutshell/segmentor.py b/nutshell/segmentor.py index 2a2d198..23aedcb 100644 --- a/nutshell/segmentor.py +++ b/nutshell/segmentor.py @@ -1,7 +1,7 @@ import inspect from .common import errors, utils -from .segment_types import ( +from .segments import ( ColorSegment, DefineSegment, IconSegment, @@ -12,21 +12,21 @@ NUTSHELL_ONLY_SEGMENTS = set() def seg(name, modifiers, cls=None, *, include_bare=True, delete=False): - name = f'@{name}' if delete: NUTSHELL_ONLY_SEGMENTS.add(name) if cls is None: - # then modifiers holds cls + # then cls was passed to modifiers return [(name, modifiers)] base = [(name, cls)] if include_bare else [] return base + [(f'{name}:{modifier}', cls) for modifier in modifiers] CONVERTERS = [ - *seg('DEFINE', DefineSegment, delete=True), - *seg('NUTSHELL', NutshellSegment), - *seg('TABLE', TableSegment), - *seg('COLORS', ColorSegment), - *seg('ICONS', (7, 15, 31), IconSegment), + *seg(None, ..., delete=True), + *seg('@DEFINE', DefineSegment, delete=True), + *seg('@NUTSHELL', NutshellSegment), + *seg('@TABLE', TableSegment), + *seg('@COLORS', ColorSegment), + *seg('@ICONS', (7, 15, 31), IconSegment), ] diff --git a/nutshell/segment_types/__init__.py b/nutshell/segments/__init__.py similarity index 100% rename from nutshell/segment_types/__init__.py rename to nutshell/segments/__init__.py diff --git a/nutshell/segment_types/colors/__init__.py b/nutshell/segments/colors/__init__.py similarity index 100% rename from nutshell/segment_types/colors/__init__.py rename to nutshell/segments/colors/__init__.py diff --git a/nutshell/segment_types/colors/colors.py b/nutshell/segments/colors/colors.py similarity index 100% rename from nutshell/segment_types/colors/colors.py rename to nutshell/segments/colors/colors.py diff --git a/nutshell/segment_types/define/__init__.py b/nutshell/segments/define/__init__.py similarity index 100% rename from nutshell/segment_types/define/__init__.py rename to nutshell/segments/define/__init__.py diff --git a/nutshell/segment_types/define/define.py b/nutshell/segments/define/define.py similarity index 84% rename from nutshell/segment_types/define/define.py rename to nutshell/segments/define/define.py index c9186e5..c7e86f6 100644 --- a/nutshell/segment_types/define/define.py +++ b/nutshell/segments/define/define.py @@ -1,13 +1,13 @@ from types import SimpleNamespace -from nutshell import macro, segment_types, common +from nutshell import macro, segments, common NUTSHELL_NAMESPACE = SimpleNamespace( common=common, - hensel=segment_types.table.inline_rulestring.hensel, - rulestring_tr=segment_types.table.inline_rulestring.default_rs, + hensel=segments.table.inline_rulestring.hensel, + rulestring_tr=segments.table.inline_rulestring.default_rs, macro=macro, - segment_types=segment_types, + segments=segments, ) diff --git a/nutshell/segments/flag_def.py b/nutshell/segments/flag_def.py new file mode 100644 index 0000000..e69de29 diff --git a/nutshell/segment_types/icons/__init__.py b/nutshell/segments/icons/__init__.py similarity index 100% rename from nutshell/segment_types/icons/__init__.py rename to nutshell/segments/icons/__init__.py diff --git a/nutshell/segment_types/icons/_utils.py b/nutshell/segments/icons/_utils.py similarity index 100% rename from nutshell/segment_types/icons/_utils.py rename to nutshell/segments/icons/_utils.py diff --git a/nutshell/segment_types/icons/icons.py b/nutshell/segments/icons/icons.py similarity index 100% rename from nutshell/segment_types/icons/icons.py rename to nutshell/segments/icons/icons.py diff --git a/nutshell/segment_types/nutshell/__init__.py b/nutshell/segments/nutshell/__init__.py similarity index 100% rename from nutshell/segment_types/nutshell/__init__.py rename to nutshell/segments/nutshell/__init__.py diff --git a/nutshell/segment_types/nutshell/nutshell.py b/nutshell/segments/nutshell/nutshell.py similarity index 100% rename from nutshell/segment_types/nutshell/nutshell.py rename to nutshell/segments/nutshell/nutshell.py diff --git a/nutshell/segment_types/table/__init__.py b/nutshell/segments/table/__init__.py similarity index 100% rename from nutshell/segment_types/table/__init__.py rename to nutshell/segments/table/__init__.py diff --git a/nutshell/segment_types/table/_classes.py b/nutshell/segments/table/_classes.py similarity index 100% rename from nutshell/segment_types/table/_classes.py rename to nutshell/segments/table/_classes.py diff --git a/nutshell/segment_types/table/_errors.py b/nutshell/segments/table/_errors.py similarity index 100% rename from nutshell/segment_types/table/_errors.py rename to nutshell/segments/table/_errors.py diff --git a/nutshell/segment_types/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py similarity index 100% rename from nutshell/segment_types/table/_neighborhoods.py rename to nutshell/segments/table/_neighborhoods.py diff --git a/nutshell/segment_types/table/_symutils.py b/nutshell/segments/table/_symutils.py similarity index 100% rename from nutshell/segment_types/table/_symutils.py rename to nutshell/segments/table/_symutils.py diff --git a/nutshell/segment_types/table/_transformer.py b/nutshell/segments/table/_transformer.py similarity index 99% rename from nutshell/segment_types/table/_transformer.py rename to nutshell/segments/table/_transformer.py index 32378e7..d500ca1 100644 --- a/nutshell/segment_types/table/_transformer.py +++ b/nutshell/segments/table/_transformer.py @@ -1,9 +1,7 @@ from collections import namedtuple from functools import wraps from inspect import signature -from importlib import import_module from itertools import chain, repeat -from pkg_resources import resource_filename import bidict from .lark_assets.parser import Transformer, Tree, Discard, v_args diff --git a/nutshell/segment_types/table/inline_rulestring/__init__.py b/nutshell/segments/table/inline_rulestring/__init__.py similarity index 100% rename from nutshell/segment_types/table/inline_rulestring/__init__.py rename to nutshell/segments/table/inline_rulestring/__init__.py diff --git a/nutshell/segment_types/table/inline_rulestring/default_rs.py b/nutshell/segments/table/inline_rulestring/default_rs.py similarity index 99% rename from nutshell/segment_types/table/inline_rulestring/default_rs.py rename to nutshell/segments/table/inline_rulestring/default_rs.py index 5afaf06..870d0bc 100644 --- a/nutshell/segment_types/table/inline_rulestring/default_rs.py +++ b/nutshell/segments/table/inline_rulestring/default_rs.py @@ -1,6 +1,6 @@ from itertools import count -from nutshell.segment_types.table._classes import * +from nutshell.segments.table._classes import * from nutshell.common.errors import * from . import hensel diff --git a/nutshell/segment_types/table/inline_rulestring/hensel.py b/nutshell/segments/table/inline_rulestring/hensel.py similarity index 100% rename from nutshell/segment_types/table/inline_rulestring/hensel.py rename to nutshell/segments/table/inline_rulestring/hensel.py diff --git a/nutshell/segment_types/table/lark_assets/grammar.lark b/nutshell/segments/table/lark_assets/grammar.lark similarity index 100% rename from nutshell/segment_types/table/lark_assets/grammar.lark rename to nutshell/segments/table/lark_assets/grammar.lark diff --git a/nutshell/segment_types/table/lark_assets/parser.py b/nutshell/segments/table/lark_assets/parser.py similarity index 100% rename from nutshell/segment_types/table/lark_assets/parser.py rename to nutshell/segments/table/lark_assets/parser.py diff --git a/nutshell/segment_types/table/table.py b/nutshell/segments/table/table.py similarity index 100% rename from nutshell/segment_types/table/table.py rename to nutshell/segments/table/table.py From 06a0b2bb765c73818ed403684f2041e3e55cdac9 Mon Sep 17 00:00:00 2001 From: Eli Date: Mon, 14 Jan 2019 22:16:04 -0800 Subject: [PATCH 24/33] Preserve left whitespace; fix & decomplicate symmetries --- .../AlternatingPermuteTest.rule | 10 +- examples/compiled_ruletables/BeeZero.rule | 162 +++++++++--------- examples/compiled_ruletables/Brew.rule | 122 ++++++------- .../compiled_ruletables/DeficientLife.rule | 38 ++-- examples/compiled_ruletables/ExtendedX.rule | 46 ++--- examples/compiled_ruletables/XHistory.rule | 64 +++---- examples/compiled_ruletables/bct.rule | 2 +- examples/compiled_ruletables/bf.rule | 32 ++-- examples/compiled_ruletables/data_test.rule | 18 +- examples/compiled_ruletables/roed.rule | 98 +++++------ examples/nutshells/BeeZero.ruel | 2 +- nutshell/segmentor.py | 12 +- nutshell/segments/table/_symutils.py | 1 - nutshell/segments/table/_transformer.py | 8 +- .../table/inline_rulestring/default_rs.py | 2 +- nutshell/segments/table/table.py | 45 +++-- 16 files changed, 334 insertions(+), 328 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 1bb7adc..933b8ea 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -65,12 +65,12 @@ var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) #### line 48: 0, h, t, any, b, any, any, any, any, h #### +0, any.0, any.1, h.0, any.2, any.3, b.0, any.4, t.0, h.1 +0, any.0, t.0, any.1, any.2, h.0, b.0, any.3, any.4, h.1 +0, h.0, t.0, any.0, any.1, any.2, any.3, any.4, b.0, h.1 0, h.0, any.0, any.1, any.2, any.3, b.0, any.4, t.0, h.1 -0, any.0, b.0, any.1, any.2, h.0, any.3, any.4, t.0, h.1 -0, any.0, any.1, any.2, any.3, any.4, t.0, h.0, b.0, h.1 -0, h.0, t.0, any.0, any.1, any.2, b.0, any.3, any.4, h.1 -0, any.0, any.1, any.2, t.0, any.3, any.4, h.0, b.0, h.1 -0, any.0, any.1, h.0, b.0, any.2, t.0, any.3, any.4, h.1 +0, any.0, any.1, h.0, t.0, any.2, any.3, any.4, b.0, h.1 +0, any.0, any.1, any.2, t.0, any.3, b.0, h.0, any.4, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### 0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index af44e5f..2c09185 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -25,110 +25,110 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations -#### line 10: 0, <017 !hensel / 1 / 0>; 2 #### +#### line 46: 0, <017 !hensel / 1 / 0>; 2 #### 0, 1, 0, 0, 0, 0, 0, 1, 0, 2 -0, 0, 1, 0, 1, 0, 0, 0, 0, 2 -0, 0, 0, 0, 0, 0, 0, 1, 1, 2 +0, 0, 0, 0, 1, 1, 0, 0, 0, 2 0, 0, 0, 1, 0, 0, 0, 1, 0, 2 0, 0, 0, 0, 1, 0, 0, 0, 1, 2 -0, 0, 1, 0, 0, 1, 0, 0, 0, 2 -0, 1, 0, 0, 0, 0, 1, 1, 0, 2 -0, 0, 1, 0, 1, 0, 0, 0, 1, 2 -0, 1, 0, 0, 0, 0, 0, 1, 1, 2 +0, 0, 0, 1, 0, 0, 1, 0, 0, 2 +0, 0, 0, 0, 0, 0, 1, 0, 1, 2 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 -0, 1, 1, 0, 1, 0, 0, 0, 0, 2 -0, 1, 0, 0, 0, 1, 0, 1, 0, 2 -0, 1, 0, 0, 0, 1, 1, 0, 0, 2 -0, 0, 0, 0, 1, 0, 0, 1, 1, 2 -0, 0, 1, 0, 1, 0, 0, 1, 0, 2 -0, 1, 0, 1, 0, 0, 1, 0, 0, 2 -0, 1, 0, 1, 0, 1, 0, 0, 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1, 1, 0, 1, 0, 1, 2 +1, 1, 1, 1, 0, 0, 1, 1, 1, 2 1, 1, 1, 0, 1, 1, 1, 0, 1, 2 -1, 1, 0, 1, 1, 1, 0, 1, 1, 2 -1, 1, 1, 1, 0, 1, 1, 0, 1, 2 +1, 1, 1, 1, 0, 1, 1, 1, 0, 2 +1, 1, 1, 0, 1, 1, 0, 1, 1, 2 +1, 1, 1, 1, 0, 1, 0, 1, 1, 2 1, 1, 1, 1, 1, 1, 1, 0, 1, 2 1, 1, 1, 1, 1, 1, 1, 1, 0, 2 # Birth - ODD generations -#### line 16: 0, <01 b0-odd / 2 / 0>; 1 #### -0, 2, 2, 0, 2, 2, 2, 2, 2, 1 +#### line 52: 0, <01 odd_b0 / 2 / 0>; 1 #### +0, 0, 2, 2, 2, 2, 2, 2, 2, 1 0, 2, 2, 2, 2, 2, 0, 2, 2, 1 # Survival - ODD generations -#### line 19: 2, <017 b0-odd / 2 / 0>; 1 #### -2, 2, 2, 0, 2, 2, 2, 2, 2, 1 +#### line 55: 2, <017 odd_b0 / 2 / 0>; 1 #### +2, 0, 2, 2, 2, 2, 2, 2, 2, 1 2, 2, 2, 2, 2, 2, 0, 2, 2, 1 -2, 2, 0, 0, 0, 0, 0, 0, 0, 1 -2, 0, 0, 0, 0, 0, 2, 0, 0, 1 -#### line 21: any, any; 0 #### +2, 0, 0, 0, 0, 0, 0, 2, 0, 1 +2, 0, 0, 0, 0, 0, 0, 0, 2, 1 +#### line 57: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index dc8b8d5..b0b74e4 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, 1, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 -_a0.0, _a0.1, _a0.2, _a0.3, 1, 1, 1, _a0.4, _a0.5, 1 -_a0.0, _a0.1, 1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1 -_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1, 1 _a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 +_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1, 1 -_a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### -1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1 1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 -1, 1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 -1, _a0.0, _a0.1, _a0.2, 1, 1, 1, _a0.3, _a0.4, 1 -1, _a0.0, 1, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1 -1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1, 1 1, 1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 -_b0.0, 2, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2, 2 -_b0.0, 2, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1, 1 +_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, 2, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, _b0.5, 2 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 -2, 2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, 2 -2, 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, 2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2 -2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, 2, _b0.4, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 -_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3, 3 -_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 -_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3, 3 -_c0.0, _c0.1, _c0.2, 3, 3, _c0.3, 3, _c0.4, _c0.5, 3 +2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2 +_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, _c0.5, 3 _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, 3, 3, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3, 3 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, _c0.5, 3, 3 _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, _c0.1, _c0.2, _c0.3, 3, 3, _c0.4, _c0.5, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 -3, 3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, 3 -3, _c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3 3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 -3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 -3, _c0.0, 3, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, 3, 3, 3, _c0.2, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, 3, 3, _c0.4, 3, 3 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, _c0.0, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, 3, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index e573cf0..c555d91 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -54,41 +54,41 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, _a0.0, 0, _a0.1, 0, 0, 0, _a0.2, 2 +0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 0, 0, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### 0, 0, 0, _b0.0, 0, _b0.1, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, 0, _c0.0, 0, 0, _c0.1, 0, _c0.2, 0, 4 +0, 0, 0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### -0, _d0.0, 0, 0, 0, 0, 0, _d0.1, _d0.2, 5 +0, _d0.0, _d0.1, _d0.2, 0, 0, 0, 0, 0, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### -0, 0, _e0.0, _e0.1, _e0.2, 0, 0, 0, 0, 6 +0, 0, 0, 0, _e0.0, _e0.1, _e0.2, 0, 0, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### -0, _f0.0, _f0.1, 0, _f0.2, 0, 0, 0, 0, 7 +0, 0, _f0.0, _f0.1, 0, 0, 0, 0, _f0.2, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, 0, 0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 8 +0, 0, _g0.0, 0, _g0.1, 0, 0, _g0.2, 0, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, 0, _h0.0, _h0.1, 0, 0, _h0.2, 0, 0, 9 +0, 0, 0, 0, _h0.0, _h0.1, 0, 0, _h0.2, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### -0, _i0.0, _i0.1, 0, 0, 0, 0, _i0.2, 0, 10 +0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 0, 0, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, 0, 0, _j0.0, _j0.1, 0, 0, _j0.2, 0, 11 +0, _j0.0, 0, 0, 0, _j0.1, _j0.2, 0, 0, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 # s2 -live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s2 +live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 +live.0, 0, 0, live.1, live.2, 0, 0, 0, 0, 1 live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 -live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 -live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 +live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 # s3 -live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s3 +live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 +live.0, 0, 0, live.1, live.2, 0, 0, 0, 0, 1 live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 -live.0, 0, 0, live.1, 0, live.2, 0, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, live.2, 0, 1 -live.0, live.1, live.2, 0, 0, 0, 0, 0, 0, 1 +live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index 69f4382..d0f2ef8 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,40 +41,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 -0, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 -0, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 -0, off.0, off.1, off.2, on.0, on.1, on.2, off.3, off.4, 1 -0, on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, 1 -0, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +0, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 0, on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -0, on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, 1 +0, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +0, on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, 1 +0, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +0, off.0, on.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 0, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 -0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +0, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 +0, off.0, on.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +0, off.0, on.0, on.1, off.1, off.2, on.2, off.3, off.4, 1 #### line 21: 0, birth ~ 1, any; 1 #### -0, any.0, any.1, any.2, birth.0, any.3, any.4, any.5, any.6, 1 0, any.0, any.1, any.2, any.3, any.4, any.5, birth.0, any.6, 1 +0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### -1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, death.0, 0 -1, any.0, any.1, any.2, any.3, death.0, any.4, any.5, any.6, 0 +1, any.0, any.1, death.0, any.2, any.3, any.4, any.5, any.6, 0 +1, any.0, any.1, any.2, death.0, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 -1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 +1, off.0, off.1, off.2, off.3, on.0, off.4, on.1, off.5, 1 1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, off.5, 1 1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 -1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, off.5, 1 -1, off.0, off.1, off.2, off.3, on.0, off.4, off.5, on.1, 1 -1, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 -1, off.0, off.1, off.2, on.0, off.3, on.1, off.4, on.2, 1 -1, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 -1, off.0, off.1, off.2, on.0, on.1, on.2, off.3, off.4, 1 -1, on.0, on.1, off.0, on.2, off.1, off.2, off.3, off.4, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, on.2, off.4, 1 +1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 +1, off.0, off.1, on.0, off.2, off.3, on.1, off.4, off.5, 1 +1, off.0, off.1, off.2, off.3, off.4, on.0, off.5, on.1, 1 +1, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 1, on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -1, on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, 1 +1, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +1, on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, 1 +1, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +1, off.0, on.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 1, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +1, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 +1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +1, off.0, on.0, on.1, off.1, off.2, on.2, off.3, off.4, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index 83a1426..13a6229 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,50 +63,50 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 1 -4, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 4, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 3 _e0.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 1 -4, _b0.0, _b0.1, on.0, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 -4, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, on.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, _b0.4, on.1, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, _b0.4, on.1, on.2, 1 -4, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 1 +4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 1 +4, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 +_e0.0, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 _e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 +4, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, on.0, on.1, _b0.0, _b0.1, _b0.2, on.2, _b0.3, _b0.4, 3 +_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, on.2, _b0.3, _b0.4, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### -1, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 -1, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 -_g0.0, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 -_g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 +1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, 6, _f0.6, 2 +1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 2 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, 6, _f0.6, 4 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, off.5, on.0 -on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, off.4, on.2, off.5, on.0 on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, off.5, on.0 on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 -on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, off.5, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, off.4, off.5, on.2, on.0 -on.0, off.0, on.1, on.2, off.1, on.3, off.2, off.3, off.4, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, on.3, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, on.2, on.3, off.4, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, on.3, off.3, off.4, on.0 -on.0, on.1, on.2, off.0, on.3, off.1, off.2, off.3, off.4, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, off.5, on.0 +on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, on.2, on.0 +on.0, off.0, on.1, on.2, on.3, off.1, off.2, off.3, off.4, on.0 on.0, on.1, off.0, off.1, on.2, on.3, off.2, off.3, off.4, on.0 -on.0, on.1, on.2, off.0, off.1, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, on.2, off.1, on.3, off.2, off.3, off.4, on.0 +on.0, on.1, on.2, on.3, off.0, off.1, off.2, off.3, off.4, on.0 +on.0, off.0, on.1, on.2, off.1, on.3, off.2, off.3, off.4, on.0 +on.0, off.0, on.1, off.1, on.2, on.3, off.2, off.3, off.4, on.0 on.0, on.1, off.0, off.1, on.2, off.2, on.3, off.3, off.4, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, on.2, off.1, off.2, on.3, off.3, off.4, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/examples/compiled_ruletables/bct.rule b/examples/compiled_ruletables/bct.rule index 245a691..e702f96 100644 --- a/examples/compiled_ruletables/bct.rule +++ b/examples/compiled_ruletables/bct.rule @@ -117,7 +117,7 @@ any.0, 15, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 5 #### line 76: data, E 5, SE..NE any; 0 #### data.0, any.0, any.1, 5, any.2, any.3, any.4, any.5, any.6, 0 # If a prgm-tape 1 is encountered, shift it downward -# and append the command to its left (by copying+shifting down) onto the right end of the data tape, +# and append the command to its left (by copying+shifting down) onto the right end of the data tape, # if the leftmost bit is 1 -- otherwise just shift it down # ---- # check the x in 1x diff --git a/examples/compiled_ruletables/bf.rule b/examples/compiled_ruletables/bf.rule index 46a14ba..7953098 100644 --- a/examples/compiled_ruletables/bf.rule +++ b/examples/compiled_ruletables/bf.rule @@ -94,7 +94,7 @@ Brainfuck. 73: Second pointer delay state (down here b/c poor planning lol) -74: eastbound YES signal (not 0, keep looping) from data pointer after testing for r-bracket +74: eastbound YES signal (not 0, keep looping) from data pointer after testing for r-bracket 75: westbound YES signal 76: southbound YES signal 77: eastbound NO signal (is 0, continue) @@ -115,8 +115,8 @@ Brainfuck. 90: blank input 91: "Uninitialized" input data; this is only here for ease of storage in RLE format, -because otherwise the vertical input tape is very unfriendly to Golly. It moves diagonally to -the southeast until there’s something above it + because otherwise the vertical input tape is very unfriendly to Golly. It moves diagonally to + the southeast until there’s something above it 92: Uninitialized \x00 input, same as above 93: Uninitialized input head, same as above @@ -125,19 +125,19 @@ the southeast until there’s something above it + To use: -Start with this template. -x = 5, y = 4, rule = bf -2.qJ$4.pR$rM$4.I! -- Enter a BF program from left to right, using cellstates 1-8, starting in the dead cell immediately southeast of -the bottommost live one. -- Initialize data as diagonal, northwest-leaning unary stacks of state-66 cells, starting each stack in the row -immediately above the topmost live cell. -- Initialize input as vertically-stacked vertical stacks of state-84 cells, starting in and going south from the -cell immediately below the westmost live one and with individual inputs delimited by state-85 cells. -An input of \x00 can be represented using a single state-90 cell in lieu of the state-84 ones. -- (Alternatively, should you wish to make your program friendlier to RLE encoding, you may initialize input as -horizontal (west-pointing) stacks of state-91 cells, delimited by state-93 cells and using state 92 for \x00; -the input tape will right itself automatically once the simulation starts.) + Start with this template. + x = 5, y = 4, rule = bf + 2.qJ$4.pR$rM$4.I! + - Enter a BF program from left to right, using cellstates 1-8, starting in the dead cell immediately southeast of + the bottommost live one. + - Initialize data as diagonal, northwest-leaning unary stacks of state-66 cells, starting each stack in the row + immediately above the topmost live cell. + - Initialize input as vertically-stacked vertical stacks of state-84 cells, starting in and going south from the + cell immediately below the westmost live one and with individual inputs delimited by state-85 cells. + An input of \x00 can be represented using a single state-90 cell in lieu of the state-84 ones. + - (Alternatively, should you wish to make your program friendlier to RLE encoding, you may initialize input as + horizontal (west-pointing) stacks of state-91 cells, delimited by state-93 cells and using state 92 for \x00; + the input tape will right itself automatically once the simulation starts.) + An example: x = 19, y = 5, rule = bf diff --git a/examples/compiled_ruletables/data_test.rule b/examples/compiled_ruletables/data_test.rule index ceed6c4..b956c24 100644 --- a/examples/compiled_ruletables/data_test.rule +++ b/examples/compiled_ruletables/data_test.rule @@ -4,17 +4,17 @@ **** v0.6.0a **** ******************************** -1: Data + 1: Data -2: Output prompter -3: Data turned output, will revert to data on next generation -4: Data being output, will revert to vacuum on next generation -5: Data being output that will not extend anymore -6: Data being output that will not extend anymore + 2: Output prompter + 3: Data turned output, will revert to data on next generation + 4: Data being output, will revert to vacuum on next generation + 5: Data being output that will not extend anymore + 6: Data being output that will not extend anymore -7: Incrementor -8: ^same, moving thru data -9: Decrementor + 7: Incrementor + 8: ^same, moving thru data + 9: Decrementor 10: ^same, moving thru data x = 15, y = 15, rule = data_test diff --git a/examples/compiled_ruletables/roed.rule b/examples/compiled_ruletables/roed.rule index 6b0c5df..c6c202b 100644 --- a/examples/compiled_ruletables/roed.rule +++ b/examples/compiled_ruletables/roed.rule @@ -10,73 +10,73 @@ http://esolangs.org/wiki/Roie 1: e 2-5: pointer 0 (n-w) -2: n -3: e -4: s -5: w + 2: n + 3: e + 4: s + 5: w 6-9: pointer 1 (n-w) -6: n -7: e -8: s -9: w + 6: n + 7: e + 8: s + 9: w 10: o 11-15: o releasing two 1s (n-w) -11: north -12: east -13: south -14: west + 11: north + 12: east + 13: south + 14: west 16-19: o releasing two 0s (n-w) -16: n -17: e -18: s -19: w + 16: n + 17: e + 18: s + 19: w 20-23: o releasing 0s, but diagonally... sorted by diagonal direction of 'mouth' -20: ne -21: se -22: sw -23: nw + 20: ne + 21: se + 22: sw + 23: nw 24-27: o releasing 1s, diagonally -24: ne -25: se -26: sw -27: nw + 24: ne + 25: se + 26: sw + 27: nw 28: r (solid) 29-32: r that will send a pointer 0 out (n-w) -29: n -30: e -31: s -32: w + 29: n + 30: e + 31: s + 32: w 33-34: r that will send a pointer 1 out (n-w) -33: n -34: e -35: s -36: w + 33: n + 34: e + 35: s + 36: w 37: d 38-41: transitory d to release a pointer 0 (n-w) -38: n -39: e -40: s -41: w + 38: n + 39: e + 40: s + 41: w 42-45: transitory d to release a pointer 1 (n-w) -42: n -43: e -44: s -45: w + 42: n + 43: e + 44: s + 45: w 46-49: d releasing a pointer 0 (n-w) -46: n -47: e -48: s -49: w + 46: n + 47: e + 48: s + 49: w 42-53: d releasing a pointer 1 (n-w) -50: n -51: e -52: s -53: w - + 50: n + 51: e + 52: s + 53: w + @TABLE neighborhood: Moore diff --git a/examples/nutshells/BeeZero.ruel b/examples/nutshells/BeeZero.ruel index 3abdc2b..9dd6fd4 100644 --- a/examples/nutshells/BeeZero.ruel +++ b/examples/nutshells/BeeZero.ruel @@ -22,7 +22,7 @@ FOUR_NEIGHBOR = { # The modifier API really needs simplification + documentation. I'll take -# care of both before merging to master. +# care of both before merging to master MODIFIER odd_b0(meta, initial, fg, bg, resultant, rulestring, variables, table): max_neighbors = table.trlen nbhds = nutshell.rulestring_tr.parse_rulestring(rulestring, meta, table) diff --git a/nutshell/segmentor.py b/nutshell/segmentor.py index 23aedcb..8d3cf49 100644 --- a/nutshell/segmentor.py +++ b/nutshell/segmentor.py @@ -10,6 +10,7 @@ ) NUTSHELL_ONLY_SEGMENTS = set() +NO_SEGMENT = '_TOP' def seg(name, modifiers, cls=None, *, include_bare=True, delete=False): if delete: @@ -21,7 +22,7 @@ def seg(name, modifiers, cls=None, *, include_bare=True, delete=False): return base + [(f'{name}:{modifier}', cls) for modifier in modifiers] CONVERTERS = [ - *seg(None, ..., delete=True), + *seg(NO_SEGMENT, lambda *a, **kw: ..., delete=True), *seg('@DEFINE', DefineSegment, delete=True), *seg('@NUTSHELL', NutshellSegment), *seg('@TABLE', TableSegment), @@ -36,8 +37,8 @@ def parse(fp): return: file, segmented into dict """ - segments, lines = {}, {} - seg = None + segments, lines = {NO_SEGMENT: ['']}, {} + seg = NO_SEGMENT # Gather all @-headed segments for lno, line in enumerate(fp, 1): @@ -49,10 +50,7 @@ def parse(fp): seg, *name = line.strip().split(None, 1) segments[seg], lines[seg] = name, lno continue - # May change in the future to allow things to be defined at the top - # of a nutshell - if seg is not None: - segments[seg].append(line) + segments[seg].append(line.rstrip('\r\n')) # turns out the rstrip is really important for line numbers # Parse and operate on gathered segments for label, converter in CONVERTERS: diff --git a/nutshell/segments/table/_symutils.py b/nutshell/segments/table/_symutils.py index 6a8968e..d6ffb63 100644 --- a/nutshell/segments/table/_symutils.py +++ b/nutshell/segments/table/_symutils.py @@ -54,7 +54,6 @@ def with_neighborhood(cls, nbhd): nbhd, cls.__name__, cls.transformation_names, - transformations=cls.transformations, tilde=cls.tilde, permute_hash_indices=cls.permute_hash_indices ) diff --git a/nutshell/segments/table/_transformer.py b/nutshell/segments/table/_transformer.py index d500ca1..8d6c708 100644 --- a/nutshell/segments/table/_transformer.py +++ b/nutshell/segments/table/_transformer.py @@ -194,10 +194,8 @@ def permute_shorthand(self, children, meta): return MetaTuple(meta, (self.kill_string(state, meta), str(permute[0]) if permute else None)) def main(self, children, meta): + self._tbl.use_sym_type() trlen = self._tbl.trlen - if not self._tbl.default_sym_used and self.directives['symmetries'] == 'none': - self._tbl.default_sym_used = True - self._tbl.add_sym_type('none') initial, resultant = children.pop(0), children.pop(-1) try: @@ -348,16 +346,16 @@ def cdir_delay(self, children, meta): @inline def symmetried_aux(self, meta, symmetries, *auxiliaries): - self._tbl.add_sym_type(symmetries) symmetries = symutils.get_sym_type(self._tbl.neighborhood, symmetries) + self._tbl.use_sym_type(symmetries) for aux in auxiliaries: aux.symmetries = symmetries return auxiliaries @inline def stationary_symmetried_aux(self, meta, symmetries, *auxiliaries): - self._tbl.add_sym_type(symmetries) symmetries = symutils.get_sym_type(self._tbl.neighborhood, symmetries) + self._tbl.use_sym_type(symmetries) for aux in auxiliaries: aux.symmetries = symmetries aux.stationary = True diff --git a/nutshell/segments/table/inline_rulestring/default_rs.py b/nutshell/segments/table/inline_rulestring/default_rs.py index 870d0bc..2eadb6b 100644 --- a/nutshell/segments/table/inline_rulestring/default_rs.py +++ b/nutshell/segments/table/inline_rulestring/default_rs.py @@ -21,7 +21,7 @@ def standard(meta, initial, fg, bg, resultant, rulestring, variables, table): r4r_nbhds[nb_count] = letters if r4r_nbhds: - table.add_sym_type('rotate4reflect') + table.use_sym_type('rotate4reflect') r4r = symutils.get_sym_type(table.neighborhood, 'rotate4reflect') get_fg, get_bg = _get_getter(table, fg, 'FG'), _get_getter(table, bg, 'BG') diff --git a/nutshell/segments/table/table.py b/nutshell/segments/table/table.py index 1d3d0b1..7c70e61 100644 --- a/nutshell/segments/table/table.py +++ b/nutshell/segments/table/table.py @@ -55,11 +55,9 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self._n_states = 1 + max(self._constants.values()) self.directives = {'neighborhood': 'Moore', 'symmetries': 'none', 'states': self._n_states} - self.sym_types = set() self.transitions = [] self._nbhd = None - self._symmetries = None # these go together - self.symmetries = 'none' # these go together + self._symmetries = symutils.get_sym_type(nbhoods.Neighborhood('Moore'), 'none') self.gollyize_nbhd = None self.default_sym_used = False self.vars = Bidict() # {VarName(name) | str(name) :: Variable(value)} @@ -69,6 +67,9 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self.available_macros = macros.__dict__.copy() self.modifiers = inline_rulestring.funcs + self.symmetries_used = {self._symmetries: False} + self.neighborhoods_used = {nbhoods.Neighborhood('Moore'): False} + if _define is not None: self.available_macros.update(_define.macros_after) self.modifiers.update(_define.modifiers) @@ -101,6 +102,9 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self.update_special_vars() self._data = transformer.transform(_parsed) + self.sym_types = {sym for sym, used in self.symmetries_used.items() if used} + self.neighborhoods = {nbhd for nbhd, used in self.neighborhoods_used.items() if used} + #self.directives['neighborhoods'] = ... MinSym, name = symutils.find_golly_sym_type(self.sym_types, self.neighborhood) if len(self.sym_types) <= 1 and self.symmetries.transformations == MinSym.transformations: self.final = [t.fix_vars() for t in self._data] @@ -111,7 +115,12 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self._apply_macros() def __getitem__(self, item): - return self._src[item] + try: + return self._src[item] + except IndexError: + print(self._src) + print(item) + raise def __iter__(self): vars_valid = any(i.rep > -1 for i in self.vars) @@ -174,6 +183,8 @@ def neighborhood(self, val): self._nbhd = self.NEIGHBORHOODS[val] else: raise ValueError('Unknown or invalid neighborhood') + if self._nbhd not in self.neighborhoods_used: + self.neighborhoods_used[self._nbhd] = False self.symmetries = self._symmetries.with_neighborhood(self.neighborhood) if not self.neighborhood.supports_transformations(self.symmetries.transformation_names): raise NeighborhoodError( @@ -181,24 +192,25 @@ def neighborhood(self, val): f'by neighborhood {self.neighborhood.cdirs}' ) self._trlen = None - - @property - def trlen(self): - if self._trlen is None: - self._trlen = len(self.neighborhood) - return self._trlen @property def symmetries(self): if self._symmetries is None: self._symmetries = symutils.get_sym_type(self.neighborhood, self.directives['symmetries']) + if self._symmetries not in self.symmetries_used: + self.symmetries_used[self._symmetries] = False return self._symmetries @symmetries.setter def symmetries(self, value): self.directives['symmetries'] = value self._symmetries = symutils.get_sym_type(self.neighborhood, value) if isinstance(value, str) else value - self.add_sym_type(self._symmetries) + + @property + def trlen(self): + if self._trlen is None: + self._trlen = len(self.neighborhood) + return self._trlen @property def n_states(self): @@ -214,6 +226,11 @@ def n_states(self, value): else: self._n_states = self.directives['states'] = value + def use_sym_type(self, sym=None): + if isinstance(sym, str): + sym = symutils.get_sym_type(self.neighborhood, sym) + self.symmetries_used[self.symmetries if sym is None else sym] = True + def update_special_vars(self, value=None): if value == '?': self.directives['states'] = self.n_states @@ -224,12 +241,6 @@ def update_special_vars(self, value=None): self.vars[self.specials['any']] = StateList(range(self.n_states), context=None) self.vars[self.specials['live']] = StateList(range(1, self.n_states), context=None) - def add_sym_type(self, sym): - if isinstance(sym, str): - self.sym_types.add(symutils.get_sym_type(self.neighborhood, sym)) - else: - self.sym_types.add(sym) - def set_macro(self, meta, name, args): self.current_macros.append((meta.lno, self._prep_macro(self.available_macros[name]), args.split())) From 98476909355cb866f90cea03ec0a4dee741a1863 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 15 Jan 2019 22:50:13 -0800 Subject: [PATCH 25/33] Fail to implement neighborhood-switching Symmetries get in the way --- .../AlternatingPermuteTest.rule | 12 +- examples/compiled_ruletables/BeeZero.rule | 160 +++++++++--------- examples/compiled_ruletables/Brew.rule | 128 +++++++------- .../compiled_ruletables/DeficientLife.rule | 42 ++--- examples/compiled_ruletables/ExtendedX.rule | 46 ++--- examples/compiled_ruletables/XHistory.rule | 66 ++++---- nutshell/segments/table/_classes.py | 53 +++--- nutshell/segments/table/_neighborhoods.py | 42 +++-- nutshell/segments/table/_transformer.py | 5 +- nutshell/segments/table/table.py | 8 +- 10 files changed, 297 insertions(+), 265 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 933b8ea..2da496d 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -65,14 +65,14 @@ var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) #### line 48: 0, h, t, any, b, any, any, any, any, h #### -0, any.0, any.1, h.0, any.2, any.3, b.0, any.4, t.0, h.1 -0, any.0, t.0, any.1, any.2, h.0, b.0, any.3, any.4, h.1 -0, h.0, t.0, any.0, any.1, any.2, any.3, any.4, b.0, h.1 -0, h.0, any.0, any.1, any.2, any.3, b.0, any.4, t.0, h.1 +0, any.0, b.0, any.1, any.2, any.3, any.4, h.0, t.0, h.1 +0, any.0, any.1, any.2, any.3, any.4, b.0, h.0, t.0, h.1 +0, h.0, any.0, any.1, b.0, any.2, t.0, any.3, any.4, h.1 +0, any.0, any.1, h.0, b.0, any.2, t.0, any.3, any.4, h.1 +0, any.0, t.0, any.1, any.2, any.3, b.0, h.0, any.4, h.1 0, any.0, any.1, h.0, t.0, any.2, any.3, any.4, b.0, h.1 -0, any.0, any.1, any.2, t.0, any.3, b.0, h.0, any.4, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### -0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 +0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index 2c09185..d0f8e08 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -26,109 +26,109 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations #### line 46: 0, <017 !hensel / 1 / 0>; 2 #### -0, 1, 0, 0, 0, 0, 0, 1, 0, 2 -0, 0, 0, 0, 1, 1, 0, 0, 0, 2 -0, 0, 0, 1, 0, 0, 0, 1, 0, 2 -0, 0, 0, 0, 1, 0, 0, 0, 1, 2 -0, 0, 0, 1, 0, 0, 1, 0, 0, 2 -0, 0, 0, 0, 0, 0, 1, 0, 1, 2 -0, 0, 0, 0, 0, 0, 1, 1, 1, 2 -0, 1, 1, 0, 0, 1, 0, 0, 0, 2 -0, 1, 0, 1, 0, 1, 0, 0, 0, 2 -0, 0, 0, 1, 1, 1, 0, 0, 0, 2 +0, 1, 0, 0, 0, 0, 0, 0, 1, 2 +0, 0, 1, 0, 1, 0, 0, 0, 0, 2 +0, 1, 0, 1, 0, 0, 0, 0, 0, 2 +0, 0, 1, 0, 0, 0, 1, 0, 0, 2 +0, 1, 0, 0, 0, 1, 0, 0, 0, 2 +0, 0, 1, 0, 0, 1, 0, 0, 0, 2 +0, 1, 0, 0, 0, 0, 0, 1, 1, 2 +0, 1, 0, 1, 0, 0,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, 1, 1, 0, 1, 0, 1, 2 -1, 1, 1, 1, 0, 0, 1, 1, 1, 2 -1, 1, 1, 0, 1, 1, 1, 0, 1, 2 -1, 1, 1, 1, 0, 1, 1, 1, 0, 2 +1, 1, 1, 1, 1, 1, 1, 0, 0, 2 +1, 1, 0, 1, 0, 1, 1, 1, 1, 2 +1, 0, 1, 1, 1, 1, 1, 0, 1, 2 +1, 1, 0, 1, 1, 1, 0, 1, 1, 2 +1, 0, 1, 1, 1, 0, 1, 1, 1, 2 1, 1, 1, 0, 1, 1, 0, 1, 1, 2 -1, 1, 1, 1, 0, 1, 0, 1, 1, 2 -1, 1, 1, 1, 1, 1, 1, 0, 1, 2 -1, 1, 1, 1, 1, 1, 1, 1, 0, 2 +1, 1, 1, 1, 0, 1, 1, 1, 1, 2 +1, 1, 1, 1, 1, 0, 1, 1, 1, 2 # Birth - ODD generations #### line 52: 0, <01 odd_b0 / 2 / 0>; 1 #### -0, 0, 2, 2, 2, 2, 2, 2, 2, 1 0, 2, 2, 2, 2, 2, 0, 2, 2, 1 +0, 0, 2, 2, 2, 2, 2, 2, 2, 1 # Survival - ODD generations #### line 55: 2, <017 odd_b0 / 2 / 0>; 1 #### -2, 0, 2, 2, 2, 2, 2, 2, 2, 1 2, 2, 2, 2, 2, 2, 0, 2, 2, 1 -2, 0, 0, 0, 0, 0, 0, 2, 0, 1 -2, 0, 0, 0, 0, 0, 0, 0, 2, 1 +2, 0, 2, 2, 2, 2, 2, 2, 2, 1 +2, 0, 0, 0, 2, 0, 0, 0, 0, 1 +2, 2, 0, 0, 0, 0, 0, 0, 0, 1 #### line 57: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index b0b74e4..5c7f692 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1, 1 -_a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 -_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -_a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1, 1 -_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1 -_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1, 1 +_a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, 1, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### +1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 +1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1, 1 -1, 1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, 1 -1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, 1, 1 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2, 2 -_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2, _b0.5, 2 +1, 1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +1, 1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 +1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 +1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, 1 +1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1, 1 +_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, _b0.5, 2 +_b0.0, 2, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2, _b0.5, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, 2, 2, _b0.4, _b0.5, 2 _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, _b0.5, 2, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, _b0.5, 2 2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2 -2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, 2, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, _b0.5, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 +2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, 2 +2, 2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2, 2 +2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, 2, _b0.4, 2 +2, _b0.0, 2, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2 2, 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 -2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2 -_c0.0, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, _c0.2, 3, 3, 3, _c0.3, _c0.4, _c0.5, 3 -_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3, 3 -_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, _c0.5, 3, 3 +2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2 +_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 +_c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3, _c0.5, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, _c0.1, _c0.2, _c0.3, 3, 3, 3, _c0.4, _c0.5, 3 _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, _c0.1, _c0.2, _c0.3, 3, 3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 -3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3 -3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 -3, _c0.0, _c0.1, 3, 3, 3, _c0.2, _c0.3, _c0.4, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, 3, 3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 +3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, _c0.0, _c0.1, _c0.2, 3, 3, 3, _c0.3, _c0.4, 3 3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 -3, _c0.0, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, 3, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index c555d91..ea180ff 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -54,41 +54,41 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 0, 0, 2 +0, 0, 0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### -0, 0, 0, _b0.0, 0, _b0.1, 0, _b0.2, 0, 3 +0, _b0.0, 0, 0, 0, _b0.1, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, 0, 0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 4 +0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 0, 0, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### -0, _d0.0, _d0.1, _d0.2, 0, 0, 0, 0, 0, 5 +0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 0, 0, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### -0, 0, 0, 0, _e0.0, _e0.1, _e0.2, 0, 0, 6 +0, _e0.0, _e0.1, 0, 0, 0, 0, 0, _e0.2, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### 0, 0, _f0.0, _f0.1, 0, 0, 0, 0, _f0.2, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, 0, _g0.0, 0, _g0.1, 0, 0, _g0.2, 0, 8 +0, 0, 0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, 0, 0, 0, _h0.0, _h0.1, 0, 0, _h0.2, 9 +0, 0, _h0.0, 0, 0, _h0.1, _h0.2, 0, 0, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### -0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 0, 0, 10 +0, 0, 0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, _j0.0, 0, 0, 0, _j0.1, _j0.2, 0, 0, 11 +0, _j0.0, 0, 0, _j0.1, _j0.2, 0, 0, 0, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s2 -live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 -live.0, 0, 0, live.1, live.2, 0, 0, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 -live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 # s2 +live.0, 0, live.1, 0, 0, live.2, 0, 0, 0, 1 +live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 +live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s3 -live.0, live.1, 0, live.2, 0, 0, 0, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 -live.0, 0, 0, live.1, live.2, 0, 0, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, 0, 0, live.2, 1 -live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 # s3 +live.0, 0, live.1, 0, 0, live.2, 0, 0, 0, 1 +live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 +live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index d0f2ef8..f9d7240 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,40 +41,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 -0, on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -0, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 0, on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, 1 -0, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +0, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 0, off.0, on.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -0, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 -0, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 -0, off.0, on.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -0, off.0, on.0, on.1, off.1, off.2, on.2, off.3, off.4, 1 +0, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 +0, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 +0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +0, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, off.0, off.1, on.0, off.2, off.3, off.4, on.1, on.2, 1 #### line 21: 0, birth ~ 1, any; 1 #### -0, any.0, any.1, any.2, any.3, any.4, any.5, birth.0, any.6, 1 0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 +0, any.0, any.1, birth.0, any.2, any.3, any.4, any.5, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### -1, any.0, any.1, death.0, any.2, any.3, any.4, any.5, any.6, 0 +1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 1, any.0, any.1, any.2, death.0, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, off.0, off.1, off.2, off.3, on.0, off.4, on.1, off.5, 1 -1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, off.5, 1 -1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 -1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 -1, off.0, off.1, on.0, off.2, off.3, on.1, off.4, off.5, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 1, off.0, off.1, off.2, off.3, off.4, on.0, off.5, on.1, 1 -1, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 -1, on.0, off.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -1, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +1, off.0, off.1, off.2, off.3, on.0, off.4, on.1, off.5, 1 +1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, off.5, 1 +1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 +1, off.0, off.1, on.0, off.2, off.3, off.4, off.5, on.1, 1 1, on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, 1 -1, off.0, on.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 +1, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 1, off.0, on.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -1, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 -1, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 -1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -1, off.0, on.0, on.1, off.1, off.2, on.2, off.3, off.4, 1 +1, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 +1, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 +1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 +1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 +1, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, on.2, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index 13a6229..a623dc9 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,50 +63,50 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.0, on.1, on.2, 1 -4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 _e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.1, on.2, 1 -4, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, _b0.3, on.2, _b0.4, 1 -4, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 -_e0.0, on.0, on.1, _b0.0, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 -4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 -4, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, _b0.1, on.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, on.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, on.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 +4, on.0, _b0.0, on.1, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 +_e0.0, on.0, _b0.0, on.1, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 4, on.0, on.1, _b0.0, _b0.1, _b0.2, on.2, _b0.3, _b0.4, 3 _e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, on.2, _b0.3, _b0.4, 1 +4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### -1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, 6, _f0.6, 2 -1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 2 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, 6, _f0.6, 4 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 4 +1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 2 +1, _f0.0, _f0.1, 6, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 4 +_g0.0, _f0.0, _f0.1, 6, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, off.0, off.1, off.2, off.3, on.1, off.4, on.2, off.5, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, off.5, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 -on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, on.2, off.4, off.5, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, off.5, on.2, on.0 on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, on.2, on.0 -on.0, off.0, on.1, on.2, on.3, off.1, off.2, off.3, off.4, on.0 -on.0, on.1, off.0, off.1, on.2, on.3, off.2, off.3, off.4, on.0 -on.0, on.1, off.0, on.2, off.1, on.3, off.2, off.3, off.4, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, off.4, on.2, off.5, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, off.5, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, off.5, on.2, on.0 on.0, on.1, on.2, on.3, off.0, off.1, off.2, off.3, off.4, on.0 -on.0, off.0, on.1, on.2, off.1, on.3, off.2, off.3, off.4, on.0 +on.0, on.1, off.0, on.2, off.1, on.3, off.2, off.3, off.4, on.0 on.0, off.0, on.1, off.1, on.2, on.3, off.2, off.3, off.4, on.0 -on.0, on.1, off.0, off.1, on.2, off.2, on.3, off.3, off.4, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, off.3, on.3, off.4, on.0 -on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, on.2, off.1, off.2, on.3, off.3, off.4, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, off.3, on.3, off.4, on.0 +on.0, on.1, off.0, off.1, on.2, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, on.3, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/nutshell/segments/table/_classes.py b/nutshell/segments/table/_classes.py index ce29bca..d0eba48 100644 --- a/nutshell/segments/table/_classes.py +++ b/nutshell/segments/table/_classes.py @@ -54,7 +54,7 @@ def _anonymous(rep=0): class TransitionGroup: - def __init__(self, tbl, initial, napkin, resultant, *, context, extra=None, symmetries=None): + def __init__(self, tbl, initial, napkin, resultant, *, context, extra=None, symmetries=None, nbhd=None): if tbl.n_states < 2: raise Error(None, 'Table uses fewer than two cellstates. Set `states:` directive to 2 or higher to fix') self.ctx = context @@ -62,6 +62,7 @@ def __init__(self, tbl, initial, napkin, resultant, *, context, extra=None, symm self.extra = extra self.tbl = tbl self.symmetries = symmetries or tbl.symmetries + self.nbhd = nbhd or tbl.neighborhood cdir_at = tbl.neighborhood.cdir_at self._tr_dict = {'0': initial, **{cdir_at(k): v for k, v in napkin.items()}} self._tr = [initial, *map(napkin.get, range(1, 1+len(napkin))), resultant] @@ -103,14 +104,14 @@ def expand(self, reference=None): ([*self[:idx], value, *self[1+idx:]] for value in individuals) for new_tr in TransitionGroup.from_seq( - tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries + tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd ).expand() ) if combine: tr = self[:] tr[idx], tr[orig_idx] = StateList(combine, e.split, context=tethered_var.ctx), e.val trs.extend(TransitionGroup.from_seq( - tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries + tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd ).expand()) break except Reshape as e: @@ -121,14 +122,14 @@ def expand(self, reference=None): ([*self[:idx], individual, *self[1+idx:]] for individual in var) for new_tr in TransitionGroup.from_seq( - tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries + tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd ).expand() ) break else: current.append(val) else: - return [Transition(current, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries)] + return [Transition(current, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd)] self._expandeds[reference] = trs return trs @@ -136,7 +137,9 @@ def apply_aux(self, auxiliaries, top=True): if auxiliaries is None: return [] new = [] - for i in (aux for aux in auxiliaries if not aux.stationary): + for i in auxiliaries: + if i.stationary: + continue try: new.extend(i.within(self)) except CoordOutOfBoundsError as e: @@ -152,20 +155,26 @@ def apply_aux(self, auxiliaries, top=True): idx = e.cdir != '0' and self.tbl.neighborhood[e.cdir] individuals, combine = var[:e.split], var[e.split:] if individuals: - aux = Auxiliary(self.tbl, i.initial_cdir, None, Mapping(e.cdir, e.map_to[:-2], context=i.ctx), context=i.ctx, symmetries=i.symmetries) + aux = Auxiliary( + self.tbl, + i.initial_cdir, + None, + Mapping(e.cdir, e.map_to[:-2], context=i.ctx), + context=i.ctx, symmetries=i.symmetries, nbhd=i.nbhd + ) new.extend( new_tr for tr in ([*self[:idx], val, *self[1+idx:]] for val in individuals if val.value is not None) for new_tr in TransitionGroup.from_seq( - tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries + tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd ).apply_aux([aux], False) ) if combine and e.val is not None: - aux = Auxiliary(self.tbl, i.initial_cdir, None, e.val, context=i.ctx) + aux = Auxiliary(self.tbl, i.initial_cdir, None, e.val, context=i.ctx, symmetries=i.symmetries, nbhd=i.nbhd) new.extend(TransitionGroup.from_seq( [*self[:idx], StateList(combine, e.split, context=i.ctx), *self[1+idx:]], - self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries + self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd ).apply_aux([aux], False)) except Reshape as e: var = self[e.cdir].within(self) @@ -175,7 +184,7 @@ def apply_aux(self, auxiliaries, top=True): ([*self[:idx], val, *self[1+idx:]] for val in var) for new_tr in TransitionGroup.from_seq( - tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries + tr, self.tbl, context=self.ctx, extra=self.extra, symmetries=self.symmetries, nbhd=self.nbhd ).apply_aux([i], False) ) @@ -192,7 +201,7 @@ def apply_aux(self, auxiliaries, top=True): for i in self.symmetries(napkin).expand() for j in TransitionGroup.from_seq( [next(d[name]) for name in [initial, *i, resultant]], - tr.tbl, context=tr.ctx, extra=self.extra, symmetries=tr.symmetries + tr.tbl, context=tr.ctx, extra=self.extra, symmetries=tr.symmetries, nbhd=self.nbhd ).apply_aux(stationaries) ) rep = len(stationaries) @@ -212,7 +221,7 @@ def apply_aux(self, auxiliaries, top=True): class Transition: - def __init__(self, tr, tbl, *, context, extra=None, symmetries=None): + def __init__(self, tr, tbl, *, context, extra=None, symmetries=None, nbhd=None): self.ctx = context self.extra = extra self.tr = tr @@ -228,6 +237,7 @@ def __init__(self, tr, tbl, *, context, extra=None, symmetries=None): cdir_at = tbl.neighborhood.cdir_at self._tr_dict = {'0': self.initial, **{cdir_at(k): v for k, v in enumerate(self.napkin, 1)}} self.symmetries = symmetries or tbl.symmetries + self.nbhd = nbhd or tbl.neighborhood self.tbl = tbl def __repr__(self): @@ -270,9 +280,9 @@ def fix_vars(self): raise SyntaxErr(v.ctx, 'Attempted binding to another binding') ret[i] = ret[cdir] - if self.tbl.gollyize_nbhd is not None: + if not self.tbl.neighborhood_ok(): return FinalTransition( - [ret[0], *self.tbl.gollyize_nbhd(self.tbl, ret[1:-1], 1 + seen.get('any', 0)), ret[-1]], + [ret[0], *self.nbhd.gollyizer_for(self.tbl)(self.tbl, ret[1:-1], 1 + seen.get('any', 0)), ret[-1]], context=self.ctx, extra=self.extra ) return FinalTransition(ret, context=self.ctx, extra=self.extra) @@ -331,9 +341,9 @@ def fix_final(self, tr): variables[variables.inv[i]].update_rep(int(tag)) else: ret.append(i) - if self.tbl.gollyize_nbhd is not None: + if not self.tbl.neighborhood_ok(): return FinalTransition( - [ret[0], *self.tbl.gollyize_nbhd(self.tbl, ret[1:-1], seen.get('any', {})), ret[-1]], + [ret[0], *self.nbhd.gollyizer_for(self.tbl)(self.tbl, ret[1:-1], seen.get('any', {})), ret[-1]], context=self.ctx, extra=self.extra ) return FinalTransition(ret, context=self.ctx, extra=self.extra) @@ -703,13 +713,14 @@ def reindex(self, index): class Auxiliary: - def __init__(self, tbl, initial_cdir, delay, resultant, *, context, symmetries=None): + def __init__(self, tbl, initial_cdir, delay, resultant, *, context, symmetries=None, nbhd=None): self.ctx = context self.tbl = tbl self.initial_cdir = initial_cdir self.orig = Coord.from_name(initial_cdir).inv self.resultant = resultant self.symmetries = symmetries or tbl.symmetries + self.nbhd = nbhd or tbl.neighborhood self.stationary = False if delay is not None: raise UnsupportedFeature( @@ -760,7 +771,7 @@ def _make_tr(self, tr, resultant): def from_int(self, tr): return TransitionGroup.from_seq( - self._make_tr(tr, self.resultant), self.tbl, context=self.ctx, symmetries=self.symmetries + self._make_tr(tr, self.resultant), self.tbl, context=self.ctx, symmetries=self.symmetries, nbhd=self.nbhd ).expand(tr) def from_binding(self, tr): @@ -770,13 +781,13 @@ def from_binding(self, tr): if isinstance(within, ResolvedBinding): within.cdir = Coord.from_name(within.cdir).move(*self.orig).name return TransitionGroup.from_seq( - self._make_tr(tr, within), self.tbl, context=self.ctx, symmetries=self.symmetries + self._make_tr(tr, within), self.tbl, context=self.ctx, symmetries=self.symmetries, nbhd=self.nbhd ).expand(tr) def from_mapping(self, tr): within = self.resultant.within(tr) # always raises some exception unless already a VarValue return [] if within.value is None else TransitionGroup.from_seq( - self._make_tr(tr, self.resultant.within(tr).value), self.tbl, context=self.ctx, symmetries=self.symmetries + self._make_tr(tr, self.resultant.within(tr).value), self.tbl, context=self.ctx, symmetries=self.symmetries, nbhd=self.nbhd ).expand(tr) diff --git a/nutshell/segments/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py index a9456e5..be54f51 100644 --- a/nutshell/segments/table/_neighborhoods.py +++ b/nutshell/segments/table/_neighborhoods.py @@ -1,5 +1,8 @@ from collections import OrderedDict from itertools import takewhile, permutations + +from bidict import bidict + from ._classes import Coord from ._errors import NeighborhoodError @@ -20,20 +23,23 @@ class Neighborhood: - GOLLY_NBHDS = { + GOLLY_NBHDS = bidict({ 'oneDimensional': ('W', 'E'), 'vonNeumann': ('N', 'E', 'S', 'W'), 'hexagonal': ('N', 'E', 'SE', 'S', 'W', 'NW'), 'Moore': ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW') - } + }) def __init__(self, cdirs): + _golly_nbhds = self.__class__.GOLLY_NBHDS if isinstance(cdirs, str): - cdirs = self.GOLLY_NBHDS[cdirs] + cdirs = _golly_nbhds[cdirs] self.cdirs = tuple(cdirs) self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) self._inv = dict(enumerate(cdirs, 1)) self.idxes = {v: k for k, v in self._inv.items()} + self.is_golly_nbhd = self.cdirs in _golly_nbhds.inv + self._gollyizers = {} def __contains__(self, item): return item in self.idxes @@ -78,7 +84,14 @@ def cdir_at(self, idx): return self._inv[idx] def gollyizer_for(self, tbl): - return get_gollyizer(tbl, self.cdirs) + _golly_nbhds_inv = self.__class__.GOLLY_NBHDS.inv + if tbl.neighborhood not in self._gollyizers: + self._gollyizers[tbl.neighborhood] = ( + get_gollyizer(tbl, self.cdirs, golly_nbhd=_golly_nbhds_inv[tbl.neighborhood.cdirs]) + if tbl.neighborhood.cdirs in _golly_nbhds_inv + else get_gollyizer(tbl, self.cdirs) + ) + return self._gollyizers[tbl.neighborhood] def supports_transformations(self, transformations): for method, *args in transformations: @@ -91,8 +104,7 @@ def supports_transformations(self, transformations): self.reflect_across(*args) except Exception: return False - # if method == 'permute': - # True + # 'permute' -> True return True def supports(self, sym_type): @@ -158,22 +170,28 @@ def identity(self, *, as_cls=True): return (self.cdirs,) +def find_golly_neighborhood(nbhds): + common = {cdir for nbhd in nbhds for cdir in nbhd.cdirs} + for name, s in NBHD_SETS.items(): + if common <= s: + return name + raise ValueError(f'Invalid (non-Moore-subset) common neighborhood {common}') + + def get_gollyizer(tbl, nbhd, *, golly_nbhd=None): nbhd_set = set(nbhd) if golly_nbhd is not None: golly_set = NBHD_SETS[golly_nbhd] - return ( - fill.__get__(ORDERED_NBHDS[golly_nbhd]) - if nbhd_set < golly_set - else lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) - ) + if nbhd_set < golly_set: + return fill.__get__(ORDERED_NBHDS[golly_nbhd]) + return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[golly_nbhd], tbl, napkin) for name, s in NBHD_SETS.items(): if nbhd_set <= s: tbl.directives['neighborhood'] = name if nbhd_set < s: return fill.__get__(ORDERED_NBHDS[name]) return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) - raise ValueError('Invalid (non-Moore-subset) neighborhood {nbhd_set}}') + raise ValueError(f'Invalid (non-Moore-subset) neighborhood {nbhd_set}') def reorder(ordered_nbhd, tbl, napkin): diff --git a/nutshell/segments/table/_transformer.py b/nutshell/segments/table/_transformer.py index 8d6c708..8ef58af 100644 --- a/nutshell/segments/table/_transformer.py +++ b/nutshell/segments/table/_transformer.py @@ -51,7 +51,6 @@ def __init__(self, tbl): self._tbl = tbl self.directives = tbl.directives self.vars = tbl.vars - self._nbhd_assigned = False def kill_string(self, val, meta, li=False): if isinstance(val, str): @@ -141,8 +140,6 @@ def directive(self, meta, name, val): if name in ('n_states', 'states'): self._tbl.update_special_vars(val) elif name == 'neighborhood': - if self._nbhd_assigned: - raise Error(meta, '`neighborhood` directive cannot be reassigned') try: self._tbl.neighborhood = val except ValueError as e: @@ -155,7 +152,6 @@ def directive(self, meta, name, val): f"{nbhd_str}\n" f' does not support current symmetry type {self._tbl.symmetries.__name__!r}' ) - self._nbhd_assigned = True else: # directives are more like comments than they are source self._tbl.comments[meta[0]] = f'#### {name}: {cmt_val}' @@ -195,6 +191,7 @@ def permute_shorthand(self, children, meta): def main(self, children, meta): self._tbl.use_sym_type() + self._tbl.use_neighborhood() trlen = self._tbl.trlen initial, resultant = children.pop(0), children.pop(-1) diff --git a/nutshell/segments/table/table.py b/nutshell/segments/table/table.py index 7c70e61..8ef2305 100644 --- a/nutshell/segments/table/table.py +++ b/nutshell/segments/table/table.py @@ -104,7 +104,7 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self.sym_types = {sym for sym, used in self.symmetries_used.items() if used} self.neighborhoods = {nbhd for nbhd, used in self.neighborhoods_used.items() if used} - #self.directives['neighborhoods'] = ... + self.directives['neighborhood'] = self.neighborhood = nbhoods.find_golly_neighborhood(self.neighborhoods) MinSym, name = symutils.find_golly_sym_type(self.sym_types, self.neighborhood) if len(self.sym_types) <= 1 and self.symmetries.transformations == MinSym.transformations: self.final = [t.fix_vars() for t in self._data] @@ -226,11 +226,17 @@ def n_states(self, value): else: self._n_states = self.directives['states'] = value + def neighborhood_ok(self): + return sum(self.neighborhoods_used.values()) > 1 or not next(iter(self.neighborhoods_used)).is_golly_nbhd + def use_sym_type(self, sym=None): if isinstance(sym, str): sym = symutils.get_sym_type(self.neighborhood, sym) self.symmetries_used[self.symmetries if sym is None else sym] = True + def use_neighborhood(self, nbhd=None): + self.neighborhoods_used[self.neighborhood if nbhd is None else nbhd] = True + def update_special_vars(self, value=None): if value == '?': self.directives['states'] = self.n_states From cfd494bdf7164c8ec327ef69a1b8967cd0dd122f Mon Sep 17 00:00:00 2001 From: Eli Date: Sat, 19 Jan 2019 23:51:32 -0800 Subject: [PATCH 26/33] Implement proper neighborhood conversion between symmetries; make most things slower --- .../AlternatingPermuteTest.rule | 10 +- examples/compiled_ruletables/BeeZero.rule | 172 +++++++++--------- examples/compiled_ruletables/Brew.rule | 136 +++++++------- .../compiled_ruletables/DeficientLife.rule | 30 +-- examples/compiled_ruletables/ExtendedX.rule | 54 +++--- examples/compiled_ruletables/XHistory.rule | 70 +++---- nutshell/segments/table/_neighborhoods.py | 48 ++++- nutshell/segments/table/_symutils.py | 40 ++-- test.py | 1 + 9 files changed, 303 insertions(+), 258 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 2da496d..59114e8 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -65,12 +65,12 @@ var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) #### line 48: 0, h, t, any, b, any, any, any, any, h #### +0, any.0, b.0, any.1, any.2, any.3, t.0, h.0, any.4, h.1 +0, any.0, any.1, h.0, b.0, any.2, any.3, any.4, t.0, h.1 +0, any.0, b.0, h.0, t.0, any.1, any.2, any.3, any.4, h.1 0, any.0, b.0, any.1, any.2, any.3, any.4, h.0, t.0, h.1 -0, any.0, any.1, any.2, any.3, any.4, b.0, h.0, t.0, h.1 -0, h.0, any.0, any.1, b.0, any.2, t.0, any.3, any.4, h.1 -0, any.0, any.1, h.0, b.0, any.2, t.0, any.3, any.4, h.1 -0, any.0, t.0, any.1, any.2, any.3, b.0, h.0, any.4, h.1 -0, any.0, any.1, h.0, t.0, any.2, any.3, any.4, b.0, h.1 +0, any.0, any.1, h.0, any.2, any.3, t.0, any.4, b.0, h.1 +0, any.0, t.0, any.1, any.2, any.3, any.4, h.0, b.0, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### 0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index d0f8e08..9e8306b 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -26,109 +26,109 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations #### line 46: 0, <017 !hensel / 1 / 0>; 2 #### -0, 1, 0, 0, 0, 0, 0, 0, 1, 2 -0, 0, 1, 0, 1, 0, 0, 0, 0, 2 -0, 1, 0, 1, 0, 0, 0, 0, 0, 2 -0, 0, 1, 0, 0, 0, 1, 0, 0, 2 0, 1, 0, 0, 0, 1, 0, 0, 0, 2 -0, 0, 1, 0, 0, 1, 0, 0, 0, 2 -0, 1, 0, 0, 0, 0, 0, 1, 1, 2 -0, 1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, 2, 2, 2, 2, 0, 1 0, 0, 2, 2, 2, 2, 2, 2, 2, 1 # Survival - ODD generations #### line 55: 2, <017 odd_b0 / 2 / 0>; 1 #### -2, 2, 2, 2, 2, 2, 0, 2, 2, 1 +2, 2, 2, 2, 2, 2, 2, 2, 0, 1 2, 0, 2, 2, 2, 2, 2, 2, 2, 1 -2, 0, 0, 0, 2, 0, 0, 0, 0, 1 -2, 2, 0, 0, 0, 0, 0, 0, 0, 1 +2, 0, 2, 0, 0, 0, 0, 0, 0, 1 +2, 0, 0, 2, 0, 0, 0, 0, 0, 1 #### line 57: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index 5c7f692..1bc8d7d 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -49,86 +49,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, _a0.5, 1 -_a0.0, 1, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, 1, 1, 1, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1, 1 +_a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 +_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 +_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1 _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1 -_a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, _a0.5, 1, 1 -_a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1, 1 -1, 1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, 1 -1, 1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1, 1 +1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, 1, 1, 1, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, 1, 1 +1, 1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1 +1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 +1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1 +1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 +1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, 1 1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 -1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1 -1, _a0.0, 1, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1 -1, _a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, 1 -1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1, 1 -_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, _b0.5, 2 -_b0.0, 2, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2, _b0.5, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, 2, 2, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 -_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, 2, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2, _b0.5, 2 +_b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, _b0.5, 2 _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, _b0.5, 2, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, _b0.5, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 +_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 +_b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, 2 -2, 2, _b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2 -2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2, 2 -2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, 2, _b0.4, 2 -2, _b0.0, 2, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, 2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, 2 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, 2, _b0.4, 2 +2, _b0.0, _b0.1, 2, 2, 2, _b0.2, _b0.3, _b0.4, 2 2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 -2, _b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, 2 -2, 2, _b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2 -_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 -_c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 +2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -_c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, _c0.1, _c0.2, _c0.3, 3, 3, 3, _c0.4, _c0.5, 3 -_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 +_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 +_c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3, 3 +_c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3, 3 +_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 -3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, 3, _c0.4, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 -3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, 3 -3, _c0.0, _c0.1, _c0.2, 3, 3, 3, _c0.3, _c0.4, 3 -3, 3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 -3, _c0.0, 3, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 +3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 +3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3, 3 +3, 3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3, 3 +3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index ea180ff..3cf6e09 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -54,40 +54,40 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, 0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 2 +0, 0, _a0.0, 0, 0, 0, _a0.1, 0, _a0.2, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### -0, _b0.0, 0, 0, 0, _b0.1, 0, _b0.2, 0, 3 +0, _b0.0, 0, _b0.1, 0, 0, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 0, 0, 4 +0, 0, _c0.0, 0, 0, _c0.1, 0, _c0.2, 0, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### 0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 0, 0, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### -0, _e0.0, _e0.1, 0, 0, 0, 0, 0, _e0.2, 6 +0, 0, 0, 0, 0, 0, _e0.0, _e0.1, _e0.2, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### -0, 0, _f0.0, _f0.1, 0, 0, 0, 0, _f0.2, 7 +0, 0, 0, 0, _f0.0, 0, _f0.1, _f0.2, 0, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, 0, 0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 8 +0, 0, _g0.0, 0, 0, _g0.1, 0, 0, _g0.2, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, 0, _h0.0, 0, 0, _h0.1, _h0.2, 0, 0, 9 +0, _h0.0, 0, 0, _h0.1, 0, 0, 0, _h0.2, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### -0, 0, 0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 10 +0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 0, 0, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### -0, _j0.0, 0, 0, _j0.1, _j0.2, 0, 0, 0, 11 +0, _j0.0, _j0.1, 0, 0, _j0.2, 0, 0, 0, 11 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 # s2 -live.0, 0, live.1, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s2 live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 -live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 +live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 # s3 -live.0, 0, live.1, 0, 0, live.2, 0, 0, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s3 live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 -live.0, 0, 0, 0, 0, 0, live.1, 0, live.2, 1 +live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 +live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 # Death otherwise #### line 22: any, any; 0 #### diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index f9d7240..6b52a6a 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -41,40 +41,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, 1 -0, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 -0, off.0, on.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -0, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 -0, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -0, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 -0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 -0, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 -0, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, on.0, on.1, off.0, off.1, off.2, off.3, on.2, off.4, 1 +0, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 +0, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 0, off.0, off.1, on.0, off.2, off.3, off.4, on.1, on.2, 1 +0, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 +0, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 +0, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 +0, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 +0, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 #### line 21: 0, birth ~ 1, any; 1 #### -0, any.0, birth.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 -0, any.0, any.1, birth.0, any.2, any.3, any.4, any.5, any.6, 1 +0, any.0, any.1, any.2, birth.0, any.3, any.4, any.5, any.6, 1 +0, any.0, any.1, any.2, any.3, birth.0, any.4, any.5, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### 1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 -1, any.0, any.1, any.2, death.0, any.3, any.4, any.5, any.6, 0 +1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, on.0, off.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 -1, off.0, off.1, off.2, off.3, off.4, on.0, off.5, on.1, 1 -1, off.0, off.1, off.2, off.3, on.0, off.4, on.1, off.5, 1 -1, off.0, on.0, off.1, off.2, off.3, on.1, off.4, off.5, 1 -1, on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, 1 -1, off.0, off.1, on.0, off.2, off.3, off.4, off.5, on.1, 1 -1, on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, 1 -1, on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, 1 -1, off.0, on.0, off.1, on.1, on.2, off.2, off.3, off.4, 1 -1, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 -1, on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 -1, off.0, on.0, off.1, off.2, on.1, off.3, off.4, on.2, 1 -1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, on.2, 1 -1, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 +1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 +1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, off.5, 1 +1, off.0, off.1, off.2, off.3, on.0, on.1, off.4, off.5, 1 +1, off.0, on.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 +1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, off.5, 1 +1, on.0, on.1, off.0, off.1, off.2, off.3, on.2, off.4, 1 +1, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 +1, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, on.2, 1 +1, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 +1, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 +1, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 +1, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 +1, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index a623dc9..7a1f989 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -63,50 +63,50 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### +4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, _b0.2, on.0, on.1, on.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, on.2, _b0.3, _b0.4, 1 +4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 _e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, _b0.0, on.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 -_e0.0, _b0.0, on.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, on.1, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 3 -_e0.0, on.0, _b0.0, on.1, on.2, _b0.1, _b0.2, _b0.3, _b0.4, 1 -4, on.0, on.1, _b0.0, _b0.1, _b0.2, on.2, _b0.3, _b0.4, 3 -_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, on.2, _b0.3, _b0.4, 1 -4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 -4, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, on.1, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 3 _e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 1 -4, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 -_e0.0, _b0.0, _b0.1, on.0, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 +4, on.0, _b0.0, on.1, _b0.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, on.0, _b0.0, on.1, _b0.1, on.2, _b0.2, _b0.3, _b0.4, 1 +4, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 1 +4, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 +_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### -1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 2 -1, _f0.0, _f0.1, 6, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, 6, _f0.5, _f0.6, 4 -_g0.0, _f0.0, _f0.1, 6, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 +1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 2 +1, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 2 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 4 +_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, on.1, off.0, off.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, off.2, off.3, off.4, on.1, off.5, on.2, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, off.4, on.2, off.5, on.0 -on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, off.5, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, off.5, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, off.4, off.5, on.2, on.0 -on.0, on.1, on.2, on.3, off.0, off.1, off.2, off.3, off.4, on.0 -on.0, on.1, off.0, on.2, off.1, on.3, off.2, off.3, off.4, on.0 -on.0, off.0, on.1, off.1, on.2, on.3, off.2, off.3, off.4, on.0 -on.0, off.0, off.1, off.2, on.1, on.2, off.3, on.3, off.4, on.0 -on.0, on.1, off.0, off.1, on.2, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, on.3, on.0 -on.0, off.0, on.1, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 +on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, off.5, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, on.2, off.4, off.5, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, off.5, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, off.5, on.0 +on.0, on.1, on.2, off.0, off.1, off.2, off.3, on.3, off.4, on.0 +on.0, off.0, on.1, on.2, on.3, off.1, off.2, off.3, off.4, on.0 +on.0, off.0, on.1, on.2, off.1, off.2, off.3, off.4, on.3, on.0 on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, on.3, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, on.2, on.3, off.4, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, off.3, on.3, off.4, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, off.1, on.2, off.2, on.3, off.3, off.4, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/nutshell/segments/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py index be54f51..749f33b 100644 --- a/nutshell/segments/table/_neighborhoods.py +++ b/nutshell/segments/table/_neighborhoods.py @@ -22,6 +22,22 @@ } +class LazyProperty: + """ + Allows definition of properties calculated once and once only. + From user Cyclone on StackOverflow, modified + """ + def __init__(self, func): + self.func = func + + def __get__(self, obj, cls): + if obj is None: + return self + ret_value = self.func(obj) + setattr(obj, self.func.__name__, ret_value) + return ret_value + + class Neighborhood: GOLLY_NBHDS = bidict({ 'oneDimensional': ('W', 'E'), @@ -31,15 +47,31 @@ class Neighborhood: }) def __init__(self, cdirs): - _golly_nbhds = self.__class__.GOLLY_NBHDS if isinstance(cdirs, str): - cdirs = _golly_nbhds[cdirs] + cdirs = self.__class__.GOLLY_NBHDS[cdirs] self.cdirs = tuple(cdirs) - self.coord_cdirs = tuple(map(Coord.from_name, cdirs)) - self._inv = dict(enumerate(cdirs, 1)) - self.idxes = {v: k for k, v in self._inv.items()} - self.is_golly_nbhd = self.cdirs in _golly_nbhds.inv - self._gollyizers = {} + # lots of things moved to LazyProperty in order + # to GREATLY reduce instantiation time + + @LazyProperty + def coord_cdirs(self): + return tuple(map(Coord.from_name, self.cdirs)) + + @LazyProperty + def _inv(self): + return dict(enumerate(self.cdirs, 1)) + + @LazyProperty + def idxes(self): + return {v: k for k, v in self._inv.items()} + + @LazyProperty + def is_golly_nbhd(self): + return self.cdirs in self.__class__.GOLLY_NBHDS.inv + + @LazyProperty + def _gollyizers(self): + return {} def __contains__(self, item): return item in self.idxes @@ -140,7 +172,7 @@ def reflect_across(self, endpoint, *, as_cls=True): return Neighborhood(sorted(r, key=r.get)) return tuple(sorted(r, key=r.get)) - def reflections_across(self, endpoint, as_cls): + def reflections_across(self, endpoint, *, as_cls=True): if as_cls: return (self, self.reflect_across(endpoint)) return [self.cdirs, self.reflect_across(endpoint, as_cls=as_cls)] diff --git a/nutshell/segments/table/_symutils.py b/nutshell/segments/table/_symutils.py index d6ffb63..b97f68d 100644 --- a/nutshell/segments/table/_symutils.py +++ b/nutshell/segments/table/_symutils.py @@ -16,7 +16,7 @@ class Napkin(tuple): transformations = None tilde = None _RECENTS = {} - + def __init__(self, _): self.cdir_map = dict(zip(self.nbhd, self)) self._expanded = None @@ -29,17 +29,21 @@ def __init_subclass__(cls): if cls.transformation_names is None: raise NotImplementedError('Please override class attribute `transformation_names` in Napkin subclass') if cls.transformations is None and cls.nbhd is not None: - if len(cls.transformation_names) > 1: - raise NotImplementedError('Please override class attribute `transformations` in Napkin subclass') - func, *args = cls.transformation_names[0] - cls.transformations = frozenset(getattr(cls.nbhd, func)(*args, as_cls=False)) + transformations, nbhd = None, cls.nbhd + for name, *args in cls.transformation_names: + transformations = ( + getattr(nbhd, name)(*args) + if transformations is None + else [j for i in transformations for j in getattr(i, name)(*args)] + ) + cls.transformations = frozenset(map(tuple, transformations)) cls._RECENTS = {} if not cls.test_nbhd(): raise NeighborhoodError(f'Symmetry type {cls.__name__!r} is not supported by its neighborhood {cls.nbhd.cdirs}') def __hash__(self): if self._hash is None: - self._hash = hash(tuple(sorted(self.expanded))) + self._hash = hash(self.expanded) return self._hash def __eq__(self, other): @@ -91,14 +95,15 @@ def compose(cls, other): @classmethod def combine(cls, other): - if cls.nbhd != other.nbhd: - raise TypeError(f'Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') - return new_sym_type( - cls.nbhd, - f'{cls.__name__}/{other.__name__}', - cls.transformation_names + other.transformation_names, - transformations=cls.transformations|other.transformations - ) + raise NotImplementedError('Symmetry-combining is currently not supported') + #if cls.nbhd != other.nbhd: + # raise TypeError(f'Cannot combine symmetries of different neighborhoods {cls.nbhd!r} and {other.nbhd!r}') + #return new_sym_type( + # cls.nbhd, + # f'{cls.__name__}/{other.__name__}', + # cls.transformation_names + other.transformation_names, + # transformations=cls.transformations|other.transformations + # ) @classmethod def test_nbhd(cls): @@ -339,6 +344,13 @@ def __iter__(self): 'rotate': rotate, } +METHOD_NAME_MAP = { + 'permutations': permute, + 'rotations_by': rotate, + 'reflections_across': reflect, + 'identity': none +} + _permute = permute() _FORBIDDEN = {('hexagonal', 'reflect'), ('Moore', 'rotate2'), ('vonNeumann', 'rotate2'), ('oneDimensional', 'rotate2')} for nbhd_name in Neighborhood.GOLLY_NBHDS: diff --git a/test.py b/test.py index f970231..eb1b007 100755 --- a/test.py +++ b/test.py @@ -45,6 +45,7 @@ def test_codecov(): nutshell_rand.seed(RAND_SEED) else: for fname in walk: + print(fname) if len(ARGV) < 3 or fname.split('.')[0] in ARGV[2:]: with open('./examples/nutshells/' + fname) as fp: try: From 3cd7b01561ceee6a744e23ee22fe2487ac0d6e7b Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 30 Jan 2019 23:01:33 -0800 Subject: [PATCH 27/33] Implement incorrect neighborhood-switching --- nutshell/common/utils.py | 15 +++-- nutshell/segments/table/_classes.py | 22 ++++--- nutshell/segments/table/_neighborhoods.py | 72 +++++++++-------------- nutshell/segments/table/_symutils.py | 15 ++++- nutshell/segments/table/table.py | 6 +- 5 files changed, 66 insertions(+), 64 deletions(-) diff --git a/nutshell/common/utils.py b/nutshell/common/utils.py index 11fdd31..04dec3b 100644 --- a/nutshell/common/utils.py +++ b/nutshell/common/utils.py @@ -13,17 +13,16 @@ class LazyProperty: """ Allows definition of properties calculated once and once only. - From user Cyclone on StackOverflow; modified slightly to look more - coherent for my own benefit. + From user Cyclone on StackOverflow & modified slightly """ - def __init__(self, method): - self.method = method + def __init__(self, func): + self.func = func def __get__(self, obj, cls): - if not obj: - return None - ret = self.method(obj) - setattr(obj, self.method.__name__, ret) + if obj is None: + return self + ret = self.func(obj) + setattr(obj, self.func.__name__, ret) return ret diff --git a/nutshell/segments/table/_classes.py b/nutshell/segments/table/_classes.py index d0eba48..4255132 100644 --- a/nutshell/segments/table/_classes.py +++ b/nutshell/segments/table/_classes.py @@ -282,7 +282,7 @@ def fix_vars(self): if not self.tbl.neighborhood_ok(): return FinalTransition( - [ret[0], *self.nbhd.gollyizer_for(self.tbl)(self.tbl, ret[1:-1], 1 + seen.get('any', 0)), ret[-1]], + [ret[0], *self.nbhd.converter_to(self.tbl.neighborhood)(ret[1:-1]), ret[-1]], context=self.ctx, extra=self.extra ) return FinalTransition(ret, context=self.ctx, extra=self.extra) @@ -316,6 +316,8 @@ def fix_partial(self): varname.update_rep(seen[varname]) ret[cdir] = f'{varname}.{seen[varname]}' ret[i] = ret[cdir] + if not self.tbl.neighborhood_ok(): + return [ret[0], *self.nbhd.converter_to(self.tbl.neighborhood)(ret[1:-1]), ret[-1]] return ret def fix_final(self, tr): @@ -341,16 +343,22 @@ def fix_final(self, tr): variables[variables.inv[i]].update_rep(int(tag)) else: ret.append(i) - if not self.tbl.neighborhood_ok(): - return FinalTransition( - [ret[0], *self.nbhd.gollyizer_for(self.tbl)(self.tbl, ret[1:-1], seen.get('any', {})), ret[-1]], - context=self.ctx, extra=self.extra - ) + #if not self.tbl.neighborhood_ok(): + # return FinalTransition( + # [ret[0], *self.nbhd.converter_to(self.tbl.neighborhood)(ret[1:-1], seen.get('any', {})), ret[-1]], + # context=self.ctx, extra=self.extra + # ) return FinalTransition(ret, context=self.ctx, extra=self.extra) def in_symmetry(self, NewSymmetry): initial, *napkin, resultant = self.fix_partial() - return [self.fix_final([initial, *i, resultant]) for i in distinct(NewSymmetry(j) for j in self.symmetries(napkin).expanded)] + self.symmetries = self.symmetries.padded_to_neighborhood(self.tbl.neighborhood) + return [ + self.fix_final([initial, *i, resultant]) + for i in distinct( + NewSymmetry(j) for j in self.symmetries(napkin).expanded + ) + ] class FinalTransition(list): diff --git a/nutshell/segments/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py index 749f33b..ff2c994 100644 --- a/nutshell/segments/table/_neighborhoods.py +++ b/nutshell/segments/table/_neighborhoods.py @@ -1,8 +1,10 @@ from collections import OrderedDict +from functools import partial from itertools import takewhile, permutations from bidict import bidict +from nutshell.common.utils import LazyProperty from ._classes import Coord from ._errors import NeighborhoodError @@ -22,22 +24,6 @@ } -class LazyProperty: - """ - Allows definition of properties calculated once and once only. - From user Cyclone on StackOverflow, modified - """ - def __init__(self, func): - self.func = func - - def __get__(self, obj, cls): - if obj is None: - return self - ret_value = self.func(obj) - setattr(obj, self.func.__name__, ret_value) - return ret_value - - class Neighborhood: GOLLY_NBHDS = bidict({ 'oneDimensional': ('W', 'E'), @@ -50,8 +36,6 @@ def __init__(self, cdirs): if isinstance(cdirs, str): cdirs = self.__class__.GOLLY_NBHDS[cdirs] self.cdirs = tuple(cdirs) - # lots of things moved to LazyProperty in order - # to GREATLY reduce instantiation time @LazyProperty def coord_cdirs(self): @@ -115,15 +99,15 @@ def cdir_at(self, idx): return self._inv[len(self) + idx] return self._inv[idx] - def gollyizer_for(self, tbl): + def converter_to(self, other): _golly_nbhds_inv = self.__class__.GOLLY_NBHDS.inv - if tbl.neighborhood not in self._gollyizers: - self._gollyizers[tbl.neighborhood] = ( - get_gollyizer(tbl, self.cdirs, golly_nbhd=_golly_nbhds_inv[tbl.neighborhood.cdirs]) - if tbl.neighborhood.cdirs in _golly_nbhds_inv - else get_gollyizer(tbl, self.cdirs) + if other not in self._gollyizers: + self._gollyizers[other] = ( + get_gollyizer(self, other, golly_nbhd=_golly_nbhds_inv[other.cdirs]) + if other.cdirs in _golly_nbhds_inv + else get_gollyizer(self, other) ) - return self._gollyizers[tbl.neighborhood] + return self._gollyizers[other] def supports_transformations(self, transformations): for method, *args in transformations: @@ -210,38 +194,38 @@ def find_golly_neighborhood(nbhds): raise ValueError(f'Invalid (non-Moore-subset) common neighborhood {common}') -def get_gollyizer(tbl, nbhd, *, golly_nbhd=None): - nbhd_set = set(nbhd) +def get_gollyizer(nbhd, other, *, golly_nbhd=None): + nbhd_set = set(nbhd.cdirs) if golly_nbhd is not None: golly_set = NBHD_SETS[golly_nbhd] if nbhd_set < golly_set: - return fill.__get__(ORDERED_NBHDS[golly_nbhd]) - return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[golly_nbhd], tbl, napkin) + return partial(fill, ORDERED_NBHDS[golly_nbhd], other) + return partial(reorder, ORDERED_NBHDS[golly_nbhd], other) for name, s in NBHD_SETS.items(): if nbhd_set <= s: - tbl.directives['neighborhood'] = name if nbhd_set < s: - return fill.__get__(ORDERED_NBHDS[name]) - return lambda tbl, napkin, _anys: reorder(ORDERED_NBHDS[name], tbl, napkin) + return partial(fill, ORDERED_NBHDS[name], other) + return partial(reorder, ORDERED_NBHDS[name], other) raise ValueError(f'Invalid (non-Moore-subset) neighborhood {nbhd_set}') -def reorder(ordered_nbhd, tbl, napkin): - cdir_at = tbl.neighborhood.cdir_at +def reorder(ordered_nbhd, nbhd, napkin): + cdir_at = nbhd.cdir_at d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} return [d[cdir] for cdir in ordered_nbhd] -def fill(ordered_nbhd, tbl, napkin, anys): # anys == usages of `any` - if isinstance(anys, int): - anys = set(range(anys)) - cdir_at = tbl.neighborhood.cdir_at +def fill(ordered_nbhd, nbhd, napkin): + #if isinstance(anys, int): + # anys = set(range(anys)) + #available_tags = [i for i in range(10) if i not in anys] + ## (ew, but grabbing VarName object) + #tbl.vars.inv[tbl.vars['any']].update_rep( + # max(anys) + len(ordered_nbhd) - len(tbl.neighborhood) - sum(takewhile(max(anys).__gt__, available_tags)) + # ) + #tagged_names = (f'any.{i}' for i in available_tags) + tagged_names = (f'any.{i}' for i in range(10)) + cdir_at = nbhd.cdir_at d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} - available_tags = [i for i in range(10) if i not in anys] - # (ew, but grabbing VarName object) - tbl.vars.inv[tbl.vars['any']].update_rep( - max(anys) + len(ordered_nbhd) - len(tbl.neighborhood) - sum(takewhile(max(anys).__gt__, available_tags)) - ) - tagged_names = (f'any.{i}' for i in available_tags) # `or` because this needs lazy evaluation return [d.get(cdir) or next(tagged_names) for cdir in ordered_nbhd] diff --git a/nutshell/segments/table/_symutils.py b/nutshell/segments/table/_symutils.py index b97f68d..b39645e 100644 --- a/nutshell/segments/table/_symutils.py +++ b/nutshell/segments/table/_symutils.py @@ -54,7 +54,7 @@ def __repr__(self): @classmethod def with_neighborhood(cls, nbhd): - return new_sym_type( + return cls if nbhd == cls.nbhd else new_sym_type( nbhd, cls.__name__, cls.transformation_names, @@ -62,6 +62,17 @@ def with_neighborhood(cls, nbhd): permute_hash_indices=cls.permute_hash_indices ) + @classmethod + def padded_to_neighborhood(cls, nbhd): + return cls if nbhd == cls.nbhd else new_sym_type( + nbhd, + cls.__name__ + '_Padded', + cls.transformation_names, # hm + transformations=frozenset([tuple(t[cls.nbhd[i]-1] if i in cls.nbhd else i for i in nbhd) for t in cls.transformations]), + tilde=cls.tilde, + permute_hash_indices=cls.permute_hash_indices + ) + @classmethod def compose(cls, other): if cls.nbhd != other.nbhd: @@ -153,7 +164,7 @@ def find_golly_sym_type(symmetries, nbhd): dummy = range(len(nbhd)) result = reduce( bitwise_and, - [cls(dummy).expanded for cls in symmetries] + [cls.padded_to_neighborhood(nbhd)(dummy).expanded for cls in symmetries] ) if result not in _GOLLY_NAMES: # Pretty sure this is 100% wrong for the general case. diff --git a/nutshell/segments/table/table.py b/nutshell/segments/table/table.py index 8ef2305..101feee 100644 --- a/nutshell/segments/table/table.py +++ b/nutshell/segments/table/table.py @@ -74,7 +74,7 @@ def __init__(self, tbl, start=0, *, dep: ['@NUTSHELL', '@DEFINE'] = (None, None) self.available_macros.update(_define.macros_after) self.modifiers.update(_define.modifiers) - self.specials = {'any': VarName('any'), 'live': VarName('live')} + self.specials = {'any': VarName('any', 8), 'live': VarName('live')} self.new_varname = VarName.new_generator() if not tbl: @@ -178,7 +178,7 @@ def neighborhood(self, val): if len(nbhd) != len(set(nbhd)): raise ValueError('Duplicate compass directions in neighborhood') self._nbhd = nbhoods.Neighborhood(nbhd) - self.gollyize_nbhd = self._nbhd.gollyizer_for(self) + self.gollyize_nbhd = self._nbhd.converter_to(self.neighborhood) elif val in self.NEIGHBORHOODS: self._nbhd = self.NEIGHBORHOODS[val] else: @@ -227,7 +227,7 @@ def n_states(self, value): self._n_states = self.directives['states'] = value def neighborhood_ok(self): - return sum(self.neighborhoods_used.values()) > 1 or not next(iter(self.neighborhoods_used)).is_golly_nbhd + return sum(self.neighborhoods_used.values()) == 1 and next(iter(self.neighborhoods_used)).is_golly_nbhd def use_sym_type(self, sym=None): if isinstance(sym, str): From d609a4d325679c61ecee84bdd95fa6b2db27c953 Mon Sep 17 00:00:00 2001 From: Eli Date: Wed, 30 Jan 2019 23:12:13 -0800 Subject: [PATCH 28/33] Fix neighborhood-switching --- .../AlternatingPermuteTest.rule | 15 +- examples/compiled_ruletables/BeeZero.rule | 142 +++++++++--------- examples/compiled_ruletables/Brew.rule | 133 ++++++++-------- .../compiled_ruletables/DeficientLife.rule | 34 ++--- examples/compiled_ruletables/ExtendedX.rule | 49 +++--- examples/compiled_ruletables/Simpl.rule | 1 + examples/compiled_ruletables/XHistory.rule | 63 ++++---- examples/compiled_ruletables/bct.rule | 1 + examples/compiled_ruletables/bf.rule | 1 + examples/compiled_ruletables/bml.rule | 5 + examples/compiled_ruletables/data_test.rule | 1 + examples/compiled_ruletables/newtons.rule | 1 + examples/compiled_ruletables/roed.rule | 1 + nutshell/segments/table/_neighborhoods.py | 33 +--- 14 files changed, 238 insertions(+), 242 deletions(-) diff --git a/examples/compiled_ruletables/AlternatingPermuteTest.rule b/examples/compiled_ruletables/AlternatingPermuteTest.rule index 59114e8..3de0295 100644 --- a/examples/compiled_ruletables/AlternatingPermuteTest.rule +++ b/examples/compiled_ruletables/AlternatingPermuteTest.rule @@ -54,6 +54,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var t.0 = {1} var h.0 = {2} var h.1 = h.0 @@ -65,14 +66,14 @@ var _a0.3 = _a0.0 #### symmetries: permute(N, E, S, W) permute(NE, SE, SW, NW) #### line 48: 0, h, t, any, b, any, any, any, any, h #### -0, any.0, b.0, any.1, any.2, any.3, t.0, h.0, any.4, h.1 -0, any.0, any.1, h.0, b.0, any.2, any.3, any.4, t.0, h.1 -0, any.0, b.0, h.0, t.0, any.1, any.2, any.3, any.4, h.1 -0, any.0, b.0, any.1, any.2, any.3, any.4, h.0, t.0, h.1 -0, any.0, any.1, h.0, any.2, any.3, t.0, any.4, b.0, h.1 -0, any.0, t.0, any.1, any.2, any.3, any.4, h.0, b.0, h.1 +0, any.0, t.0, h.0, b.0, any.1, any.2, any.3, any.4, h.1 +0, any.0, b.0, any.1, any.2, h.0, t.0, any.3, any.4, h.1 +0, h.0, any.0, any.1, any.2, any.3, t.0, any.4, b.0, h.1 +0, any.0, b.0, any.1, t.0, any.2, any.3, h.0, any.4, h.1 +0, any.0, any.1, any.2, b.0, h.0, any.3, any.4, t.0, h.1 +0, any.0, any.1, any.2, b.0, any.3, t.0, h.0, any.4, h.1 #### line 49: 0, h, --t, any, --t, any, --t, any, --t, h #### -0, any.0, _a0.0, any.1, _a0.1, any.2, _a0.2, h.0, _a0.3, h.1 +0, h.0, _a0.0, any.0, _a0.1, any.1, _a0.2, any.2, _a0.3, h.1 #### line 50: (h, t), any, any, any, any, any, any, any, any, [0:(t, 0)] #### 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 1 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index 9e8306b..4c78f67 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -26,109 +26,109 @@ var any.8 = any.0 #### symmetries: permute # Birth - EVEN generations #### line 46: 0, <017 !hensel / 1 / 0>; 2 #### -0, 1, 0, 0, 0, 1, 0, 0, 0, 2 0, 0, 0, 0, 1, 0, 0, 0, 1, 2 -0, 1, 0, 0, 0, 0, 0, 1, 0, 2 -0, 0, 0, 0, 0, 0, 1, 1, 0, 2 -0, 0, 0, 0, 1, 0, 0, 1, 0, 2 +0, 1, 0, 1, 0, 0, 0, 0, 0, 2 0, 0, 1, 0, 1, 0, 0, 0, 0, 2 -0, 0, 0, 1, 0, 1, 1, 0, 0, 2 +0, 1, 1, 0, 0, 0, 0, 0, 0, 2 +0, 0, 0, 0, 0, 1, 0, 0, 1, 2 +0, 1, 0, 0, 0, 1, 0, 0, 0, 2 +0, 1, 1, 0, 1, 0, 0, 0, 0, 2 +0, 0, 1, 0, 1, 0, 1, 0, 0, 2 +0, 1, 0, 1, 1, 0, 0, 0, 0, 2 0, 0, 0, 0, 1, 1, 1, 0, 0, 2 -0, 0, 1, 0, 1, 1, 0, 0, 0, 2 +0, 1, 0, 0, 1, 0, 1, 0, 0, 2 +0, 0, 0, 1, 0, 1, 0, 1, 0, 2 +0, 0, 1, 0, 0, 0, 1, 1, 0, 2 0, 0, 0, 1, 0, 0, 0, 1, 1, 2 0, 0, 0, 1, 1, 1, 0, 0, 0, 2 0, 0, 1, 0, 0, 1, 0, 1, 0, 2 -0, 0, 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1, 1, 1, 1, 0, 1, 1, 1, 1, 2 # Birth - ODD generations #### line 52: 0, <01 odd_b0 / 2 / 0>; 1 #### +0, 2, 2, 2, 2, 2, 2, 0, 2, 1 0, 2, 2, 2, 2, 2, 2, 2, 0, 1 -0, 0, 2, 2, 2, 2, 2, 2, 2, 1 # Survival - ODD generations #### line 55: 2, <017 odd_b0 / 2 / 0>; 1 #### +2, 2, 2, 2, 2, 2, 2, 0, 2, 1 2, 2, 2, 2, 2, 2, 2, 2, 0, 1 -2, 0, 2, 2, 2, 2, 2, 2, 2, 1 -2, 0, 2, 0, 0, 0, 0, 0, 0, 1 -2, 0, 0, 2, 0, 0, 0, 0, 0, 1 +2, 2, 0, 0, 0, 0, 0, 0, 0, 1 +2, 0, 0, 0, 0, 0, 2, 0, 0, 1 #### line 57: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/Brew.rule b/examples/compiled_ruletables/Brew.rule index 1bc8d7d..0479933 100644 --- a/examples/compiled_ruletables/Brew.rule +++ b/examples/compiled_ruletables/Brew.rule @@ -27,6 +27,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var _a0.0 = {0,2,3} var _a0.1 = _a0.0 var _a0.2 = _a0.0 @@ -49,86 +50,86 @@ var _c0.5 = _c0.0 #### symmetries: permute # Birth conditions #### line 18: --[FG], <3 / [live] / --[FG]>; [FG] #### -_a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, 1, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1, 1 _a0.0, _a0.1, _a0.2, _a0.3, 1, 1, 1, _a0.4, _a0.5, 1 -_a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1, 1 +_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, 1, _a0.5, 1 +_a0.0, _a0.1, _a0.2, 1, 1, _a0.3, _a0.4, _a0.5, 1, 1 _a0.0, 1, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -_a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1, 1, 1 -_a0.0, 1, _a0.1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 -_a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1 -_a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1 -_a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, _a0.5, 1 +_a0.0, 1, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +_a0.0, _a0.1, _a0.2, 1, _a0.3, 1, _a0.4, _a0.5, 1, 1 # Survival conditions #### line 20: live, <23 / [0] / --[0]>; [0] #### -1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1, 1 1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 -1, _a0.0, 1, 1, _a0.1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, _a0.5, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, _a0.5, 1 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, _a0.5, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, _a0.5, 1, 1 -1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 +1, 1, _a0.0, _a0.1, _a0.2, 1, _a0.3, _a0.4, _a0.5, 1 +1, 1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, _a0.4, 1 +1, _a0.0, 1, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1, 1, 1 1, _a0.0, _a0.1, _a0.2, 1, 1, 1, _a0.3, _a0.4, 1 -1, _a0.0, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, 1, 1 +1, 1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, 1, _a0.4, 1 +1, _a0.0, _a0.1, 1, 1, _a0.2, _a0.3, _a0.4, 1, 1 1, 1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1 -1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1, 1, 1 -1, 1, _a0.0, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, _a0.4, 1, 1 -1, 1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, _a0.4, 1 -1, _a0.0, 1, _a0.1, _a0.2, _a0.3, 1, 1, _a0.4, 1 -1, _a0.0, 1, _a0.1, 1, _a0.2, _a0.3, 1, _a0.4, 1 -_b0.0, 2, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2, _b0.5, 2 -_b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +1, 1, 1, 1, _a0.0, _a0.1, _a0.2, _a0.3, _a0.4, 1 +1, _a0.0, _a0.1, 1, _a0.2, 1, _a0.3, _a0.4, 1, 1 +_b0.0, _b0.1, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2, 2 -_b0.0, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, 2, _b0.5, 2 -_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2, 2 -_b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2, 2 -2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, _b0.5, 2 +_b0.0, _b0.1, 2, 2, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, _b0.2, 2, _b0.3, 2, _b0.4, _b0.5, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, 2, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 +_b0.0, _b0.1, _b0.2, 2, 2, _b0.3, _b0.4, 2, _b0.5, 2 +_b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2, 2, _b0.5, 2 +_b0.0, 2, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, _b0.5, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 -2, 2, 2, _b0.0, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 -2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 +2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2, 2 -2, 2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 -2, _b0.0, _b0.1, _b0.2, 2, 2, 2, _b0.3, _b0.4, 2 -2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 -2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, 2, _b0.4, 2 -2, _b0.0, _b0.1, 2, 2, 2, _b0.2, _b0.3, _b0.4, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, 2, _b0.4, 2 +2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, _b0.5, 2 +2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, _b0.5, 2 +2, _b0.0, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2, 2 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2, 2 -2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, 2, _b0.4, 2 -2, 2, _b0.0, _b0.1, 2, _b0.2, _b0.3, _b0.4, 2, 2 -2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2, 2 -_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3 +2, 2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, _b0.4, 2 +2, _b0.0, 2, 2, 2, _b0.1, _b0.2, _b0.3, _b0.4, 2 +2, 2, _b0.0, _b0.1, 2, _b0.2, 2, _b0.3, _b0.4, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, _b0.3, 2, _b0.4, 2 +2, 2, 2, _b0.0, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2 +2, _b0.0, _b0.1, 2, 2, _b0.2, _b0.3, 2, _b0.4, 2 +2, _b0.0, _b0.1, _b0.2, _b0.3, 2, 2, 2, _b0.4, 2 +2, 2, _b0.0, 2, _b0.1, _b0.2, 2, _b0.3, _b0.4, 2 +_c0.0, _c0.1, 3, _c0.2, 3, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +_c0.0, _c0.1, 3, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3 -_c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 -_c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3 -_c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, _c0.5, 3, 3 -_c0.0, 3, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 -_c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3, 3, 3 -_c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 -3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3, 3 -3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3 +_c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, _c0.5, 3 +_c0.0, _c0.1, 3, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, _c0.5, 3 +_c0.0, 3, 3, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 +_c0.0, 3, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, _c0.2, 3, 3, _c0.3, _c0.4, _c0.5, 3 +3, _c0.0, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, _c0.5, 3 +3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, _c0.5, 3 +3, _c0.0, 3, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3 +3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3, 3 +3, _c0.0, 3, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3 -3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3, 3, 3 -3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, 3, _c0.4, 3, 3 -3, 3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, _c0.4, 3 -3, _c0.0, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3, 3, 3 -3, _c0.0, 3, _c0.1, 3, _c0.2, _c0.3, 3, _c0.4, 3 +3, 3, _c0.0, _c0.1, 3, _c0.2, 3, _c0.3, _c0.4, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, _c0.3, 3, _c0.4, 3 +3, _c0.0, 3, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 +3, 3, _c0.0, _c0.1, 3, 3, _c0.2, _c0.3, _c0.4, 3 +3, 3, 3, 3, _c0.0, _c0.1, _c0.2, _c0.3, _c0.4, 3 +3, 3, _c0.0, 3, _c0.1, _c0.2, 3, _c0.3, _c0.4, 3 #### line 23: live, any; [0: (any-1) << 1] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 2, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 3 diff --git a/examples/compiled_ruletables/DeficientLife.rule b/examples/compiled_ruletables/DeficientLife.rule index 3cf6e09..4a85824 100644 --- a/examples/compiled_ruletables/DeficientLife.rule +++ b/examples/compiled_ruletables/DeficientLife.rule @@ -54,21 +54,21 @@ var _j0.2 = _j0.0 #### symmetries: rotate4reflect #### line 5: 0, 0, -2, E..S 0, -2, 0, -2; 2 #### -0, 0, _a0.0, 0, 0, 0, _a0.1, 0, _a0.2, 2 +0, 0, _a0.0, 0, _a0.1, 0, _a0.2, 0, 0, 2 #### line 6: 0, -3, 0, -3, SE..SW 0, -3, 0; 3 #### 0, _b0.0, 0, _b0.1, 0, 0, 0, _b0.2, 0, 3 #### line 7: 0, 0, 0, -4, 0, -4, 0, 0, -4; 4 #### -0, 0, _c0.0, 0, 0, _c0.1, 0, _c0.2, 0, 4 +0, _c0.0, 0, _c0.1, 0, 0, _c0.2, 0, 0, 4 #### line 8: 0, W..N -5, NE..SW 0; 5 #### -0, 0, 0, _d0.0, _d0.1, _d0.2, 0, 0, 0, 5 +0, _d0.0, 0, 0, 0, 0, 0, _d0.1, _d0.2, 5 #### line 9: 0, NW..NE -6, E..W 0; 6 #### -0, 0, 0, 0, 0, 0, _e0.0, _e0.1, _e0.2, 6 +0, 0, 0, 0, _e0.0, _e0.1, _e0.2, 0, 0, 6 #### line 10: 0, 0, -7, -7, SE..W 0, NW -7; 7 #### -0, 0, 0, 0, _f0.0, 0, _f0.1, _f0.2, 0, 7 +0, 0, 0, _f0.0, _f0.1, 0, _f0.2, 0, 0, 7 #### line 11: 0, 0, -8, 0, 0, -8, 0, 0, -8; 8 #### -0, 0, _g0.0, 0, 0, _g0.1, 0, 0, _g0.2, 8 +0, _g0.0, 0, 0, _g0.1, 0, _g0.2, 0, 0, 8 #### line 12: 0, NW..N -9, 0, 0, -9, S..W 0; 9 #### -0, _h0.0, 0, 0, _h0.1, 0, 0, 0, _h0.2, 9 +0, 0, _h0.0, 0, 0, 0, _h0.1, _h0.2, 0, 9 #### line 13: 0, NW..N -10, 0, -10, SE..W 0; 10 #### 0, 0, 0, _i0.0, 0, _i0.1, _i0.2, 0, 0, 10 #### line 14: 0, NW..N -11, NE..SE 0, -11, 0, 0; 11 #### @@ -76,19 +76,19 @@ var _j0.2 = _j0.0 # Survival #### symmetries: permute #### line 18: live, live ~ 2, 0; 1 #### -live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s2 -live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 -live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 # s2 +live.0, 0, 0, live.1, 0, 0, live.2, 0, 0, 1 +live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 +live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, 0, live.1, live.2, 0, 0, 0, 0, 0, 1 live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 -live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 #### line 19: live, live ~ 3, 0; 1 #### -live.0, 0, 0, 0, 0, live.1, 0, 0, live.2, 1 # s3 -live.0, live.1, 0, 0, 0, live.2, 0, 0, 0, 1 -live.0, 0, 0, 0, 0, 0, live.1, live.2, 0, 1 +live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 # s3 +live.0, 0, 0, live.1, 0, 0, live.2, 0, 0, 1 +live.0, 0, live.1, 0, live.2, 0, 0, 0, 0, 1 +live.0, 0, 0, live.1, 0, 0, 0, live.2, 0, 1 +live.0, 0, live.1, live.2, 0, 0, 0, 0, 0, 1 live.0, 0, live.1, 0, 0, 0, live.2, 0, 0, 1 -live.0, 0, 0, 0, live.1, 0, live.2, 0, 0, 1 -live.0, 0, 0, 0, 0, live.1, 0, live.2, 0, 1 # Death otherwise #### line 22: any, any; 0 #### any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/examples/compiled_ruletables/ExtendedX.rule b/examples/compiled_ruletables/ExtendedX.rule index 6b52a6a..f9b9874 100644 --- a/examples/compiled_ruletables/ExtendedX.rule +++ b/examples/compiled_ruletables/ExtendedX.rule @@ -26,6 +26,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var on.0 = {1,6} var on.1 = on.0 var on.2 = on.0 @@ -41,40 +42,40 @@ var death.0 = {3,4} #### symmetries: permute # Birth; CHANGE THE 3 BELOW #### line 20: 0, <3 / on / off>; 1 #### -0, on.0, on.1, off.0, off.1, off.2, off.3, on.2, off.4, 1 -0, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 -0, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -0, off.0, off.1, on.0, off.2, off.3, off.4, on.1, on.2, 1 -0, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 -0, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 -0, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 -0, on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 -0, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 +0, off.0, off.1, off.2, off.3, on.0, on.1, off.4, on.2, 1 +0, off.0, on.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +0, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 +0, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 0, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +0, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 +0, on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, 1 +0, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 +0, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +0, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 #### line 21: 0, birth ~ 1, any; 1 #### 0, any.0, any.1, any.2, birth.0, any.3, any.4, any.5, any.6, 1 -0, any.0, any.1, any.2, any.3, birth.0, any.4, any.5, any.6, 1 +0, birth.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 1 # Survival; CHANGE THE 23 BELOW #### line 24: 1, death ~ 1, any; 0 #### -1, death.0, any.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 1, any.0, death.0, any.1, any.2, any.3, any.4, any.5, any.6, 0 +1, any.0, any.1, any.2, any.3, any.4, any.5, death.0, any.6, 0 #### line 25: 1, <23 / on / off>; 1 #### -1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 1, off.0, off.1, off.2, on.0, off.3, off.4, off.5, on.1, 1 -1, off.0, off.1, on.0, off.2, on.1, off.3, off.4, off.5, 1 -1, off.0, off.1, off.2, off.3, on.0, on.1, off.4, off.5, 1 +1, off.0, off.1, off.2, off.3, on.0, off.4, on.1, off.5, 1 +1, off.0, on.0, off.1, off.2, off.3, off.4, off.5, on.1, 1 +1, off.0, off.1, off.2, on.0, on.1, off.3, off.4, off.5, 1 1, off.0, on.0, off.1, off.2, off.3, off.4, on.1, off.5, 1 -1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, off.5, 1 -1, on.0, on.1, off.0, off.1, off.2, off.3, on.2, off.4, 1 -1, off.0, on.0, on.1, on.2, off.1, off.2, off.3, off.4, 1 -1, off.0, on.0, on.1, off.1, off.2, off.3, off.4, on.2, 1 -1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, on.2, 1 -1, off.0, off.1, off.2, off.3, on.0, on.1, on.2, off.4, 1 -1, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 -1, off.0, on.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 -1, on.0, off.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 -1, off.0, on.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 +1, off.0, off.1, on.0, off.2, off.3, off.4, on.1, off.5, 1 +1, off.0, off.1, off.2, off.3, on.0, on.1, off.4, on.2, 1 +1, off.0, on.0, off.1, on.1, off.2, off.3, off.4, on.2, 1 +1, off.0, off.1, off.2, on.0, on.1, off.3, on.2, off.4, 1 +1, on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, 1 1, on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, 1 +1, on.0, off.0, on.1, off.1, off.2, off.3, on.2, off.4, 1 +1, on.0, on.1, off.0, off.1, off.2, on.2, off.3, off.4, 1 +1, on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, 1 +1, on.0, off.0, off.1, off.2, off.3, off.4, on.1, on.2, 1 +1, off.0, on.0, off.1, off.2, on.1, off.3, on.2, off.4, 1 #### line 26: 1, any; 0 #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 0 diff --git a/examples/compiled_ruletables/Simpl.rule b/examples/compiled_ruletables/Simpl.rule index 56dc1a6..e49d797 100644 --- a/examples/compiled_ruletables/Simpl.rule +++ b/examples/compiled_ruletables/Simpl.rule @@ -36,6 +36,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var on.0 = {11,12,13,14,15,16,17,18,19,20} var on.1 = on.0 var on.2 = on.0 diff --git a/examples/compiled_ruletables/XHistory.rule b/examples/compiled_ruletables/XHistory.rule index 7a1f989..056ebee 100644 --- a/examples/compiled_ruletables/XHistory.rule +++ b/examples/compiled_ruletables/XHistory.rule @@ -35,6 +35,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var off.0 = {0,2,4} var off.1 = off.0 var off.2 = off.0 @@ -63,50 +64,50 @@ var _g0.0 = {3,5} #### symmetries: permute # Birth; REPLACE THE 3 BELOW #### line 28: off, <3 / on / (off, 6)>; [0: (3, 1, ...)] #### -4, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, _b0.2, _b0.3, _b0.4, on.2, 1 +4, _b0.0, on.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, on.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 +4, _b0.0, on.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, on.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 +4, _b0.0, on.0, on.1, _b0.1, on.2, _b0.2, _b0.3, _b0.4, 3 +_e0.0, _b0.0, on.0, on.1, _b0.1, on.2, _b0.2, _b0.3, _b0.4, 1 4, _b0.0, _b0.1, _b0.2, on.0, on.1, on.2, _b0.3, _b0.4, 3 _e0.0, _b0.0, _b0.1, _b0.2, on.0, on.1, on.2, _b0.3, _b0.4, 1 -4, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, on.0, _b0.0, _b0.1, _b0.2, _b0.3, on.1, _b0.4, on.2, 1 -4, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 +4, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 +4, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 3 +_e0.0, _b0.0, _b0.1, on.0, _b0.2, on.1, _b0.3, on.2, _b0.4, 1 +4, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 3 +_e0.0, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 1 +4, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 3 +_e0.0, on.0, _b0.0, _b0.1, _b0.2, on.1, _b0.3, _b0.4, on.2, 1 4, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 3 _e0.0, _b0.0, _b0.1, on.0, on.1, on.2, _b0.2, _b0.3, _b0.4, 1 4, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 3 _e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, _b0.3, on.2, _b0.4, 1 -4, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 3 -_e0.0, _b0.0, _b0.1, _b0.2, on.0, _b0.3, on.1, _b0.4, on.2, 1 -4, on.0, _b0.0, on.1, _b0.1, on.2, _b0.2, _b0.3, _b0.4, 3 -_e0.0, on.0, _b0.0, on.1, _b0.1, on.2, _b0.2, _b0.3, _b0.4, 1 -4, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 3 -_e0.0, _b0.0, on.0, _b0.1, _b0.2, _b0.3, on.1, on.2, _b0.4, 1 -4, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 3 -_e0.0, on.0, _b0.0, _b0.1, on.1, _b0.2, on.2, _b0.3, _b0.4, 1 # Death on touching a boundary cell #### line 31: on, 6 ~ 1, (0, 6); [0: (2, 4, ...)] #### -1, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 2 -1, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 2 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 6, 4 -_g0.0, _f0.0, _f0.1, _f0.2, _f0.3, 6, _f0.4, _f0.5, _f0.6, 4 +1, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 +1, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 2 +_g0.0, _f0.0, 6, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 +_g0.0, 6, _f0.0, _f0.1, _f0.2, _f0.3, _f0.4, _f0.5, _f0.6, 4 # Survival; REPLACE THE 23 BELOW #### line 34: on, <23 / on / off>; [0] #### -on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 on.0, off.0, off.1, off.2, on.1, off.3, off.4, off.5, on.2, on.0 -on.0, off.0, off.1, on.1, off.2, on.2, off.3, off.4, off.5, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, on.2, off.4, off.5, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, off.4, on.2, off.5, on.0 +on.0, off.0, on.1, off.1, off.2, off.3, off.4, off.5, on.2, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, off.3, off.4, off.5, on.0 on.0, off.0, on.1, off.1, off.2, off.3, off.4, on.2, off.5, on.0 -on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, off.5, on.0 -on.0, on.1, on.2, off.0, off.1, off.2, off.3, on.3, off.4, on.0 -on.0, off.0, on.1, on.2, on.3, off.1, off.2, off.3, off.4, on.0 -on.0, off.0, on.1, on.2, off.1, off.2, off.3, off.4, on.3, on.0 -on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, on.3, on.0 -on.0, off.0, off.1, off.2, off.3, on.1, on.2, on.3, off.4, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, off.3, on.3, off.4, on.0 -on.0, off.0, on.1, off.1, on.2, off.2, on.3, off.3, off.4, on.0 -on.0, on.1, off.0, off.1, off.2, on.2, off.3, on.3, off.4, on.0 -on.0, off.0, on.1, off.1, off.2, on.2, on.3, off.3, off.4, on.0 +on.0, off.0, off.1, on.1, off.2, off.3, off.4, on.2, off.5, on.0 +on.0, off.0, off.1, off.2, off.3, on.1, on.2, off.4, on.3, on.0 +on.0, off.0, on.1, off.1, on.2, off.2, off.3, off.4, on.3, on.0 +on.0, off.0, off.1, off.2, on.1, on.2, off.3, on.3, off.4, on.0 +on.0, on.1, on.2, off.0, off.1, off.2, off.3, off.4, on.3, on.0 on.0, on.1, off.0, off.1, on.2, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, on.2, off.1, off.2, off.3, on.3, off.4, on.0 +on.0, on.1, on.2, off.0, off.1, off.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, off.1, off.2, on.2, on.3, off.3, off.4, on.0 +on.0, on.1, off.0, off.1, off.2, off.3, off.4, on.2, on.3, on.0 +on.0, off.0, on.1, off.1, off.2, on.2, off.3, on.3, off.4, on.0 # Death #### line 37: on, any; [0: (2, 4, ...)] #### 1, any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, 2 diff --git a/examples/compiled_ruletables/bct.rule b/examples/compiled_ruletables/bct.rule index e702f96..ad1674b 100644 --- a/examples/compiled_ruletables/bct.rule +++ b/examples/compiled_ruletables/bct.rule @@ -60,6 +60,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var data.0 = {1,2} var data.1 = data.0 var rdata.0 = {12,13} diff --git a/examples/compiled_ruletables/bf.rule b/examples/compiled_ruletables/bf.rule index 7953098..6556f93 100644 --- a/examples/compiled_ruletables/bf.rule +++ b/examples/compiled_ruletables/bf.rule @@ -158,6 +158,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var live.0 = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95} var anyPrgm.0 = {1,2,3,4,5,6,7,8} var prgm.0 = {1,2,5,6,7,8} diff --git a/examples/compiled_ruletables/bml.rule b/examples/compiled_ruletables/bml.rule index 26c8094..d404d69 100644 --- a/examples/compiled_ruletables/bml.rule +++ b/examples/compiled_ruletables/bml.rule @@ -23,6 +23,11 @@ var any.0 = {0,1,2,3,4} var any.1 = any.0 var any.2 = any.0 var any.3 = any.0 +var any.4 = any.0 +var any.5 = any.0 +var any.6 = any.0 +var any.7 = any.0 +var any.8 = any.0 var live.0 = {1,2,3,4} # A waiting car starts moving on the next tick diff --git a/examples/compiled_ruletables/data_test.rule b/examples/compiled_ruletables/data_test.rule index b956c24..f61b8ea 100644 --- a/examples/compiled_ruletables/data_test.rule +++ b/examples/compiled_ruletables/data_test.rule @@ -35,6 +35,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var live.0 = {1,2,3,4,5,6,7,8,9,10} var live.1 = live.0 var up.0 = {2,3} diff --git a/examples/compiled_ruletables/newtons.rule b/examples/compiled_ruletables/newtons.rule index 56fc3e3..646016d 100644 --- a/examples/compiled_ruletables/newtons.rule +++ b/examples/compiled_ruletables/newtons.rule @@ -26,6 +26,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var _a0.0 = {1,5} var _b0.0 = {1,3} var _c0.0 = {1,6} diff --git a/examples/compiled_ruletables/roed.rule b/examples/compiled_ruletables/roed.rule index c6c202b..5894c76 100644 --- a/examples/compiled_ruletables/roed.rule +++ b/examples/compiled_ruletables/roed.rule @@ -91,6 +91,7 @@ var any.4 = any.0 var any.5 = any.0 var any.6 = any.0 var any.7 = any.0 +var any.8 = any.0 var anyO.0 = {10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27} var anyR.0 = {32,33,34,35,36,28,29,30,31} var anyD.0 = {37,46,47,48,49,50,51,52,53} diff --git a/nutshell/segments/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py index ff2c994..ddf709a 100644 --- a/nutshell/segments/table/_neighborhoods.py +++ b/nutshell/segments/table/_neighborhoods.py @@ -195,37 +195,18 @@ def find_golly_neighborhood(nbhds): def get_gollyizer(nbhd, other, *, golly_nbhd=None): - nbhd_set = set(nbhd.cdirs) + nbhd_set = set(nbhd) if golly_nbhd is not None: golly_set = NBHD_SETS[golly_nbhd] - if nbhd_set < golly_set: - return partial(fill, ORDERED_NBHDS[golly_nbhd], other) - return partial(reorder, ORDERED_NBHDS[golly_nbhd], other) + return partial(fix, ORDERED_NBHDS[golly_nbhd], nbhd) for name, s in NBHD_SETS.items(): if nbhd_set <= s: - if nbhd_set < s: - return partial(fill, ORDERED_NBHDS[name], other) - return partial(reorder, ORDERED_NBHDS[name], other) + return partial(fix, ORDERED_NBHDS[name], nbhd) raise ValueError(f'Invalid (non-Moore-subset) neighborhood {nbhd_set}') -def reorder(ordered_nbhd, nbhd, napkin): - cdir_at = nbhd.cdir_at - d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} - return [d[cdir] for cdir in ordered_nbhd] - - -def fill(ordered_nbhd, nbhd, napkin): - #if isinstance(anys, int): - # anys = set(range(anys)) - #available_tags = [i for i in range(10) if i not in anys] - ## (ew, but grabbing VarName object) - #tbl.vars.inv[tbl.vars['any']].update_rep( - # max(anys) + len(ordered_nbhd) - len(tbl.neighborhood) - sum(takewhile(max(anys).__gt__, available_tags)) - # ) - #tagged_names = (f'any.{i}' for i in available_tags) +def fix(cdirs_to, nbhd_from, napkin): tagged_names = (f'any.{i}' for i in range(10)) - cdir_at = nbhd.cdir_at - d = {cdir_at(k): v for k, v in enumerate(napkin, 1)} - # `or` because this needs lazy evaluation - return [d.get(cdir) or next(tagged_names) for cdir in ordered_nbhd] + print(cdirs_to) + print(nbhd_from) + return [napkin[nbhd_from[i]-1] if i in nbhd_from else next(tagged_names) for i in cdirs_to] From 3601154c256a8dcef2053fab5a6f3f3375ac61b1 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 5 Feb 2019 16:11:34 -0800 Subject: [PATCH 29/33] Fix segment_types->segments in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 844f84b..6a4deb4 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def __getitem__(self, args): 'nutshell': f[ 'tools': f['icons'], 'common', - 'segment_types': f[ + 'segments': f[ 'colors', 'icons', 'nutshell', From 95fa4413cd0553a17f6c09c4a34faa590fa5ae68 Mon Sep 17 00:00:00 2001 From: Eli Date: Tue, 5 Feb 2019 19:54:35 -0800 Subject: [PATCH 30/33] Apply B08/S08 hensel-rulestring-transition fix from master --- CHANGELOG.md | 7 + examples/compiled_ruletables/BeeZero.rule | 170 +++++++++--------- nutshell/segments/table/_neighborhoods.py | 4 + .../table/inline_rulestring/default_rs.py | 35 +++- 4 files changed, 120 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19aca3b..aede42b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,13 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)'s. `__str__()` is shown with a "does not support symmetries" message - Tilde notation is no longer available for symmetries that aren't "permute all cells" +## [0.5.6] 2019-01-20 +### Fixed +- The previous version's sole change had an unintended side effect: before it, with mixed r4r and permute transitions being + default, B08 and S08 were treated as permute transitions and only processed as such. With the removal of permute, however, + these were being ignored by the r4r-transition generator (because of their not having letters). Fixed by having it address + 0 and 8 explicitly. + ## [0.5.5] - 2018-12-24 ### Changed - Permute in inline rulestrings was transpiling wrong, and it was annoying to have to `force-r4r` with Brew, so that's out -- diff --git a/examples/compiled_ruletables/BeeZero.rule b/examples/compiled_ruletables/BeeZero.rule index 4c78f67..2132922 100644 --- a/examples/compiled_ruletables/BeeZero.rule +++ b/examples/compiled_ruletables/BeeZero.rule @@ -23,112 +23,106 @@ var any.6 = any.0 var any.7 = any.0 var any.8 = any.0 -#### symmetries: permute -# Birth - EVEN generations -#### line 46: 0, <017 !hensel / 1 / 0>; 2 #### +0, 0, 1, 0, 0, 0, 0, 1, 0, 2 0, 0, 0, 0, 1, 0, 0, 0, 1, 2 -0, 1, 0, 1, 0, 0, 0, 0, 0, 2 -0, 0, 1, 0, 1, 0, 0, 0, 0, 2 -0, 1, 1, 0, 0, 0, 0, 0, 0, 2 -0, 0, 0, 0, 0, 1, 0, 0, 1, 2 +0, 0, 0, 0, 0, 1, 0, 1, 0, 2 +0, 0, 0, 0, 1, 1, 0, 0, 0, 2 +0, 0, 0, 0, 0, 0, 1, 0, 1, 2 0, 1, 0, 0, 0, 1, 0, 0, 0, 2 -0, 1, 1, 0, 1, 0, 0, 0, 0, 2 +0, 0, 1, 0, 0, 1, 1, 0, 0, 2 +0, 0, 1, 0, 0, 1, 0, 0, 1, 2 +0, 0, 1, 0, 1, 1, 0, 0, 0, 2 +0, 1, 1, 0, 0, 0, 0, 1, 0, 2 +0, 1, 1, 0, 0, 1, 0, 0, 0, 2 0, 0, 1, 0, 1, 0, 1, 0, 0, 2 -0, 1, 0, 1, 1, 0, 0, 0, 0, 2 -0, 0, 0, 0, 1, 1, 1, 0, 0, 2 -0, 1, 0, 0, 1, 0, 1, 0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, 1, 1, 0, 1, 1, 2 +1, 1, 1, 0, 1, 0, 1, 1, 1, 2 1, 1, 1, 1, 1, 1, 1, 0, 0, 2 -1, 1, 1, 1, 1, 0, 1, 1, 0, 2 +1, 1, 1, 1, 1, 1, 0, 1, 0, 2 1, 1, 1, 0, 1, 1, 1, 0, 1, 2 -1, 1, 1, 0, 1, 1, 1, 1, 1, 2 -1, 1, 1, 1, 0, 1, 1, 1, 1, 2 -# Birth - ODD generations -#### line 52: 0, <01 odd_b0 / 2 / 0>; 1 #### -0, 2, 2, 2, 2, 2, 2, 0, 2, 1 -0, 2, 2, 2, 2, 2, 2, 2, 0, 1 -# Survival - ODD generations -#### line 55: 2, <017 odd_b0 / 2 / 0>; 1 #### -2, 2, 2, 2, 2, 2, 2, 0, 2, 1 -2, 2, 2, 2, 2, 2, 2, 2, 0, 1 -2, 2, 0, 0, 0, 0, 0, 0, 0, 1 -2, 0, 0, 0, 0, 0, 2, 0, 0, 1 -#### line 57: any, any; 0 #### +1, 1, 1, 1, 1, 1, 0, 1, 1, 2 +1, 0, 1, 1, 1, 1, 1, 1, 1, 2 +1, 1, 1, 1, 1, 1, 1, 1, 1, 2 +0, 2, 2, 2, 2, 2, 0, 2, 2, 1 +0, 0, 2, 2, 2, 2, 2, 2, 2, 1 +0, 2, 2, 2, 2, 2, 2, 2, 2, 1 +2, 2, 2, 2, 2, 2, 0, 2, 2, 1 +2, 0, 2, 2, 2, 2, 2, 2, 2, 1 +2, 0, 0, 0, 0, 0, 0, 0, 2, 1 +2, 0, 0, 0, 0, 0, 0, 2, 0, 1 +2, 2, 2, 2, 2, 2, 2, 2, 2, 1 any.0, any.1, any.2, any.3, any.4, any.5, any.6, any.7, any.8, 0 diff --git a/nutshell/segments/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py index ddf709a..c8f857f 100644 --- a/nutshell/segments/table/_neighborhoods.py +++ b/nutshell/segments/table/_neighborhoods.py @@ -49,6 +49,10 @@ def _inv(self): def idxes(self): return {v: k for k, v in self._inv.items()} + @LazyProperty + def numbers(self): + return self.idxes.values() + @LazyProperty def is_golly_nbhd(self): return self.cdirs in self.__class__.GOLLY_NBHDS.inv diff --git a/nutshell/segments/table/inline_rulestring/default_rs.py b/nutshell/segments/table/inline_rulestring/default_rs.py index 2eadb6b..95a5204 100644 --- a/nutshell/segments/table/inline_rulestring/default_rs.py +++ b/nutshell/segments/table/inline_rulestring/default_rs.py @@ -27,24 +27,43 @@ def standard(meta, initial, fg, bg, resultant, rulestring, variables, table): get_fg, get_bg = _get_getter(table, fg, 'FG'), _get_getter(table, bg, 'BG') get_initial, get_resultant = _get_getter(table, initial, None), _get_getter(table, resultant, None) counter = count(1) - ret = [ + ret = [] + if '0' in r4r_nbhds: + ret.append(TransitionGroup( + table, + get_initial('0', None, meta), + dict.fromkeys(table.neighborhood.numbers, get_bg('0', None, meta)), + get_resultant('0', None, meta), + context=meta, extra=next(counter), + symmetries=r4r + )) + ret += [ TransitionGroup( - table, - get_initial(nb_count, letter, meta), - { + table, + get_initial(nb_count, letter, meta), + { num: get_fg(nb_count, letter, meta) # XXX: probably suboptimal performance b/c [dot attr access] -> [getitem] -> [getitem] if cdir in hensel.R4R_NBHDS[nb_count][letter] else get_bg(nb_count, letter, meta) for cdir, num in table.neighborhood.items() - }, - get_resultant(nb_count, letter, meta), - context=meta, extra=next(counter), - symmetries=r4r + }, + get_resultant(nb_count, letter, meta), + context=meta, extra=next(counter), + symmetries=r4r ) for nb_count, letters in r4r_nbhds.items() for letter in letters ] + if '8' in r4r_nbhds: + ret.append(TransitionGroup( + table, + get_initial('8', None, meta), + dict.fromkeys(table.neighborhood.numbers, get_fg('8', None, meta)), + get_resultant('8', None, meta), + context=meta, extra=next(counter), + symmetries=r4r + )) return ret From 2566ce95da5bdc20f810ab4b1f29fc8d6cd7f8c5 Mon Sep 17 00:00:00 2001 From: hadi tarhini Date: Thu, 7 Feb 2019 06:21:50 -0800 Subject: [PATCH 31/33] Declare "define" segment in setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 6a4deb4..2167d3e 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ def __getitem__(self, args): 'common', 'segments': f[ 'colors', + 'define', 'icons', 'nutshell', 'table': f['lark_assets', 'inline_rulestring'] From 6c6b490edc4613de65325d8d3336734f79b2afe6 Mon Sep 17 00:00:00 2001 From: Eli Date: Thu, 14 Feb 2019 00:29:15 -0800 Subject: [PATCH 32/33] Remove debug prints --- CHANGELOG.md | 5 ++++- nutshell/segments/table/_neighborhoods.py | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aede42b..668d1b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,6 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)'s. ## [0.6.0] - In progress ### Planned -- Neighborhood-switching, a la symmetry-switching - More modifiers, e.g. Langton's Ant and Deficient/genext -- also hex - Extensions to macros and inline-rulestring modifiers: - Macros that do their thing before statelists are re-resolved into names (to allow a macro to add new statelists) @@ -14,6 +13,10 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)'s. of a Nutshell (rather than needing to be in their own, separate file, which means that when I distribute a rule I either have to share the extra file along with it or I have to add the macro/modifier to the stdlib) - A `prune` macro +### Added +- Neighborhood-switching, a la symmetry-switching + - I am not convinced that this isn't buggy as of yet + ### Changed - Completely overhauled symmetries and neighborhoods such that: - Transformations like reflection and rotation are handled from the *neighborhood* rather than the symmetry type diff --git a/nutshell/segments/table/_neighborhoods.py b/nutshell/segments/table/_neighborhoods.py index c8f857f..75f5c0a 100644 --- a/nutshell/segments/table/_neighborhoods.py +++ b/nutshell/segments/table/_neighborhoods.py @@ -211,6 +211,4 @@ def get_gollyizer(nbhd, other, *, golly_nbhd=None): def fix(cdirs_to, nbhd_from, napkin): tagged_names = (f'any.{i}' for i in range(10)) - print(cdirs_to) - print(nbhd_from) return [napkin[nbhd_from[i]-1] if i in nbhd_from else next(tagged_names) for i in cdirs_to] From 04c26d1300f792034e2371c99724ce202ef16319 Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 17 Mar 2019 13:38:45 -0700 Subject: [PATCH 33/33] Convert, not pad, nbhd when switching symmetries. Seems to help? --- nutshell/segments/table/_symutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nutshell/segments/table/_symutils.py b/nutshell/segments/table/_symutils.py index b39645e..c81f2d6 100644 --- a/nutshell/segments/table/_symutils.py +++ b/nutshell/segments/table/_symutils.py @@ -164,7 +164,7 @@ def find_golly_sym_type(symmetries, nbhd): dummy = range(len(nbhd)) result = reduce( bitwise_and, - [cls.padded_to_neighborhood(nbhd)(dummy).expanded for cls in symmetries] + [cls.with_neighborhood(nbhd)(dummy).expanded for cls in symmetries] ) if result not in _GOLLY_NAMES: # Pretty sure this is 100% wrong for the general case.