All pastes #107219 Raw Edit

Mine

public text v1 · immutable
#107219 ·published 2006-07-30 22:13 UTC
rendered paste body
class neuron:
	def __init__(self, threshhold ):
		self.output = None #the node to output to
		self.threshhold = threshhold #threshhold
		
		self.w = [] #inputs
		
		self.active = 0 #0 means not active
		
	def setOutput(self, neuron, weight):
		self.output = neuron
		self.output.addInput(self, weight)
		
	def addInput(self, neuron, weight)
		self.w.append((neuron,weight))
		
	def checkInputs(self):
		sum = 0
		for neuron, weight in self.w:
			if neuron.active:
				sum += weight
				neuron.active = 0
		if sum >= self.threshhold:
			self.execute() #run w/e
			#tell the neuron that it has something
			self.output.checkInputs()