changed project structure

This commit is contained in:
Richard Feistenauer 2019-02-17 11:11:27 +01:00
parent 1b177ff686
commit acaeda970f
23 changed files with 37 additions and 23 deletions

3
.gitignore vendored
View File

@ -3,4 +3,5 @@
__pycache__ __pycache__
.coverage .coverage
htmlcov/ htmlcov/
*.orig *.orig
performance.txt

0
LICENSE.txt Normal file
View File

1
MANIFEST.in Normal file
View File

@ -0,0 +1 @@
recursive-include cellular_automaton/examples *

0
README.md Normal file
View File

1
__init__.py Normal file
View File

@ -0,0 +1 @@
from .cellular_automaton import *

View File

@ -0,0 +1,6 @@
from .cell_state import *
from .neighborhood import *
from .rule import *
from .factory import *
from .automaton import *
from .display import *

View File

@ -1,4 +1,4 @@
from cellular_automaton.ca_cell_state import CellState from .cell_state import CellState
from typing import Type from typing import Type

View File

@ -1,4 +1,4 @@
from cellular_automaton.ca_rule import Rule from cellular_automaton.cellular_automaton import Rule
from typing import Type from typing import Type

View File

@ -7,8 +7,7 @@ import pstats
from pympler import asizeof from pympler import asizeof
from cellular_automaton.ca_state import CellularAutomatonState from . import CellularAutomatonState, CellularAutomatonProcessor
from cellular_automaton.cellular_automaton import CellularAutomatonProcessor
class _DisplayInfo: class _DisplayInfo:

View File

@ -1,4 +1,6 @@
from cellular_automaton import * from . import Neighborhood, CellState, Rule
from ._cell import Cell
from ._state import CellularAutomatonState
from typing import Type from typing import Type
import itertools import itertools

View File

@ -11,7 +11,7 @@ class Rule:
""" Calculates and sets new state of 'cell'. """ Calculates and sets new state of 'cell'.
:param last_cell_state: The cells current state to calculate new state for. :param last_cell_state: The cells current state to calculate new state for.
:param neighbors_last_states: The cells neighbors current states. :param neighbors_last_states: The cells neighbors current states.
:return: True if state changed, False if not. :return: New state.
A cells evolution will only be called if it or at least one of its neighbors has changed last evolution_step cycle. A cells evolution will only be called if it or at least one of its neighbors has changed last evolution_step cycle.
""" """
return False return last_cell_state

View File

@ -1,8 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import random import random
from cellular_automaton.ca_rule import Rule from cellular_automaton import *
from cellular_automaton.ca_cell_state import CellState, SynchronousCellState
class TestRule(Rule): class TestRule(Rule):
@ -29,7 +28,6 @@ class MyState(CellState):
if __name__ == "__main__": if __name__ == "__main__":
from cellular_automaton import *
# best single is 400/400 with 0,2 ca speed and 0,09 redraw / multi is 300/300 with 0.083 # best single is 400/400 with 0,2 ca speed and 0,09 redraw / multi is 300/300 with 0.083
neighborhood = MooreNeighborhood(EdgeRule.FIRST_AND_LAST_CELL_OF_DIMENSION_ARE_NEIGHBORS) neighborhood = MooreNeighborhood(EdgeRule.FIRST_AND_LAST_CELL_OF_DIMENSION_ARE_NEIGHBORS)
ca = CAFactory.make_cellular_automaton(dimension=[100, 100], ca = CAFactory.make_cellular_automaton(dimension=[100, 100],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

14
setup.py Normal file
View File

@ -0,0 +1,14 @@
from distutils.core import setup
setup(
name="cellular_automaton",
version="0.1.0",
author="Richard Feistenauer",
author_email="r.feistenauer@web.de",
packages=["cellular_automaton"],
url="https://gitlab.com/DamKoVosh/cellular_automaton",
license="LICENSE.txt",
description="N dimensional cellular automaton implementation with multi processing capability.",
long_description="README.md",
requires=["pygame"]
)

View File

@ -1,8 +0,0 @@
from .ca_cell import *
from .ca_cell_state import *
from .ca_display import *
from .ca_neighborhood import *
from .ca_rule import *
from .ca_state import *
from .cellular_automaton import *
from .ca_factory import *

View File

@ -1,7 +1,7 @@
import sys import sys
sys.path.append('../src') sys.path.append('../src')
from cellular_automaton import * from cellular_automaton.cellular_automaton import *
import unittest import unittest

View File

@ -1,7 +1,7 @@
import sys import sys
sys.path.append('../src') sys.path.append('../src')
import cellular_automaton.ca_cell_state as cs from cellular_automaton import cellular_automaton as cs
import unittest import unittest

View File

@ -1,7 +1,7 @@
import sys import sys
sys.path.append('../src') sys.path.append('../src')
from cellular_automaton import * from cellular_automaton.cellular_automaton import *
import unittest import unittest
import mock import mock

View File

@ -1,7 +1,7 @@
import sys import sys
sys.path.append('../src') sys.path.append('../src')
import cellular_automaton.ca_neighborhood as csn from cellular_automaton import cellular_automaton as csn
import unittest import unittest