Exemplo n.º 1
0
	def learning(self):
		for agent in self.Pop:	agent.assessment()	# storing current scores (with possible cross-benefits)
		# some agents learn
		Learners = sample(self.Pop, ET.chances(self.Param('LearningProbability')/100.0, len(self.Pop)))	
		for agent in self.Pop:
			agent.wins(agent.Points)	# Stores points for learning
			if agent in Learners:
				if not agent.Learns(self.neighbours(agent), hot=self.Obs.hot_phase()):
					# agent.update()	# this is a newborn - update position for display
					pass
				agent.update()	# update position for display
Exemplo n.º 2
0
	def learning(self):
		for agent in self.Pop:	agent.assessment()	# storing current scores (with possible cross-benefits)
		# some agents learn
		Learners = sample(self.Pop, ET.chances(self.Param('LearningProbability')/100.0, len(self.Pop)))	
		for agent in self.Pop:
			agent.wins(agent.Points)	# Stores points for learning
			if agent in Learners:
				if not agent.Learns(self.neighbours(agent), hot=self.Obs.hot_phase()):
					# agent.update()	# this is a newborn - update position for display
					pass
				agent.update()	# update position for display
Exemplo n.º 3
0
Arquivo: DNA.py Projeto: lesyk/Evolife
	def mutate(self, mutation_rate = -1):
		" computing the expected number of mutations "
		if mutation_rate < 0:	mutation_rate = self.Scenario.Parameter('MutationRate')
		mutation_number = Tools.chances(mutation_rate/1000.0, self.nb_nucleotides)
##        mutation_number =  (mutation_rate * self.nb_nucleotides) / 1000
##        if randint(1,1000) < 1 + ((mutation_rate * self.nb_nucleotides) % 1000) :
##            mutation_number += 1
		# performing mutations
		for mutation in range(mutation_number):
			pos = random.randint(0, self.nb_nucleotides - 1)
			self.__dna[pos] = 1 - self.__dna[pos]
		return mutation_number