Example #1
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
Example #2
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)
Example #3
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)
 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
Example #5
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
 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
Example #7
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
Example #8
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)
Example #9
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
Example #10
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
Example #11
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
         
         
Example #12
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
Example #13
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
Example #14
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
Example #15
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
Example #16
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
Example #17
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
Example #18
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
Example #19
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
Example #20
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
Example #21
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
Example #22
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()
 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
Example #24
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
Example #25
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
 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)
 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
Example #28
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
Example #29
0
    def update(self):  #,model):#,model):#,model):#model):
        subtract_one = -1
        self._counting_object += 1
        new_variable = Black_Hole.update(self)  #,model)#model)#model)#,model)
        #deleted_object = Black_Hole.update(self,model)
        if new_variable:
            # self._counting_object = 0
            self.change_dimension(len(new_variable), len(new_variable))
            self._counting_object = 0
        elif self._counting_object == 30:
            self.change_dimension(subtract_one, subtract_one)

            if self.get_dimension()[0] == 0:

                model.remove(self)
            self._counting_object = 0
        return new_variable
Example #30
0
 def update(self, model):
     c = 30
     self.counter += 1
     eaten = Black_Hole.update(self, model)
     for prey in eaten:
         self._width += 1
         self._height += 1
         
     if self.counter == c:
         self._width -= 1
         self._height -= 1
         self.counter = 0
         
     if self._width == 0 and self._height == 0:
         model.remove(self)
         
     return eaten
Example #31
0
def mouse_click(x, y):
    if button == 'Ball':
        simulation.add(Ball(x, y))
    elif button == 'Floater':
        simulation.add(Floater(x, y))
    elif button == 'Black_Hole':
        simulation.add(Black_Hole(x, y))
    elif button == 'Pulsator':
        simulation.add(Pulsator(x, y))
    elif button == 'Hunter':
        simulation.add(Hunter(x, y))
    elif button == 'Special':
        simulation.add(Special(x, y))
    elif button == 'Remove':
        for i in simulation.copy():
            if i.distance((x, y)) < i.radius:
                remove(i)
Example #32
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)
Example #33
0
    def update(self, model):

        width, height = self.get_dimension()
        self._counter += 1

        all_eaten = Black_Hole.update(self, model)
        if all_eaten:
            self.change_dimension(1, 1)
            self._counter = 0

        if self._counter == Pulsator.updates:
            self.change_dimension(-1, -1)
            self._counter = 0

        if width + height == 0:
            model.remove(self)

        return all_eaten
Example #34
0
def mouse_click(x,y):
    global selection, simultons
    if selection == 'Remove': #Need to finish
        for sim in simultons.copy():
            if sim.contains( (x,y) ):
                remove(sim)
    elif selection == 'Ball':
        add( Ball(x,y,5,5,0,5) )
    elif selection == 'Floater':
        add( Floater(x,y,5,5,0,5) )
    elif selection == 'Black_Hole':
        add( Black_Hole(x,y,20,20) )
    elif selection == 'Pulsator':
        add( Pulsator(x,y,20,20) )
    elif selection == 'Hunter':
        add( Hunter(x,y,20,20,0,5) )
    elif selection == 'Special':
        add( Special(x,y,5,5,0,10) )
Example #35
0
 def update(self, m):
     self.cycles = self.cycles + 1
     goner = Black_Hole.update(self, m)
     if goner:
         self.cycles = 0
         x = len(goner)
         self.change_dimension(x, x)
     elif self.cycles == self.counter:
         #if the cycle counter reaches 30 then decrease the dimension
         #of the pulsator by -1
         y = -1
         self.change_dimension(y, y)
         #if the dimensions of the pulsator becomes 0, you must remove it
         if self.dim() == 0:
             m.remove(self)
         #reset the cycle counter once the object is removed
         self.cycles = 0
     return goner
Example #36
0
 def update(self):
     if self.radius - 1 != 0:
         something_is_eaten = Black_Hole.update(self)
         if something_is_eaten:
             self.change_dimension(1, 1)
             self.count = 0
         else:
             self.count += 1
             if self.count == Pulsator.disappear:
                 if self.radius - 1 == 0:
                     model.remove(self)
                     self.count == 0
                 else:
                     self.change_dimension(-1, -1)
                     self.count = 0
         return something_is_eaten
     else:
         model.remove(self)
Example #37
0
 def update(self, model):
     self._counter += 1
     eaten_set = Black_Hole.update(self, model)
     
     if self.get_dimension()[1] == 0:
         model.remove(self)
         self._counter = 0
         
     if len(eaten_set) != 0:
         self._counter = 0
         self.change_dimension(1, 1)
     elif self._counter == Pulsator.no_eaten_counter:
         self.change_dimension(-1, -1)
         self._counter = 0
         
     if self.get_dimension()[1] == 0:
         model.remove(self)
         self._counter = 0
     return eaten_set
 def update(self,balls):
     aset = Black_Hole.update(self,balls)
     global acount
     
     if len(aset) == 1:
         for i in aset:
             self.radius += 1
     
     if len(aset) == 0:
         acount -= 1
         if acount < 0:
             self.radius -=1
             acount = 30
             
     if self.radius < 1:
         return self.return_finished(balls)
        
             
     return aset
Example #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
Example #40
0
 def __init__(self, x, y):
     Black_Hole.__init__(self, x, y)
     self.counter = 0
Example #41
0
 def __init__(self, x, y):
     Black_Hole.__init__(self, x, y)
     self.pulsator_counter = 0
Example #42
0
 def __init__(self,x,y):
     self._counter = 0
     Black_Hole.__init__(self,x,y)
 def __init__(self,x,y,size = 30):
     Black_Hole.__init__(self,x,y)
     self.set_dimension(size, size)
     self._image = PhotoImage(Image.open('space_amoeba.gif').convert('RGBA').resize((size, size), Image.ANTIALIAS))
     self.radius = (self._image.height()/2)+((self._image.width()**2)/(8 * self._image.height()))
     self._counter = 1
Example #44
0
 def __init__(self,x,y):
     Black_Hole.__init__(self,x,y)
     self._time_starved = 0
     self._color = "GRAY"
Example #45
0
 def __init__(self, x, y):
     Black_Hole.__init__(self, x, y)
     Mobile_Simulton.__init__(self, x, y, 2*self.radius, 2*self.radius, 0, 5)
     self.randomize_angle()
     self.color = 'Orange'
     self.end_of_chain = self