From de6b1d9f442bf1095763641f57be035b2d1880f0 Mon Sep 17 00:00:00 2001 From: Tom Weber Date: Tue, 15 Nov 2022 19:18:31 +0100 Subject: [PATCH] use bernoulli distribution for random start --- conway/__init__.py | 0 anime.py => conway/anime.py | 0 main.py => conway/gameoflife.py | 11 +++++++---- setup.py | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 conway/__init__.py rename anime.py => conway/anime.py (100%) rename main.py => conway/gameoflife.py (91%) create mode 100644 setup.py diff --git a/conway/__init__.py b/conway/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/anime.py b/conway/anime.py similarity index 100% rename from anime.py rename to conway/anime.py diff --git a/main.py b/conway/gameoflife.py similarity index 91% rename from main.py rename to conway/gameoflife.py index 5951bae..9a9114f 100644 --- a/main.py +++ b/conway/gameoflife.py @@ -3,12 +3,12 @@ import copy import matplotlib.pyplot as plt import numpy as np -from anime import PltAnimation -from anime import PlotlyAnimation +from conway.anime import PltAnimation +from conway.anime import PlotlyAnimation class State(object): - def __init__(self, depth: int, width: int, coords=None): + def __init__(self, depth: int = 100, width: int = 100, coords=None): # Coords: tuple of ints or list of tuple of ints self.width = width self.depth = depth @@ -90,7 +90,10 @@ class State(object): alive += 1 return alive - +def get_anime(size=100, steps=100, start="random"): + state = State(size, size, start) + anime = PlotlyAnimation(state, steps) + return anime.animation def main(): diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d7d296a --- /dev/null +++ b/setup.py @@ -0,0 +1,19 @@ +from setuptools import setup + +setup( + name='conway', + version='0.1.0', + description="A conway's game of life implementation", + url='https://git.weber.codes/tom/conwaysgameoflife', + author='Tom Weber', + author_email='mail@weber.codes', + license='BSD 2-clause', + packages=['conway'], + install_requires=['wheel', + 'numpy', + 'pandas', + 'matplotlib', + 'plotly' + ], + +)