예제 #1
0
파일: critter.py 프로젝트: nglgzz/tale
	def crossover(self, partner):
		"""
			Returns the critters' child and decreases energy to
			this critter and the partner

			Parameter partner is the critter's partner
		"""
		self.energy    -= Critter_s.mate_cost
		partner.energy -= Critter_s.mate_cost2

		child = Critter(Critter_s.randpos())
		child.brain = self.brain.crossover(partner.brain)
		return child
예제 #2
0
파일: simulation.py 프로젝트: nglgzz/tale
	def __init__(self):
		"""
			Initializes a simulation creating the world (which is a grid),
			creating a dictionary of critters, the keys are tuples representing the positions
			and the values are the critters, spawning food and then syncing everything with the
			world
		"""
		self.world = Grid(Environment_s.width, Environment_s.height)
		self.world_age = 0

		self.population = {}
		for i in range(Simulation_s.n_crit):
			c = Critter(Critter_s.randpos())
			self.population[c.pos] = c

		self.food = Food(Simulation_s.n_food)
		self.sync()