From b0a8fb05a404dbf143c2d60ab54d30f7c117a019 Mon Sep 17 00:00:00 2001 From: Richard Feistenauer Date: Sat, 9 Feb 2019 19:06:18 +0100 Subject: [PATCH] fixed tests and refactored cellstate --- performance.txt | 5 ++- scripts/main_ui.py | 2 +- scripts/performance_test | Bin 3861 -> 3861 bytes src/cellular_automaton/ca_cell.py | 38 +++++++------------ src/cellular_automaton/ca_cell_state.py | 21 +++++----- src/cellular_automaton/ca_display.py | 8 ++-- src/cellular_automaton/ca_factory.py | 4 +- src/cellular_automaton/cellular_automaton.py | 7 ++-- test/test_cell.py | 15 ++++---- 9 files changed, 46 insertions(+), 54 deletions(-) diff --git a/performance.txt b/performance.txt index c9fec8b..7726429 100644 --- a/performance.txt +++ b/performance.txt @@ -14,4 +14,7 @@ TOTAL TIME: 0.1792s # probably wrong calculated (asizeof was in there) SIZE: 20.2575MB # Factory instead of grid TOTAL TIME: 0.1152s # dict instead of list for cells -SIZE: 20.2575MB # process size 53 / 75,8 \ No newline at end of file +SIZE: 20.2575MB # process size 53 / 75,8 + +TOTAL TIME: 0.1135s # evolve is static +SIZE: 20.2575MB # process size 50.8 / 76 (no more cell objects in processes) \ No newline at end of file diff --git a/scripts/main_ui.py b/scripts/main_ui.py index a01e5cc..8b7f345 100644 --- a/scripts/main_ui.py +++ b/scripts/main_ui.py @@ -48,7 +48,7 @@ if __name__ == "__main__": freeze_support() random.seed(1000) - # best is 400/400 with 0,2 ca speed and 0,09 redraw + # 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) ca = make_cellular_automaton(dimension=[100, 100], neighborhood=neighborhood, rule=TestRule(), state_class=MyState) ca_window = PyGameFor2D(window_size=[1000, 800], cellular_automaton=ca) diff --git a/scripts/performance_test b/scripts/performance_test index 112495e103f620ce1aa9a7d2fc78540540b2e869..6b88c5966074883b6715e97601db6b7bcdfcfd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