code: def calculate_fitness(self):
          
          if self.fitness is not None:
              raise Exception(
                  "You are calculating the fitness of agent {}, ".format(self.id)
                  + "but they already have a fitness"
              )
  
          said_blue = self.infos(type=Meme)[0].contents == "blue"
  
          proportion = float(
              max(
                  self.network.nodes(type=RogersEnvironment)[0].infos(),
                  key=attrgetter("id"),
              ).contents
          )
          self.proportion = proportion
          is_blue = proportion > 0.5
  
          if said_blue is is_blue:
              self.score = 1
          else:
              self.score = 0
  
          is_asocial = self.infos(type=LearningGene)[0].contents == "asocial"
  
          e = 2
          b = 1
          c = 0.3 * b
          baseline = c + 0.0001
  
          self.fitness = (baseline + self.score * b - is_asocial * c) ** e
docs: Calculcate your fitness.