コード例 #1
0
 def costHonor(self, offering, DifferentialCosts=False, patriotism=0):
     basic_cost = offering * percent(self.Parameter('HonoringCost'))
     if not DifferentialCosts:  # MaxOffer mode: non-patriots face the same cost as patriots
         return basic_cost
     else:  # DiffCosts mode: NonPatriots face a premium for honoring
         return basic_cost + basic_cost * (1 - patriotism) * percent(
             self.Parameter('DishonestPremium'))
コード例 #2
0
ファイル: Sacrifice.py プロジェクト: jlie10/SelfSacrifice
 def costHonor(self, offering, DifferentialCosts = False, patriotism = 0):
     basic_cost = offering * percent(self.Parameter('HonoringCost'))
     if not DifferentialCosts:
         #print('Offer max')
         return basic_cost
     else:   # NonPatriots face a premium for honoring
         #print('diff cost')
         return basic_cost + basic_cost * (1 - patriotism) * (1+ percent(self.Parameter('DishonestPremium')))
コード例 #3
0
ファイル: SocialSignals.py プロジェクト: piochelepiotr/jump
 def Signal(self, Feature=None, Transparent=False):
     " returns the actual quality of an individual or its displayed version "
     if Transparent: return self.Quality
     BC = Gbl.Param('BottomCompetence')
     Comp = percent(100 - BC) * self.Quality + BC
     # Comp = BC + self.Quality
     VisibleCompetence = percent(Comp * self.feature(Feature))
     return self.Limitate(VisibleCompetence, 0, 100)
コード例 #4
0
ファイル: SocialNetwork.py プロジェクト: ArnoutDevos/Athens
	def assessment(self):
		self.Points -= percent(Gbl.Param('SignallingCost') * self.Features['SignalInvestment'])
		# self.restore_symmetry() # Checks that self is its friends' friend
		for (Rank,Friend) in enumerate(self.Friends()):
			AgentSocialOffer = Gbl.InterActions.SocialOffer(Gbl.InterActions.FCompetence(self,
																				Apparent=False),
														Rank, self.nbFriends())
			Friend.Risk = percent(Friend.Risk * (100 - percent(Gbl.Param('CompetenceImpact')
																	   * AgentSocialOffer)))
コード例 #5
0
ファイル: Patriot.py プロジェクト: jlie10/SelfSacrifice
 def signalCost(self, sgl, DifferentialCosts=False, patriotism=0):
     basic_cost = sgl * percent(self.Scenario.Parameter('HonoringCost'))
     if not DifferentialCosts:
         #print('Offer max')
         self.score(-basic_cost)
     else:  # NonPatriots face a premium for honoring
         #print('diff cost')
         self.score(-basic_cost + basic_cost * (1 - patriotism) *
                    percent(self.Parameter('DishonestPremium')))
コード例 #6
0
	def Quality(self, Indiv, Apparent=False):
		" Adds a bottom value to Quality "
		BC = self.Parameter('BottomQuality')
		Comp = percent(100-BC) * Indiv.Phene_relative_value('Quality') + BC
		VisibleQuality = percent(Comp * Indiv.Phene_relative_value('SignalInvestment'))
		if Apparent:
			return VisibleQuality
		else:
			return Comp
コード例 #7
0
ファイル: S_Favourable.py プロジェクト: tomMoral/pjld
	def evaluation(self,indiv):
		""" Implements the computation of individuals' scores -  - Used in 'life_game'
		"""
		################################
		# computing individual benefit #
		################################
		Bonus = percent(indiv.gene_relative_intensity('favourable') * self.Parameter('IndividualBenefit'))
		Bonus += percent(self.CollectiveAsset * self.Parameter('CollectiveBenefit'))
		indiv.score(Bonus, FlagSet=False)  # Bonus is added to Score 
コード例 #8
0
ファイル: S_CostlySignal.py プロジェクト: ArnoutDevos/Athens
	def Quality(self, Indiv, Apparent=False):
		" Adds a bottom value to Quality "
		BC = self.Parameter('BottomQuality')
		Comp = percent(100-BC) * Indiv.Phene_relative_value('Quality') + BC
		VisibleQuality = percent(Comp * Indiv.Phene_relative_value('SignalInvestment'))
		if Apparent:
			return VisibleQuality
		else:
			return Comp
コード例 #9
0
ファイル: Hero.old.py プロジェクト: jlie10/SelfSacrifice
 def deathProbability(self, indiv):
     """ Converts an individual's genetic propensity to self-sacrifice into a probability
         MODIF: now dpeends on type --- fail
         MODIF2: now = probability of being a hero...
     """
     r = percent(indiv.gene_relative_value('Hero'))
     if r > random():
         return percent(self.Parameter('SacrificeProbability'))
     else:
         return 0
コード例 #10
0
ファイル: Hero.py プロジェクト: jlie10/SelfSacrifice
    def deathProbability(self, indiv):
        """ Depending on an individual's patriotism
            and genetic readiness to display it,
            the individual may engage in self-sacrifice
        """
        r = percent (indiv.gene_relative_value('Readiness')) \
            * percent (indiv.Phene_value('Patriotism'))
        #r = r/5 # pour comme JLD

        return r
コード例 #11
0
ファイル: SocialNetwork.py プロジェクト: ArnoutDevos/Athens
	def Competence(self, Apparent=False):
		" returns the actual quality of an individual or its displayed version "
		if Apparent:
			BC = Gbl.Param('BottomCompetence')
			Comp = percent(100-BC) * self.Quality + BC
			# Comp = BC + self.Quality
			VisibleCompetence = percent(Comp * self.Features['SignalInvestment'])	   
			return self.Limitate(VisibleCompetence, 0, 100)
		else:
			# return Comp
			return self.Quality
コード例 #12
0
	def Competence(self, Indiv, Apparent=False):
		" returns the actual quality of an individual or its displayed version "
		BC = self.Parameter('BottomCompetence')
		Comp = percent(100-BC) * Indiv.Quality + BC
		# Comp = BC + Indiv.Quality
		VisibleCompetence = percent(Comp * Indiv.SignalInvestment)	   
		if Apparent:
			return Limitate(VisibleCompetence, 0, 100)
		else:
			# return Comp
			return Indiv.Quality
コード例 #13
0
ファイル: S_Favourable.py プロジェクト: lesyk/Evolife
	def evaluation(self,indiv):
		""" Implements the computation of individuals' scores -  - Used in 'life_game'
		"""
		################################
		# computing individual benefit #
		################################
		IndividualValue = indiv.gene_relative_value('favourable')	# between 0 and 100
		# Bonus = <individual value> * <Individual benefit parameter> / 100 
		Bonus = percent(IndividualValue * self.Parameter('IndividualBenefit'))
		# Collective profit is merely added
		Bonus += percent(self.CollectiveAsset * self.Parameter('CollectiveBenefit'))
		indiv.score(Bonus, FlagSet=False)  # Bonus is added to Score 
コード例 #14
0
ファイル: S_Signalling.py プロジェクト: tomMoral/pjld
	def Competence(self, Indiv, Apparent=False):
		" Adds a bottom value to competence "
		BC = self.Parameter('BottomCompetence')
		Comp = percent(100-BC) * Indiv.Phene_relative_value('Competence') + BC
		VisibleCompetence = percent(Comp * Indiv.Phene_relative_value('SignalInvestment'))
		CompSign = self.Parameter('CompetenceSignificance')
		Attractiveness = percent(100-CompSign) * Indiv.Phene_relative_value('Strength') \
						 + percent(CompSign) * VisibleCompetence
		if Apparent:
			return Attractiveness
##            return VisibleCompetence
		else:
			return Comp
コード例 #15
0
	def assessment(self):
		self.Points -= percent(MyScenario.Parameter('SignallingCost') * self.SignalInvestment)
		if MyScenario.Parameter('InteractionScenario') == MyScenario.Parameter('CostlySignal'):
			if self.best_friend() is not None:
				self.best_friend().Points += MyScenario.Parameter('JoiningBonus')
		elif MyScenario.Parameter('InteractionScenario') == MyScenario.Parameter('Grooming'):
			self.restore_symmetry() # Checks that self is its friends' friend
			for (Rank,Friend) in enumerate(self.friends()):
				AgentSocialOffer = InterActions.SocialOffer(InterActions.FCompetence(self,
																					Apparent=False),
															Rank, self.nbFriends())
				Friend.Risk = percent(Friend.Risk * (100 - percent(MyScenario.Parameter('CompetenceImpact')
																		   * AgentSocialOffer)))
コード例 #16
0
ファイル: Sacrifice.py プロジェクト: jlie10/SelfSacrifice
    def evaluation(self, indiv):
        
        
        #print('indiv has {} friends'.format(indiv.nbFriends()))   
        #print('indiv has {} friends and {} followers'.format(indiv.nbFriends(), indiv.nbFollowers()))   
        
##################### version coll semble marche bien meme si mauss
#   et que depend pas mal des parametres...    
# # + add a Judas version ===> can even become dishonest signal... --> put a max on demand ?  
        indiv.score( + self.Parameter('FriendshipValue') * indiv.nbFollowers() )
        #indiv.score( + self.Parameter('FriendshipValue') * indiv.nbFollowers() )   # symmetrical version ...


        if indiv.Patriotism ==0 and random() < percent(self.Parameter('NbTraitors')):
            # indiv is a traitor who betrays its friends
            for follower in indiv.followers:
                follower.score(- self.Parameter('DenunciationCost'))
                
                indiv.score(+ self.Parameter('Judas'))  # 0 by default
                # Alt version ---> dishonest signaling could emerge ?? / Only with extreme values it seems, more like no sgl
        elif indiv.Patriotism ==1:
            for follower in indiv.followers:
                follower.score(+ self.Parameter('PatriotFriendBonus'))
        
        
        
        
        #else:
        #    for follower in indiv.followers:
        #        follower.score(+ self.Parameter('FriendshipValue'))
        
        
        return

################### version indiv marche bof...
        if indiv.nbFollowers() == 0: return
        
        indiv.score( + self.Parameter('JoiningBonus'))
                # OK si JB > FV en gros...
        Friend = choice(indiv.followers.names())

        if indiv.Patriotism == 0 and random() < percent(self.Parameter('NbTraitors')):
            # indiv is a traitor who betrays Friend
            Friend.score( - self.Parameter('DenunciationCost'))
            Friend.Executed = (self.Parameter('DenunciationCost') == 0)
        else:
            # Friend benefits from having befriended a true patriot
            Friend.score(+ self.Parameter('FriendshipValue'))

        return
コード例 #17
0
ファイル: S_Favourable.py プロジェクト: piochelepiotr/jump
    def evaluation(self, indiv):
        """ Implements the computation of individuals' scores -  - Used in 'life_game'
		"""
        ################################
        # computing individual benefit #
        ################################
        IndividualValue = indiv.gene_relative_value(
            'favourable')  # between 0 and 100
        # Bonus = <individual value> * <Individual benefit parameter> / 100
        Bonus = percent(IndividualValue * self.Parameter('IndividualBenefit'))
        # Collective profit is merely added
        Bonus += percent(self.CollectiveAsset *
                         self.Parameter('CollectiveBenefit'))
        indiv.score(Bonus, FlagSet=False)  # Bonus is added to Score
コード例 #18
0
ファイル: S_Signalling.py プロジェクト: tomMoral/pjld
	def start_game(self,members):
		""" defines what is to be done at the group level before interactions
			occur
		"""
 
		for Indiv in members:
			Indiv.score(self.Parameter('SignallingCost'), FlagSet=True)	# resetting scores
			SigInv = Indiv.Phene_value('SignalInvestment')
			self.GlobalComm += SigInv
			SignalCost = percent(SigInv * self.Parameter('SignallingCost'))
			Indiv.score(-SignalCost)
			# friendship links (lessening with time) are updated 
			#Indiv.lessening_friendship()
			# links are reset
			#Indiv.detach()

			# Monitoring competence distribution
			self.CompetenceHistogram[self.CompetenceRange(Indiv)][0] += SigInv
			self.CompetenceHistogram[self.CompetenceRange(Indiv)][1] += 1
				
		self.PopSize += len(members)	# number of individuals currently present
			
		# Individuals first interact one more time with their current friends
		for Indiv in members:
##            Offers = Indiv.gurus.performances()
##            histogram = [(O,Offers.count(O)) for O in list(set(Offers))]
##            histogram.sort(key=lambda x: x[1], reverse=True)
##            histogram = dict(histogram)
			for Friend in Indiv.friends():
				self.Interactions.groom(Indiv, Friend)
コード例 #19
0
ファイル: S_Cooperation.py プロジェクト: piochelepiotr/jump
	def interaction(self, indiv, Partner):
		""" Dyadic cooperative interaction: one player (indiv) makes the first step by
			offering a 'gift' to a partner. The latter then returns the favour.
			Both the gift and the returned reward are controlled by genes.
			Both involve costs.
		"""
		
		#   First step: initial gift
		gift = percent(self.Parameter('FirstStep') * indiv.gene_relative_value('Cooperativeness'))
		Partner.score(noise_mult(gift,self.Parameter('Noise')))	# multiplicative noise
		#   First player pays associated cost
		#   Cost is a function of investment
		cost = percent(gift * self.Parameter('FirstStepCost'))
		indiv.score(-cost)
		#   Receiver remembers who gave the gift
		Partner.follow(indiv, gift)
コード例 #20
0
ファイル: SocialSignals.py プロジェクト: piochelepiotr/jump
 def assessment(self):
     " computing social payoff "
     global SocialValue
     # first, pay the cost for signalling
     self.Points -= self.Cost()
     # self.restore_symmetry() # Checks that self is its friends' friend
     # being acquainted provides benefit to friend
     for (Rank, Friend) in enumerate(self.Friends()):
         # computing real friendship effect
         # AgentSocialOffer = SocialValue.SocialOffer(Gbl.InterActions.FCompetence(self, Transparent=True), Rank, self.nbFriends())
         AgentSocialEffect = SocialValue.SocialOffer(
             self.Quality, Rank, self.nbFriends())
         Friend.Risk = percent(
             Friend.Risk *
             (100 -
              percent(Gbl.Param('CompetenceImpact') * AgentSocialEffect)))
コード例 #21
0
ファイル: Exogenous.py プロジェクト: jlie10/Memoire
    def reproduction(self):
        """ Reproduction within the group
            Uses 'parenthood' (in Scenario) and 'couples' (not reproduced here - from Group module)
            'couples' returns as many couples as children are to be born
        """
        # The probability of parents to beget children depends on their rank within the group
        # (Except if Selectivity = 0, for which rank becomes random)
        self.update_(flagRanking=True)  # updates individual ranks
        for C in self.Scenario.couples(self.ranking):
            # Making of the child
            child = Individual(self.Scenario, ID=self.free_ID(), Newborn=True)
            if child:
                child.hybrid(
                    C[0],
                    C[1])  # Child's DNA results from parents' DNA crossover
                child.mutate()
                # Child inherits shares: thus grand-children (and so on) also indirectly benefit from self-sacrifice
                child.inherit_share(
                    C[0],
                    C[1],
                    heredity=percent(
                        self.Scenario.Parameter('SacrificeHeredity')))
                child.update(
                )  # Computes the value of genes, as DNA is available only now
                if self.Scenario.new_agent(
                        child, C
                ):  # Let scenario decide something about the newcomer (not used here)
                    # Child is added to parents' children lists
                    C[0].addChild(child)
                    C[1].addChild(child)

                    self.receive(child)  # Adds child to the group
コード例 #22
0
ファイル: Patriot.py プロジェクト: jlie10/SelfSacrifice
    def evaluation(self, indiv):

        #print('indiv has {} friends'.format(indiv.nbFriends()))
        #print('indiv has {} friends and {} followers'.format(indiv.nbFriends(), indiv.nbFollowers()))

        if indiv.nbFollowers() == 0:
            # indiv is alone in the world
            self.alone(indiv, penalty=self.Parameter('AlonePenalty'))
        else:
            indiv.score(+self.Parameter('JoiningBonus') *
                        indiv.nbFollowers())  # 0 by default
            # Sert vraiment a rien en principe...

        for follower in indiv.followers:
            follower.score(+self.Parameter('FriendshipValue'))
            # Friendship is beneficial no matter what

        if not indiv.patriot() == 0 and random() < percent(
                self.Parameter('NbTraitors')):
            # indiv is a traitor who betrays its friends
            for follower in indiv.followers:
                self.betrayed(follower,
                              cost=self.Parameter('DenunciationCost'))
                indiv.score(+self.Parameter('Judas'))

        elif indiv.patriot():
            # indiv is a true patriot : bonus (0 by default)
            for follower in indiv.followers:
                follower.score(+self.Parameter('PatriotFriendBonus'))

        return
コード例 #23
0
    def reproduction(self):
        """ Reproduction within the group (see Exogene) for details
            Calls local class 'Patriotic_Individual'
        """
        self.update_(flagRanking=True)  # updates individual ranks
        for C in self.Scenario.couples(self.ranking):
            # Making of the child
            child = Patriotic_Individual(self.Scenario,
                                         ID=self.free_ID(),
                                         Newborn=True)
            if child:
                child.hybrid(
                    C[0],
                    C[1])  # Child's DNA results from parents' DNA crossover
                child.mutate()
                child.inherit_share(
                    C[0],
                    C[1],
                    heredity=percent(
                        self.Scenario.Parameter('SacrificeHeredity')))
                child.update(
                )  # Computes the value of genes, as DNA is available only now
                if self.Scenario.new_agent(
                        child, C
                ):  # Let scenario decide something about the newcomer (not used here)
                    # Child is added to parents' children lists
                    C[0].addChild(child)
                    C[1].addChild(child)

                    self.receive(child)  # Adds child to the group
コード例 #24
0
ファイル: S_Cooperation.py プロジェクト: ArnoutDevos/Athens
	def interaction(self, indiv, Partner):
		""" Dyadic cooperative interaction: one player (indiv) makes the first step by
			offering a 'gift' to a partner. The latter then returns the favour.
			Both the gift and the returned reward are controlled by genes.
			Both involve costs.
		"""
		
		#   First step: initial gift
		gift = percent(self.Parameter('FirstStep') * indiv.gene_relative_value('Cooperativeness'))
		Partner.score(noise_mult(gift,self.Parameter('Noise')))	# multiplicative noise
		#   First player pays associated cost
		#   Cost is a function of investment
		cost = percent(gift * self.Parameter('FirstStepCost'))
		indiv.score(-cost)
		#   Receiver remembers who gave the gift
		Partner.follow(indiv, gift)
コード例 #25
0
ファイル: Hero.py プロジェクト: jlie10/SelfSacrifice
 def new_agent(self, child, parents):
     child.inherit_share(parents[0],
                         parents[1],
                         heredity=percent(
                             self.Parameter('SacrificeHeredity')))
     for P in parents:
         P.addChild(child)
     return True
コード例 #26
0
	def end_game(self, members):
		""" Individuals get benefit from their alliances
		"""
		# Followees get benefit from being followed
		# Followers get benefit from following high quality individuals

		for Follower in members:
			for Friend in Follower.friends():
				Friend.score(self.Parameter('FollowerSupport'))
				Follower.score(percent(self.Parameter('FollowerBenefit') * self.Quality(Friend, Apparent=False)))
コード例 #27
0
ファイル: S_CostlySignal.py プロジェクト: ArnoutDevos/Athens
	def end_game(self, members):
		""" Individuals get benefit from their alliances
		"""
		# Followees get benefit from being followed
		# Followers get benefit from following high quality individuals

		for Follower in members:
			for Friend in Follower.friends():
				Friend.score(self.Parameter('FollowerSupport'))
				Follower.score(percent(self.Parameter('FollowerBenefit') * self.Quality(Friend, Apparent=False)))
コード例 #28
0
ファイル: Hero.py プロジェクト: jlie10/SelfSacrifice
    def memo_heroes(self, new_heroes, members, threshold=5):
        " Society, through its (alive)_ individuals, remembers its heroes "

        members.sort(key=lambda x: x.HeroesWitnessed, reverse=True)

        past_heroes = members[int(percent(threshold) *
                                  len(members))].HeroesWitnessed
        # Heroes pass off to posterity if they are "remembered" by a sufficient amount of alive individuals (threshold %)
        for indiv in members:
            indiv.HeroesWitnessed += new_heroes
        return past_heroes + new_heroes
コード例 #29
0
ファイル: Exogenous.py プロジェクト: jlie10/Memoire
 def interactions(self, members, nb_interactions=1):
     """	Defines how the (alive) population interacts
         Used in 'life_game'
     """
     for inter in range(nb_interactions):
         if not members: return
         Fan = choice(members)
         # Fan chooses friends from a sample of Partners
         Partners = self.partners(Fan, members, int(percent(self.Parameter('SampleSize')\
                                                                 * (len(members)-1) )))
         self.interact(Fan, Partners)
コード例 #30
0
ファイル: S_Signalling.py プロジェクト: tomMoral/pjld
	def end_game(self, members):
		""" Individuals get benefit from their alliances
		"""
		# computing inclusive strength
		# Followers get benefit from following; that benefit is
		# correlated with the competence of the signaller. 

		for Agent in members:
			# self-service
			#Agent.Phene_value('Risk',100-self.SocialOffer(Agent, 0, Apparent=False))
			Agent.Phene_value('Risk',100)
		for Agent in members:
##            print 'end game', '%s(%d)' % (Agent.id, self.Competence(Agent,Apparent=False)),
##            print Agent.gurus
			for (Rank,Friend) in enumerate(Agent.friends()):
##                Friend.score(self.SocialOffer(Agent, Rank, Apparent=False))
				AgentSocialOffer = self.Interactions.SocialOffer(self.Competence(Agent, Apparent=False), Rank, Agent.nbFriends())
				Risk = percent(Friend.Phene_value('Risk') * (100 - percent(self.Parameter('CompetenceImpact')
																		   * AgentSocialOffer)))
				Friend.Phene_value('Risk',Risk)
##                print 'Friend', Friend.id, 'gets protection', self.SocialOffer(Agent, Rank, Apparent=False)
##                raw_input('.')
		for Agent in members:
			# agent get scores depending on their risk,
			# i.e. that grow with their accumulated protection
			Agent.score((100 - Agent.Phene_value('Risk')))
			# Monitoring average distance between best friends
			Friend = Agent.best_friend()
			if Friend is not None:
				self.CompetenceAvgDistance += abs(Friend.Phene_value('Competence')-Agent.Phene_value('Competence'))

			
		# monitoring scores depending on competence
		for Agent in members:
			CR = self.CompetenceRange(Agent)
			self.RiskByCompetence[CR][0] += 1
			self.RiskByCompetence[CR][1] += Agent.Phene_value('Risk')
コード例 #31
0
    def evaluation(self, indiv):

        indiv.score(+self.Parameter('JoiningBonus') * indiv.nbFollowers())

        if indiv.Patriotism == 0 and random() < percent(
                self.Parameter('NbTraitors')):
            # indiv is a traitor who betrays its friends
            for follower in indiv.followers:
                follower.score(-self.Parameter('DenunciationCost')
                               )  # The betrayed pay a cost
                indiv.score(+self.Parameter('Judas')
                            )  # Betrayer obtains payment for betrayal
        else:
            for follower in indiv.followers:
                follower.score(+self.Parameter('FriendshipValue'))
        return
コード例 #32
0
ファイル: S_Gazelle.py プロジェクト: tomMoral/pjld
	def interaction(self, gazelle, lion):
		if self.gazelle(gazelle) and lion:	# a partner has been found - Hunt may begin
			if self.gazelle(lion):	error("Gazelle scenario:", "Hunting gazelle")
			# the lion decides whether the gazelle is worth chasing
			chase = True
			if random.randint(1,100) < lion.gene_relative_intensity('LionSensitivityToSignal'):
				# this lion pays attention to jumps
				jump = self.jump(gazelle)
				# the gazelle pays the price
				gazelle.score(-percent(self.Parameter('JumpCost')*jump))
				if jump > self.Parameter('Noise'):
					chase = False	# This wise lion will consider another prey
			# Now the lion gets the benefit or cost of the chase
			if chase:
				if self.strongGazelle(gazelle):		# SOMETHING'S MISSING HERE . . .
					lion.score(-self.Parameter('LostPreyCost'))
				else:
					lion.score(self.Parameter('HunterReward'))
					gazelle.score(-self.Parameter('PreyCost'))					
コード例 #33
0
ファイル: SocialNetwork.py プロジェクト: lesyk/Evolife
	def One_Step(self):
		" Interactions take place, then learning "
		# This procedure is repeatedly called by the simulation thread
		# Social interactions
		for agent in self.Pop:
			agent.Points = 0
			agent.Risk = 100	# maximum risk
			# agent.lessening_friendship()	# eroding past gurus performances
##		for agent in self.Pop:
##			# first interact with current friends
##			for Partner in agent.friends():
##				agent.Interact([Partner])
		for Run in range(Gbl.Parameters.Parameter('NbRuns')):
			if Gbl.ScenarioName == 'CostlySignal':
				Fan = choice(self.Pop)
				# Fan chooses from a sample
				Fan.Interact(sample(self.Pop, Gbl.Parameters.Parameter('SampleSize')))
			elif Gbl.ScenarioName == 'Grooming':
				(Player, Partner) = sample(self.Pop, 2)
				Partner.Interact([Player])
		for agent in self.Pop:
			# one looks whether interactions were profitable
			agent.assessment()
		for agent in self.Pop:
			agent.wins()	# memorizes success
			#if self.Obs.Visible() and agent.Quality == 99:
			#	print agent, '>>>', agent.Benefits, '{%d}' % agent.Points
			#	print "%s --> %s" % (agent, agent.Benefits)
		# Learning occurs for one agent every NbRuns interactions
		Learner = choice(self.Pop)
		Children = self.Obs.StepId < percent(self.Obs.TimeLimit * Gbl.Parameters.Parameter('LearnHorizon'))
		Learner.Learns(self.neighbours(Learner), Children)
		# Learner should re-interact with its followers
		for Partner in Learner.followers.names():
			Partner.Interact([Learner])
		self.Obs.Positions[Learner.id] = Learner.Position
		if self.Obs.Visible():
##			self.Obs.Alliances = [(agent.id,[(agent.best_friend().id,0)])
##									  for agent in self.Pop if agent.best_friend() is not None]
##			self.Obs.Alliances += [(agent.id,[])
##									  for agent in self.Pop if agent.best_friend() == None]
			self.Obs.Alliances = [(agent.id, [T.id for T in Alliances.signature(agent)]) for agent in self.Pop]
		return True	 # This value is forwarded to "ReturnFromThread"
コード例 #34
0
	def start_game(self,members):
		""" defines what is to be done at the group level before interactions
			occur
		"""
 
		for Indiv in members:
			# resetting scores so that scors remain positive
			Indiv.score(self.Parameter('CostlySignalCost'), FlagSet=True)
			SigInv = Indiv.Phene_value('SignalInvestment')
			SignalCost = percent(SigInv * self.Parameter('CostlySignalCost'))
			Indiv.score(-SignalCost)

			# Monitoring Quality distribution
			self.GlobalComm += SigInv
			self.QualityHistogram[self.QualityRange(Indiv)][0] += SigInv
			self.QualityHistogram[self.QualityRange(Indiv)][1] += 1
				
		self.PopSize += len(members)	# number of individuals currently present
			
		# Individuals first interact one more time with their current friends
		for Indiv in members:
			for Friend in Indiv.friends():
				self.interaction(Indiv, Friend)
コード例 #35
0
ファイル: S_CostlySignal.py プロジェクト: ArnoutDevos/Athens
	def start_game(self,members):
		""" defines what is to be done at the group level before interactions
			occur
		"""
 
		for Indiv in members:
			# resetting scores so that scors remain positive
			Indiv.score(self.Parameter('CostlySignalCost'), FlagSet=True)
			SigInv = Indiv.Phene_value('SignalInvestment')
			SignalCost = percent(SigInv * self.Parameter('CostlySignalCost'))
			Indiv.score(-SignalCost)

			# Monitoring Quality distribution
			self.GlobalComm += SigInv
			self.QualityHistogram[self.QualityRange(Indiv)][0] += SigInv
			self.QualityHistogram[self.QualityRange(Indiv)][1] += 1
				
		self.PopSize += len(members)	# number of individuals currently present
			
		# Individuals first interact one more time with their current friends
		for Indiv in members:
			for Friend in Indiv.friends():
				self.interaction(Indiv, Friend)
コード例 #36
0
	def One_Step(self):
		" Interactions take place, then learning "
		# This procedure is repeatedly called by the simulation thread
		# Social interactions
		for agent in self.Pop:
			agent.Points = 0
			agent.Risk = 100	# maximum risk
##        for agent in self.Pop:
##            # first interact with current friends
##            for Partner in agent.friends():
##                agent.Interact(Partner)
		for Run in range(MyScenario.Parameter('NbRuns')):
			(Player, Partner) = sample(self.Pop, 2)
			Partner.Interact(Player)
		for agent in self.Pop:
			# one looks whether interactions were profitable
			agent.assessment()
		for agent in self.Pop:
			agent.wins()	# memorizes success
			#if self.Obs.Visible() and agent.id == 99:
			#	print agent, '>>>', agent.Benefits, '{%d}' % agent.Points
			#	print "%s --> %s" % (agent, agent.Benefits)
		# Learning occurs for one agent every NbRuns interactions
		Learner = choice(self.Pop)
		Children = self.Obs.StepId < percent(self.Obs.TimeLimit * MyScenario.Parameter('LearnHorizon'))
		Learner.Learns(self.neighbours(Learner), Children)
		# Learner should re-interact with its followers
		for Partner in Learner.followers.names():
			Partner.Interact(Learner)
		self.Obs.Positions[Learner.id] = Learner.Position
		if self.Obs.Visible():
##            self.Obs.Alliances = [(agent.id,[(agent.best_friend().id,0)])
##                                      for agent in self.Pop if agent.best_friend() is not None]
##            self.Obs.Alliances += [(agent.id,[])
##                                      for agent in self.Pop if agent.best_friend() == None]
			self.Obs.Alliances = [(agent.id,Alliances.signature(agent)) for agent in self.Pop]
		return 0	 # This value is forwarded to "ReturnFromThread"
コード例 #37
0
ファイル: SocialNetwork.py プロジェクト: lesyk/Evolife
	def adult(self):
		return self.Age > percent(Gbl.Parameters.Parameter('AgeMax') * Gbl.Parameters.Parameter('Infancy'))
コード例 #38
0
	def adult(self):
		return self.Age > percent(MyScenario.Parameter('AgeMax') * MyScenario.Parameter('Infancy'))
コード例 #39
0
ファイル: SocialSignals.py プロジェクト: piochelepiotr/jump
 def Cost(self, Feature=None):
     return percent(Gbl.Param('SignallingCost') * self.feature(Feature))