
import ec

NUM_EC = 4

class Model:
	state, funs = [], []
	out_i = None

	def __init__(self):
		self.state = [None]*NUM_EC
		for i in range(NUM_EC):
			self.funs.append(ec.EC(i))
		self.out_i = None

	def set_out_id(self, i):
		self.out_i = i
	
	def run(self):
		next_state = [None]*len(self.state)
		for i in range(len(self.funs)):
			output = self.funs[i].run(self.state[i-1])
			if output != NUM_EC:
				next_state[i] = output 
			else:	
				next_state[i] = self.state[i]
		self.state = next_state

	def trsfun(self, input):
		self.state = input
		self.run()
		if self.out_i == None:
			return self.state
		else:
			return self.state[self.out_i]



