def store_firing_neuron(self, neuron):
# Called from Neuron.update_dist(), i.e., whenever COMP or LCOMP is updated
# Call from Neuron.broadcast()
# Called by individual neurons whenever they fire
log.trace("CM1KEmulator.store_firing_neuron()")
# NOTE: firing_neurons won't be sorted until all neurons are added (see update_all_neuron_dists())
# Only store a firing neuron if its dist-and-cat combination is unique (CM1K Hardware Manual, p. 17)
unique = True
for neuron2 in self.firing_neurons:
if neuron2.dist == neuron.dist and neuron2.cat == neuron.cat:
unique = False
break
if unique:
# self.firing_neurons.append(neuron)
insert_pos = len(self.firing_neurons)
for i, neuron2 in enumerate(self.firing_neurons):
if neuron2.dist <= neuron.dist: # This must be <=, not <, so that earlier neurons win, ala CM1K spec
insert_pos = i
break
self.firing_neurons.insert(insert_pos, neuron)
评论列表
文章目录