Пример #1
0
 def update(self,selected):
     self._count+=1
     
     if len(selected)==0:
         
         Pulsator.counter-=1
         if Pulsator.counter==0:
             self.radius-=0.5
             Pulsator.counter=30
     else:
         if len(Black_Hole.update(self,selected))!=0:
             Pulsator.counter=30
             self.radius+=0.5
         else:
             Pulsator.counter-=1
             if Pulsator.counter==0:
                 self.radius-=0.5
                 Pulsator.counter=30
         
     if self.radius==0 or self._count==600:
         temp=Black_Hole.update(self,selected)
         temp.add(self)
         return temp
     
     return Black_Hole.update(self,selected)
 def update(self, model):
     if len(Black_Hole.update(self, model)) != 0:
         for i in range(len(Black_Hole.update(self, model))):
             for a in range(10):
                 choice = randint(1, 2)
                 dx = randint(-10, 10)
                 dy = randint(-10, 10)
                 if choice == 1:
                     model.simuls.add(Ball(self._x + dx, self._y + dy))
                 elif choice == 2:
                     model.simuls.add(Floater(self._x + dx, self._y + dy))
         self.eaten = set()
         model.remove(self)
 def update(self, model):
     if len(Black_Hole.update(self, model)) == 0:
         self.counter -= 1
         if self.counter == 0:
             self.change_dimension(-1, -1)
             self.counter = Pulsator.counter
             w, h = self.get_dimension()
             if w == 0:
                 model.remove(self)
     else:
         self.counter = Pulsator.counter
         self.change_dimension(len(Black_Hole.update(self, model)),
                               len(Black_Hole.update(self, model)))
         self.eaten = set()
Пример #4
0
    def update(self):
        eaten = Black_Hole.update(self)
        width, height = self.get_dimension()

        if self.explode:

            if self.expand:
                self.radius *= self.expand_factor
                self.set_dimension(width * self.expand_factor,
                                   height * self.expand_factor)
                self.expand = False

            self.countdown -= 1
            if self.countdown <= 0:
                eaten.add(self)
                return eaten

        if len(eaten) > 0 and not self.explode:  # ate something
            self.radius -= 0.5 * len(eaten)
            self.set_dimension(width - 1 * len(eaten), height - 1 * len(eaten))

            self.counter += 1  # reset

        if self.counter > 5 and not self.explode:
            self.explode = True
            self.expand = True

        return eaten
Пример #5
0
 def update(self, model):
     self.move()
     for item in Black_Hole.update(self, model):
         if Special.shape == 'rectangle':
             Special.shape = 'oval'
         else:
             Special.shape = 'rectangle'
Пример #6
0
 def update(self, model):
     targets = model.find(lambda s: isinstance(s, Prey)
                        and self.distance(s.get_location()) <= Special.killzone)
     if len(targets) > 0:
         target = sorted([t for t in targets],
                         key = lambda t: self.distance(t.get_location()))[0]
         x,y = self.get_location()
         tx, ty = target.get_location()
         self.set_angle(atan2(ty-y, tx-x))
         
     self.move()
     
     eaten = Black_Hole.update(self, model)
     if len(eaten) > 0:
         self.count = 1
         if self.get_speed() <= Special.max_speed:
             self.set_speed(self.get_speed() + len(eaten))
         if self.get_speed() > Special.max_speed:
             self.set_speed(Special.max_speed)
     else:
         if self.count == Special.counter:
             self.set_speed(self.get_speed() - 1)
             if self.get_speed() == 0:
                 model.to_be_removed.add(self)
             self.count = 1
         else:
             self.count += 1
     
     return eaten
Пример #7
0
 def update(self):
     x = Black_Hole.update(self)
     if x != set():
         self.change_dimension(1,1)
     targets_in_range = model.find(self.hunt_contains_obj)
     closest = None
     ticker = None
     for i in targets_in_range:
         if ticker == None:
             if self.target1 != i and self.target2 != i:
                 ticker = self.distance(i.get_location())
                 closest = i
         else:
             if self.distance(i.get_location()) < ticker:
                 if self.target1 != i and self.target2 != i:
                     ticker = self.distance(i.get_location())
                     closest = i
     if closest != None:
         if self.target1 == None:
             self.target1 = closest
             self.launch_parasite(True)
         elif self.target2 == None:
             self.target2 = closest
             self.launch_parasite(False)
     self.remove_close_parasites()
     #print(self.get_dimension())
     self.move()
Пример #8
0
    def update(self, model):
        self.counter -= 1
        Black_Hole.update(self, model)
        if self.counter == 0:
            self.change_dimension(-1,-1)
            w, h = self.get_dimension()
            self.counter = 30
            if w == 0 and h == 0:
                model.controller.the_canvas.delete(self)
                model.sim.remove(self)


        elif self.eatenNum < self.eaten:
            ate = self.eaten - self.eatenNum
            self.eatenNum = self.eaten
            Black_Hole.change_dimension(self, ate, ate)
            self.counter = 30
Пример #9
0
 def update(self):
     self.coory = Simulton.get_dimension(self)
     if self.coory[0] == 0:
         model.removed.add(self)
     else:
         self.move()
         Black_Hole.update(self)
         current = 501
         chase = 0
         for b in model.find(special.Special):
             coord = (b._x, b._y)
             leng = math.hypot(coord[0]-self._x, 
                          coord[1]-self._y)
             if leng<500:
                 if leng<current:
                     current=leng 
                     chase = b
         if chase != 0:
             self._angle = math.atan2(chase._y-self._y, chase._x-self._x)
Пример #10
0
 def update(self, model):
     self.pulsator_counter += 1
     if self.pulsator_counter == Pulsator.counter_constant:
         self.pulsator_counter = 0
         self.change_dimension(-1, -1)
     if self.get_dimension()[0] <= 0:
         model.simultons.remove(self)
     for item in Black_Hole.update(self, model):
         self.change_dimension(1, 1)
         self.pulsator_counter = 0
Пример #11
0
 def update(self, model):
     eaten_objects = Black_Hole.update(self, model)
     self.count += 1
     if len(eaten_objects) > 0:
         self.count = 0
         self.change_dimension(len(eaten_objects), len(eaten_objects))
     if self.count == self.counter_constant:
         self.count = 0
         self.change_dimension(-1, -1)
     if self.get_dimension() == (0, 0):
             model.remove(self)
Пример #12
0
 def update(self,model):
     self._counter += 1
     eaten = Black_Hole.update(self,model)
     if eaten:
         self._counter = 0
         self.change_dimension(len(eaten),len(eaten))
     elif self._counter == Pulsator.shrink_count:
         self.change_dimension(-1,-1)
         if self.get_dimension()[0] == 0:
             model.remove(self)
         self._counter = 0
     return eaten
Пример #13
0
 def update(self, model):
     self.counter += 1
     eaten = Black_Hole.update(self, model)
     if eaten:
         self.counter = 0
         self.change_dimension(len(eaten), len(eaten))
     elif self.counter == Pulsator.counter:
         self.change_dimension(-1, -1)
         if self._width == 0:
             model.remove(self)
         self.counter = 0
     return eaten
Пример #14
0
 def update(self, model):
     self._counter +=1 
     sims = Black_Hole.update(self, model)
     if sims:
         self._counter = 0
         self.change_dimension(len(sims), len(sims))
     elif self._counter == Pulsator.counter_constant:
         self.change_dimension(-1, -1)
         if self.get_dimension()[0] == 0:
             model.remove(self)
         self._counter = 0
     return sims
Пример #15
0
 def update(self,model):
     eaten = Black_Hole.update(self,model)
     if len(eaten)==0:
         self._time_starved += 1
         if self._time_starved % self.counter == 0:
             self.change_dimension(-1,-1)
             self._time_starved = 0
     else:
         self.change_dimension(1, 1)
         self._timestarved = 0
     if self.get_dimension() == (0,0):
         model.remove(self)
Пример #16
0
 def update(self):
     eaten=Black_Hole.update(self)
     self._counter+=1
     if len(eaten)!=0:
         self.change_dimension(len(eaten), len(eaten))
         self._counter=0
     if self._counter == Pulsator.counter_constant:
         self.change_dimension(-1, -1)
         self._counter=0
     if self.get_dimension() == (0,0):
         model.remove(self)
     return eaten
 def update(self,model):
     self._truth+=1
     temp = Black_Hole.update(self,model)
     if len(temp)==0 and self._truth==Pulsator.the_truth_of_the_world:
         self.change_dimension(-1,-1)
         self._truth = 0
     elif self.get_dimension()==(0,0):model.remove(self)
     else:
         for i in range(len(temp)):
             self.change_dimension(1,1)
             self._truth = 0
     return temp
Пример #18
0
 def update(self, model):
     self.time_between_meals += 1
     eaten = Black_Hole.update(self, model)
     if len(eaten) > 0:
         for i in eaten.copy():
             self.change_dimension(1, 1)
             self.time_between_meals = 0
     else:
         if self.time_between_meals % self._counter_constant == 0:
             self.change_dimension(-1, -1)
             if self.get_dimension() == (0, 0):
                 model.remove(self)
     return eaten
Пример #19
0
 def update(self, model):
     self.counterc -= 1
     eaten = len(Black_Hole.update(self,model))
     if eaten != 0:
         self.counterc = Pulsator.ecounter
         self.change_dimension(eaten,eaten)
     if self.counterc == 0:
         self.change_dimension(-1,-1)
         if self._height == 0 and self._width == 0:
             model.remove(self)
         self.counterc = Pulsator.ecounter
         
         
Пример #20
0
 def update(self, model):
     self._counter += 1
     already_eaten = Black_Hole.update(self, model)
     if already_eaten and len(already_eaten) > self.count:
         self.count += 1
         self.change_dimension(len(already_eaten), len(already_eaten))
         self._counter = 0
     elif self._counter == Pulsator.constant:
         self.change_dimension(-1, -1)
         if self.get_dimension() == (0, 0):
             model.remove(self)
         self._counter = 0
     return already_eaten
Пример #21
0
 def update(self):
     eaten = Black_Hole.update(self)
     if len(eaten) != 0:
         self.change_dimension(len(eaten), len(eaten))
         self.counter = 0
     else:
         if self.counter + 1 == 30:
             self.counter = 0
             self.change_dimension(-1, -1)
             if self.get_dimension() == (0, 0):
                 model.remove(self)
         else:
             self.counter += 1
     return eaten
Пример #22
0
    def update(self, model):
        self.count += 1
        set1 = Black_Hole.update(self, model)
        size = len(set1)
        if size:
            self.count = 0
            self.change_dimension(size, size)
        elif self.count == 30:
            self.change_dimension(-1, -1)
            self.count = 0
            if self.get_dimension() == (0, 0):
                model.remove(self)

        return set1
Пример #23
0
 def update(self):
     ate = Black_Hole.update(self)    
     if ate:
         self.change_dimension(len(ate), len(ate))
         self._counter = 0
         
     else:
         self._counter +=1
         if self._counter == 30:
             self._counter = 0
             self.change_dimension(-1,-1)
             if self.get_dimension() == (0,0):
                 model.remove(self)
     return ate
Пример #24
0
 def update(self, model):
     self._counter += 1
     eaten = Black_Hole.update(self, model)
     if len(eaten) == 0:
         if self._counter == 30:
             self.change_dimension(-1, -1)
             self._counter = 0
             if 0 in self.get_dimension():
                 model.remove(self)
     else:
         self._counter = 0
         for x in eaten:
             self.change_dimension(1, 1)
     return eaten
Пример #25
0
 def update(self, model):
     self.counter += 1
     if self.counter == 30:
         if self.get_dimension()[0] == 1:
             model.remove(self)
         else:
             self.counter = 0
             self.set_dimension(self.get_dimension()[0] - 1,
                                self.get_dimension()[1] - 1)
     g = Black_Hole.update(self, model)
     for _ in g:
         self.change_dimension(1, 1)
         self.counter = 0
     return g
Пример #26
0
 def update(self, model):
     eaten = Black_Hole.update(self, model)
     if len(eaten) > 0:
         self.count = 1
         self.change_dimension(len(eaten), len(eaten))
     else:
         if self.count == Pulsator.counter:
             self.change_dimension(-1, -1)
             if self.get_dimension() == (0, 0):
                 model.to_be_removed.add(self)
             self.count = 1
         else:
             self.count += 1
     return eaten
Пример #27
0
 def update(self, model):
     temp = Black_Hole.update(self, model)
     if len(temp) != 0:
         for _ in range(len(temp)):
             self.change_dimension(1, 1)
         self._counter = 0
         return temp
     else:
         self._counter += 1
         if self._counter == self.max_count:
             self._counter = 0
             self.change_dimension(-1, -1)
             if self.get_dimension() == (0, 0):
                 return {self}
             return set()
Пример #28
0
 def update(self, model):
     eaten = Black_Hole.update(self, model)
     if eaten != set():
         self.change_dimension(1, 1)
         self.counter = 30
     else:
         self.counter -= 1
     if self.counter == 0:
         if self.get_dimension()[0] == 0:
             model.things = set([i for i in model.things if i != self])
         else:
             self.change_dimension(-1, -1)
             self.counter = 30
     self.radius = self.get_dimension()[0] / 2
     return eaten
Пример #29
0
 def update(self, model):
     x = Black_Hole.update(self, model)
     self._counter -= 1
     if len(x) > 0:
         for _ in x:
             self._counter = self.c
             self.change_dimension(1, 1)
             self.radius += 0.5
     if self._counter == 0:
         self._counter = self.c
         self.change_dimension(-1, -1)
         self.radius -= 0.5
     if self.get_dimension() == (0,0):
         model.remove(self)
     return x
Пример #30
0
 def update(self, model):
     self.counter2 += 1
     matched = Black_Hole.update(self, model)
     if not matched:
         if self.counter2 == self.counter1:
             self.change_dimension(-1, -1)
             if self.get_dimension()[0] == 0 or self.get_dimension(
             )[1] == 0:
                 model.remove(self)
             self.counter2 = 0
     else:
         for i in matched:
             self.change_dimension(1, 1)
         self.counter2 = 0
     return matched
Пример #31
0
 def update(self,model):
     removed = Black_Hole.update(self,model)
     if len(removed) != 0:
         self._width += len(removed)
         self._height += len(removed)
         self._time_between_meals = 0
     elif len(removed) == 0:
         self._time_between_meals += 1
         if self._time_between_meals == Pulsator.counter:
             self._time_between_meals = 0
             self._width -= 1
             self._height -= 1
             if self._width == 0:
                 model.remove(self)
     return removed
Пример #32
0
 def update(self):
     result = Black_Hole.update(self)
     delta = len(result)
     if delta:
         self.change_dimension(delta, delta)
         self.count = 0
     elif self.count != Pulsator.counter:
         self.count += 1
     else:
         self.change_dimension(-1, -1)
         self.count = 0
     if self.get_dimension() == (0, 0):
         return {self}
     else:
         return result
Пример #33
0
 def update(self):
     self.pulsator_counter += 1
     Eaten_item_set = Black_Hole.update(self)
     
     if self.get_dimension() == (0,0):
             model.remove(self)
             
     if self.pulsator_counter == Pulsator.counter_constant:
         Black_Hole.change_dimension(self,-1,-1)
         self.pulsator_counter = 0
         
     for item in Eaten_item_set:
         Black_Hole.change_dimension(self,1,1)
         self.pulsator_counter = 0
         
     return Eaten_item_set
 def update(self, model):
     result = Black_Hole.update(self,model)
     self._counter += 1
     if len(result) > 0:
         self.set_dimension(self.get_dimension()[0] + len(result), self.get_dimension()[1] + len(result))
         self._image = PhotoImage(Image.open('space_amoeba.gif').convert('RGBA').resize((self.get_dimension()[0], self.get_dimension()[1]), Image.ANTIALIAS))            
         self.radius = (self._image.height()/2)+((self._image.width()**2)/(8 * self._image.height()))
         self._counter = 1
     if self._counter == Pulsator.counter:
         self.set_dimension(self.get_dimension()[0] - 1, self.get_dimension()[1] - 1)
         self._image = PhotoImage(Image.open('space_amoeba.gif').convert('RGBA').resize((self.get_dimension()[0], self.get_dimension()[1]), Image.ANTIALIAS))
         self.radius = (self._image.height()/2)+((self._image.width()**2)/(8 * self._image.height()))
         self._counter = 1
     if self.get_dimension() < (Pulsator.death,Pulsator.death):
         result.add(self)
     return result
 def update(self, model):
     self.time_count += 1
     ball_eaten = Black_Hole.update(self, model)
     if self.time_count == Pulsator.death_num:
         if ball_eaten == set():
             self.change_dimension(-1, -1)
             self.time_count = 0
         if ball_eaten != set():
             self.time_count = 0
     if ball_eaten != set():
         for ball in ball_eaten:
             self.change_dimension(1, 1)
             self.time_count = 0
     wid = self.get_dimension()[0]
     if wid == 0:
         model.remove(self)
Пример #36
0
    def update(self, model):
        removal_set = Black_Hole.update(self, model)
        if removal_set:
            for num in range(len(removal_set)):
                self.change_dimension(1, 1)
            self._counter = 1
        elif self._counter == Pulsator.tbm:
            self.change_dimension(-1, -1)
            self._counter = 1
            x, y = self.get_dimension()
            if x == 0 and y == 0:
                model.remove(self)
        else:
            self._counter += 1

        return removal_set
Пример #37
0
 def update(self, model):
     self.cycles += 1
     self.move()
     self.wall_bounce()
     if self.cycles % 10 == 0:
         self._angle += 36
     removed = Black_Hole.update(self, model)
     direction = random.random()
     if len(removed) > 0:
         if direction <= 0.25:
             self._x -= 30
         elif direction <= 0.5:
             self._x += 30
         elif direction <= 0.75:
             self._y -= 30
         elif direction <= 1:
             self._y += 30
Пример #38
0
 def update(self):
     main = []
     x_coor = Simulton.get_dimension(self)
     if x_coor[0] == 0:
         model.removed.add(self)
     else:
         if self._counter == 0:
             Simulton.set_dimension(self, x_coor[0] - 2, x_coor[1] - 2)
             self._counter = 30
         else:
             item = Black_Hole.update(self)
             if len(item) == 0:
                 self._counter -= 1
             else:
                 main += [pa for pa in item]
                 self._counter = 30
                 Simulton.set_dimension(self, x_coor[0] + 2, x_coor[1] + 2)
     return set(main)
Пример #39
0
 def update(self, p):
     to_eat = Black_Hole.update(self,p)
     eaten = set()
     for obj in to_eat:
         if not isinstance(obj,Chain_Link):
             eoc = self.end_of_chain
             chain_x, chain_y = eoc.get_location()
             chain_angle = eoc.get_angle()
             
             new_x = chain_x - eoc.radius*cos(chain_angle)
             new_y = chain_y - eoc.radius*sin(chain_angle)
             
             new_link = Chain_Link(new_x, new_y, self.end_of_chain)
             new_link.change_location(-new_link.radius, -new_link.radius)
             
             self.end_of_chain = new_link
             model.add(new_link)
             eaten.add(obj)
     
     self.move()
     return eaten