2018-12-01 19:37:18 +00:00
|
|
|
class Cell:
|
2018-12-02 16:45:08 +00:00
|
|
|
def __init__(self, name: str, coordinate: list):
|
2018-12-01 19:37:18 +00:00
|
|
|
self.name = name
|
2018-12-02 16:45:08 +00:00
|
|
|
self.coordinate = coordinate
|
2018-12-01 19:37:18 +00:00
|
|
|
self.neighbours = []
|
2018-12-02 16:45:08 +00:00
|
|
|
self._status = [None, None]
|
2018-12-08 16:45:06 +00:00
|
|
|
self._dirty = False
|
2018-12-01 14:14:22 +00:00
|
|
|
|
2018-12-01 19:37:18 +00:00
|
|
|
def set_neighbours(self, neighbours: list):
|
2018-12-08 21:33:13 +00:00
|
|
|
""" Set new cells as neighbour of this cell.
|
|
|
|
:param neighbours: A List of Cell names.
|
|
|
|
"""
|
2018-12-01 19:37:18 +00:00
|
|
|
self.neighbours = neighbours
|
2018-12-02 16:45:08 +00:00
|
|
|
|
2018-12-08 21:33:13 +00:00
|
|
|
def is_set_for_redrawing(self):
|
2018-12-08 16:45:06 +00:00
|
|
|
return self._dirty
|
|
|
|
|
2018-12-08 21:33:13 +00:00
|
|
|
def set_for_redraw(self):
|
2018-12-08 16:45:06 +00:00
|
|
|
self._dirty = True
|
|
|
|
|
2018-12-08 21:33:13 +00:00
|
|
|
def release_from_redraw(self):
|
2018-12-08 16:45:06 +00:00
|
|
|
self._dirty = False
|
|
|
|
|
2018-12-08 21:33:13 +00:00
|
|
|
def set_status_of_iteration(self, new_status, iteration):
|
|
|
|
""" Will set the new status for the iteration modulo two.
|
2018-12-02 16:45:08 +00:00
|
|
|
:param new_status: The new status to set.
|
|
|
|
:param iteration: Uses the iteration index, to differ between current and next state.
|
2018-12-08 16:45:06 +00:00
|
|
|
:return True if status has changed.
|
2018-12-02 16:45:08 +00:00
|
|
|
"""
|
|
|
|
self._status[iteration % 2] = new_status
|
|
|
|
|
2018-12-08 16:45:06 +00:00
|
|
|
return self._status[0] != self._status[1]
|
2018-12-02 16:45:08 +00:00
|
|
|
|
2018-12-08 21:33:13 +00:00
|
|
|
def get_status_of_iteration(self, iteration):
|
|
|
|
""" Will return the status for the iteration modulo two.
|
2018-12-02 16:45:08 +00:00
|
|
|
:param iteration: Uses the iteration index, to differ between current and next state.
|
|
|
|
:return The status for this iteration.
|
|
|
|
"""
|
|
|
|
return self._status[iteration % 2]
|