# Path: antitile/off.py
# def readline_comment(file, symbol='#'):
# def load_off(file):
# def write_off(vertices, faces, facecolors=None, edges=None, edgecolors=None,
#               verts=None, vertexcolors=None):
# 
# Path: antitile/tiling.py
# class Tiling:
#     def __init__(self, vertices, faces):
#     def edges(self):
#     def face_size(self):
#     def faces_by_size(self):
#     def face_normals(self):
#     def true_faces(self):
#     def faces_by_edge(self, edges):
#     def vertex_adjacency(self):
#     def face_adjacency(self):
#     def face_vertex_incidence(self):
#     def vertex_f_adjacency(self):
#     def face_v_adjacency(self):
#     def normalize_faces(self):
#     def id_dupe_faces(self, face_group=None, oriented=False):
# def edges_from_facelist(faces):
# def orient_face(face, edge):
# def energy(xyz, exponent=1, over=None):
# def center_of_gravity(xyz):
# def bentness(xyz, poly):
# def edge_length(xyz, edges, spherical=False):
# def face_area(xyz, poly, spherical=False):
# def aspect_ratio(xyz, poly, spherical=False):


import argparse
import warnings
import numpy as np
from sys import stdin
from scipy import sparse
from antitile import off, tiling
share an edge (von Neumann neighborhood). With this option, faces
are adjacent if they share a vertex (Moore neighborhood)."""

def main():
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument("filename", nargs='?',
                        help="Input file. Reads from stdin if not given.")
    parser.add_argument("-n", help="Number of steps", default=100, type=int)
    parser.add_argument("-b", help="Birth rule, comma-separated",
                        default=[1, 5, 6], type=ruleparse)
    parser.add_argument("-s", help="Survival rule, comma-separated",
                        default=[1, 2], type=ruleparse)
    parser.add_argument("-l", help="Lookback", type=int, default=12)
    parser.add_argument("-v", help=NEIGHBOR, action='store_true')
    parser.add_argument("-d", action='store_true', help="Color the vertices "
                        "as if the cellular automata were operating on "
                        "the dual polyhedron/tiling")
    parser.add_argument("-o", help="Output prefix.", default="cellular")
    args = parser.parse_args()
    file = open(args.filename) if args.filename else stdin
    with file as f:
        vertices, faces, fc, e, ec, verts, vc = off.load_off(f)
    init = vc if args.d else fc
    if init is None or np.ptp(init) == 0:
        init = np.random.randint(2, size=len(faces))
    init = np.asarray(init)
    if len(init.shape) > 1:
        raise ValueError("Need color indexes, not color values")
    elif np.any(init > 1):
        init = init > (init.max()+init.min())/2

# Path: antitile/off.py
# def readline_comment(file, symbol='#'):
# def load_off(file):
# def write_off(vertices, faces, facecolors=None, edges=None, edgecolors=None,
#               verts=None, vertexcolors=None):
# 
# Path: antitile/tiling.py
# class Tiling:
#     def __init__(self, vertices, faces):
#     def edges(self):
#     def face_size(self):
#     def faces_by_size(self):
#     def face_normals(self):
#     def true_faces(self):
#     def faces_by_edge(self, edges):
#     def vertex_adjacency(self):
#     def face_adjacency(self):
#     def face_vertex_incidence(self):
#     def vertex_f_adjacency(self):
#     def face_v_adjacency(self):
#     def normalize_faces(self):
#     def id_dupe_faces(self, face_group=None, oriented=False):
# def edges_from_facelist(faces):
# def orient_face(face, edge):
# def energy(xyz, exponent=1, over=None):
# def center_of_gravity(xyz):
# def bentness(xyz, poly):
# def edge_length(xyz, edges, spherical=False):
# def face_area(xyz, poly, spherical=False):
# def aspect_ratio(xyz, poly, spherical=False):


# Path: bin/cellular.py
import argparse
import warnings
import numpy as np
from sys import stdin
from scipy import sparse
from antitile import off, tiling

share an edge (von Neumann neighborhood). With this option, faces
are adjacent if they share a vertex (Moore neighborhood)."""

def main():
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument("filename", nargs='?',
                        help="Input file. Reads from stdin if not given.")
    parser.add_argument("-n", help="Number of steps", default=100, type=int)
    parser.add_argument("-b", help="Birth rule, comma-separated",
                        default=[1, 5, 6], type=ruleparse)
    parser.add_argument("-s", help="Survival rule, comma-separated",
                        default=[1, 2], type=ruleparse)
    parser.add_argument("-l", help="Lookback", type=int, default=12)
    parser.add_argument("-v", help=NEIGHBOR, action='store_true')
    parser.add_argument("-d", action='store_true', help="Color the vertices "
                        "as if the cellular automata were operating on "
                        "the dual polyhedron/tiling")
    parser.add_argument("-o", help="Output prefix.", default="cellular")
    args = parser.parse_args()
    file = open(args.filename) if args.filename else stdin
    with file as f:
        vertices, faces, fc, e, ec, verts, vc = off.load_off(f)
    init = vc if args.d else fc
    if init is None or np.ptp(init) == 0:
        init = np.random.randint(2, size=len(faces))
    init = np.asarray(init)
    if len(init.shape) > 1:
        raise ValueError("Need color indexes, not color values")
    elif np.any(init > 1):
        init = init > (init.max()+init.min())/2

    poly = tiling.Tiling(vertices, faces)