Add init state argument
This commit is contained in:
parent
1903bed60e
commit
7a5b7eae6e
@ -37,11 +37,13 @@ class CellularAutomatonCreator(abc.ABC):
|
||||
def __init__(self,
|
||||
dimension,
|
||||
neighborhood: Neighborhood,
|
||||
init,
|
||||
*args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._dimension = dimension
|
||||
self._neighborhood = neighborhood
|
||||
|
||||
self.init = init
|
||||
|
||||
self._current_state = {}
|
||||
self._next_state = {}
|
||||
self.__make_cellular_automaton_state()
|
||||
@ -229,15 +231,16 @@ class Neuropercolation(CellularAutomatonCreator, abc.ABC):
|
||||
|
||||
class NeuropercolationCoupled(CellularAutomatonCreator, abc.ABC):
|
||||
|
||||
def __init__(self, dim, eps, coupling=[], *args, **kwargs):
|
||||
def __init__(self, dim, eps, coupling=[], init=[[0,0],[0,0]], *args, **kwargs):
|
||||
super().__init__(dimension=[dim, dim, 2, 2],
|
||||
init=init,
|
||||
neighborhood=VonNeumannNeighborhood(EdgeRule.FIRST_AND_LAST_CELL_OF_DIMENSION_ARE_NEIGHBORS))
|
||||
self._evolution_step = 0
|
||||
self.epsilon = eps
|
||||
self.coupling = coupling
|
||||
|
||||
def init_cell_state(self, coord): # pylint: disable=no-self-use
|
||||
return DEAD
|
||||
return [self.init[coord[3]][coord[2]]]
|
||||
|
||||
def get_cells(self):
|
||||
return self._current_state
|
||||
|
@ -70,6 +70,7 @@ class Simulate1Layer:
|
||||
def __init__(self,
|
||||
dim,
|
||||
eps,
|
||||
init=0,
|
||||
steps=100,
|
||||
draw='pygame',
|
||||
res=4,
|
||||
@ -88,7 +89,7 @@ class Simulate1Layer:
|
||||
:param state_to_color_cb: A callback to define the draw color of CA states (default: red for states != 0)
|
||||
"""
|
||||
super().__init__(*args, **kwargs)
|
||||
self._cellular_automaton = Neurolattice(dim,eps)
|
||||
self._cellular_automaton = Neurolattice(dim,eps,init=init)
|
||||
self.__active = True
|
||||
self.__cell_size = [res,res]
|
||||
self.__dimension = dim
|
||||
@ -239,6 +240,7 @@ class Simulate2Layers:
|
||||
def __init__(self,
|
||||
dim,
|
||||
eps,
|
||||
init=[0,0],
|
||||
steps=100,
|
||||
draw='pygame',
|
||||
res=4,
|
||||
@ -257,7 +259,7 @@ class Simulate2Layers:
|
||||
:param state_to_color_cb: A callback to define the draw color of CA states (default: red for states != 0)
|
||||
"""
|
||||
super().__init__(*args, **kwargs)
|
||||
self._cellular_automaton = Neuropercolation(dim,eps)
|
||||
self._cellular_automaton = Neuropercolation(dim,eps,init=init)
|
||||
self.__active = True
|
||||
self.__cell_size = [res,res]
|
||||
self.__dimension = dim
|
||||
@ -422,6 +424,7 @@ class Simulate4Layers:
|
||||
dim,
|
||||
eps,
|
||||
coupling=[],
|
||||
init=[[0,0],[0,0]],
|
||||
steps=100,
|
||||
draw='pygame',
|
||||
res=4,
|
||||
@ -440,7 +443,7 @@ class Simulate4Layers:
|
||||
:param state_to_color_cb: A callback to define the draw color of CA states (default: red for states != 0)
|
||||
"""
|
||||
super().__init__(*args, **kwargs)
|
||||
self._cellular_automaton = NeuropercolationCoupled(dim,eps,coupling)
|
||||
self._cellular_automaton = NeuropercolationCoupled(dim,eps,coupling,init)
|
||||
self.__active = True
|
||||
self.__cell_size = [res,res]
|
||||
self.__dimension = dim
|
||||
|
Loading…
Reference in New Issue
Block a user