Add count_channels function to count open channels
This commit is contained in:
parent
2db3088530
commit
cd0a17385f
@ -221,6 +221,12 @@ class Neuropercolation(CellularAutomatonCreator, abc.ABC):
|
|||||||
new_cell_state = ALIVE
|
new_cell_state = ALIVE
|
||||||
return new_cell_state
|
return new_cell_state
|
||||||
|
|
||||||
|
def count_channels(self):
|
||||||
|
open_channels = [0,0]
|
||||||
|
for coord, old in zip(self._current_state.keys(), self._current_state.values()):
|
||||||
|
open_channels[coord[2]] += 1 if sum([n.state[0] for n in old.neighbors])==2 else 0
|
||||||
|
return open_channels
|
||||||
|
|
||||||
class NeuropercolationCoupled(CellularAutomatonCreator, abc.ABC):
|
class NeuropercolationCoupled(CellularAutomatonCreator, abc.ABC):
|
||||||
|
|
||||||
def __init__(self, dim, eps, coupling=[], *args, **kwargs):
|
def __init__(self, dim, eps, coupling=[], *args, **kwargs):
|
||||||
@ -299,3 +305,10 @@ class NeuropercolationCoupled(CellularAutomatonCreator, abc.ABC):
|
|||||||
else:
|
else:
|
||||||
new_cell_state = ALIVE
|
new_cell_state = ALIVE
|
||||||
return new_cell_state
|
return new_cell_state
|
||||||
|
|
||||||
|
def count_channels(self):
|
||||||
|
open_channels = [[0,0],[0,0]]
|
||||||
|
for coord, old in zip(self._current_state.keys(), self._current_state.values()):
|
||||||
|
open_channels[coord[3]][coord[2]] += 1 if sum([n.state[0] for n in old.neighbors])==2 and coord[:2] in self.coupling else 0
|
||||||
|
return open_channels
|
||||||
|
|
Loading…
Reference in New Issue
Block a user