Example #1
0
 def determine_birth(self):
     '''
     determines if an individual is too big and if so it separates
     based on the div size. recalculates food
     :return: void
     '''
     for i in self.individuals:
         if i.size > i.divideSize:
             dir = 0  #randrange(0, 180)
             childA = Critter(foodAmount=(i.foodAmount / 2),
                              size=(i.size / 2),
                              location=i.location,
                              heading=dir,
                              color=i.color,
                              speed=i.speed,
                              typeName=self.typeName)
             muDir = 0  #randrange(180, 360)
             childB = Critter(foodAmount=(i.foodAmount / 2),
                              size=(i.size / 2),
                              location=i.location,
                              heading=muDir,
                              color=i.color,
                              speed=i.speed,
                              typeName=self.typeName)
             i.alive = False
             self.individuals.remove(i)
             self.individuals.append(childA)
             self.individuals.append(childB)
Example #2
0
 def build_pop(self):
     '''
     this function fills the member population with a seed gen of x Critters
     :return: void
     '''
     for i in range(0, self.startingPopulation):
         this_critter = Critter(
             location=[randint(0, 1200), randint(0, 600)],
             heading=(0),
             size=15,
             typeName=self.typeName,
             color=self.color)
         #print(this_critter.location[0],'\t',this_critter.location[1])
         self.individuals.append(this_critter)
 def __init__(self, x, y, hunger):
     Critter.__init__(self, x, y, 7)
     self.char = chr(0x2665)
 def __init__(self, x, y, hunger):
     Critter.__init__(self, x, y, hunger)
     self.vector = [0,0]
     while(self.vector[0] + self.vector[1] < 3 or self.vector[0] == 0 or self.vector[1] == 0):
         self.vector = [random.randint(-4,4), random.randint(-4,4)]
     self.char = chr(0x25BC)
Example #5
0
 def update(self):
     Critter.update(self)
     self.hunger = 0
Example #6
0
 def __init__(self, x, y, hunger):
     Critter.__init__(self, x, y, 0)
     self.char = "✈"
Example #7
0
 def collision(self, othercritter):
     if (self.x == othercritter.x and self.y == othercritter.y):
         newCritter = Critter(self.x, self.y, 0)
         self.vector, othercritter.vector, newCritter.vector = self.__generate3Vectors(
         )
         return newCritter