Add count_channels function to count open channels
This commit is contained in:
parent
2db3088530
commit
cd0a17385f
@ -194,7 +194,7 @@ class Neuropercolation(CellularAutomatonCreator, abc.ABC):
|
|||||||
new_state = evolution_rule(old.state.copy(), old_c.state.copy(), [n.state[0] for n in old.neighbors], coord[2], coord_c[2]) #inverse the inhibitory layer's action
|
new_state = evolution_rule(old.state.copy(), old_c.state.copy(), [n.state[0] for n in old.neighbors], coord[2], coord_c[2]) #inverse the inhibitory layer's action
|
||||||
|
|
||||||
evolve_cell(old, new, new_state)
|
evolve_cell(old, new, new_state)
|
||||||
|
|
||||||
def __evolve_cell(self, old, cell, new_state):
|
def __evolve_cell(self, old, cell, new_state):
|
||||||
changed = new_state != old.state
|
changed = new_state != old.state
|
||||||
cell.state = new_state
|
cell.state = new_state
|
||||||
@ -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