From dc3903b2a66adcc08de6b27b2618ad46e90dda6a Mon Sep 17 00:00:00 2001 From: rfeistenauer Date: Fri, 23 Oct 2020 10:33:09 +0200 Subject: [PATCH] Fixes init cell called to often --- cellular_automaton/automaton.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cellular_automaton/automaton.py b/cellular_automaton/automaton.py index 2bc8eac..83eb6e6 100644 --- a/cellular_automaton/automaton.py +++ b/cellular_automaton/automaton.py @@ -54,8 +54,9 @@ class CellularAutomatonCreator(abc.ABC): def __make_cells(self): for coord in itertools.product(*[range(d) for d in self._dimension]): - self._current_state[coord] = CELL(self.init_cell_state(coord)) - self._next_state[coord] = CELL(self.init_cell_state(coord)) + cell_state = self.init_cell_state(coord) + self._current_state[coord] = CELL(cell_state) + self._next_state[coord] = CELL(cell_state) def __add_neighbors(self): calculate_neighbor_coordinates = self._neighborhood.calculate_cell_neighbor_coordinates