def __init__(self, x, y):
     self._new_x = x
     self._new_y = y
     new_x = 2 * Black_Hole.radius_constant
     new_y = 2 * Black_Hole.radius_constant
     # Simulton.__init__(self,x,y, new_x, new_y)
     Simulton.__init__(self, x, y, new_x, new_y)
Ejemplo n.º 2
0
 def __init__(self, x, y, width, height, color):
     
     Simulton.__init__(self, x, y, width, height)
     
     self._x = x
     self._y = y
     self._width = width * 2
     self._height = height * 2
     self._color = color
Ejemplo n.º 3
0
 def __init__(self, x, y, angle, speed):
     Simulton.__init__(self, x, y, Mobile_simulton.radius, Mobile_simulton.
                       radius)  #####how large are these robots, need to dis
     self._angle = angle
     self._speed = speed
     self._back_counter_left = 0
     self._back_counter_right = 0
     self._back_counter_top = 0
     self._back_counter_bottom = 0
Ejemplo n.º 4
0
 def display(self, canvas):
     (x, y) = Simulton.get_location(self)
     canvas.create_oval(x - self.radius,
                        y - self.radius,
                        x + self.radius,
                        y + self.radius,
                        fill='Black')
Ejemplo n.º 5
0
 def update(self, objs):
     inset = set()
     for i in objs:
         (x, y) = Simulton.get_location(i)
         if self.contains((x, y)) and isinstance(i, Mortal):
             inset.add(i)
     return inset
Ejemplo n.º 6
0
def mouse_click(x, y):
    new_simulton = set(simultons)
    if clicked == 'Remove':
        for s in new_simulton:
            d = s.get_location()
            if Simulton.contains(s, (x, y)):
                remove(s)
    else:
        simultons.add(eval(clicked)(x, y))
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
def mouse_click(x, y):
    if selected != "Remove" and selected != None:
        add(eval(selected)(x, y))
    else:
        if selected == "Remove":
            for s in set(simultons):
                if Simulton.contains(s, (x, y)):
                    remove(s)
                    break
Ejemplo n.º 9
0
 def __init__(self, x, y, host=None, inher=0):
     self.host = host
     self.counter = 0
     self.reproduce_counter = 0
     self.reproduced = True
     self.lifespan = random.randrange(100, 600)
     self.genes = inher if inher else self.generate_binary_num(4)
     self.effect_on_init()
     temp = self.count_1_bits(self.genes)
     if temp:
         self.color = '#' + '{:0<6}'.format(
             hex(
                 sum(
                     int(
                         Special.color[Special.map[((self.genes >> i) % 2) *
                                                   (i + 1)]], 16) // temp
                     for i in range(Special.gene_number)))[2:])
     else:
         self.color = 'white'
     Simulton.__init__(self, x, y, Special.radius * 2, Special.radius * 2)
Ejemplo n.º 10
0
 def update(self, model):
     allPrey = model.find(lambda x: isinstance(x, Prey))
     w, h = self.get_dimension()
     for prey in allPrey:
         if self.distance(
             (Simulton.get_location(prey))) < w / 2:  # width == height
             model.controller.the_canvas.delete(prey)
             model.sim.remove(prey)
             self.eatenSet.add(prey)
             self.eaten += 1
     return self.eatenSet
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
 def display(self, canvas):
     cor = Simulton.get_dimension(self)
     canvas.create_oval(self._x-(cor[0]/2), self._y-(cor[1]/2),
                             self._x+(cor[0]/2), self._y+(cor[1]/2),
                             fill='black')
Ejemplo n.º 13
0
 def __init__(self, x, y):
     self.radius = 30
     self._x = x
     self._y = y
     Simulton.__init__(self, x, y, self._width, self._height)
     self._color = 'black'
 def __init__(self,x,y):
     self._image = PhotoImage(Image.open('bigbang.gif').convert('RGBA').resize((20, 20), Image.ANTIALIAS))
     Simulton.__init__(self,x,y,self._image.width(),self._image.height())
     self._center = (int(x),int(y))
     self._explosion = 500
Ejemplo n.º 15
0
 def __init__(self, x, y, width = 20, height = 20):
     Simulton.__init__(self, x, y, width, height)
     self._color = "black"
Ejemplo n.º 16
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, 20, 20)
Ejemplo n.º 17
0
 def __init__(self, x, y, width=0, height=0):
     Simulton.__init__(self, x, y, width, height)
     self.radius = 10
     self.set_dimension(self.radius * 2, self.radius * 2)
Ejemplo n.º 18
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, self.radius * 2, self.radius * 2)
     self._color = 'black'
Ejemplo n.º 19
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, Static_simulton.radius * 2,
                       Static_simulton.radius * 2)
     self.find = False
Ejemplo n.º 20
0
 def __init__(self,x,y):   
     Simulton.__init__(self,x,y,2*Black_Hole.radius,2*Black_Hole.radius)
Ejemplo n.º 21
0
 def __contains__(self, item):
     return self.distance((Simulton.get_location(item))) < Black_Hole.radius
Ejemplo n.º 22
0
 def __init__(self, x, y):
     Simulton.set_dimension(self, 20, 20)
     w, h = Simulton.get_dimension(self)
     Simulton.__init__(self, x, y, w, h)
     self.eaten = 0
     self.eatenSet = set()
Ejemplo n.º 23
0
 def contains(self,xy, search):
     #return ((((xy[0]-self._x)**2) + ((xy[1]-self._y)**2)) <= 25)
     return (Simulton.distance(self, xy) <= (search))
Ejemplo n.º 24
0
 def __init__(self, x, y):
     Simulton.__init__(self,x,y,self.radius*2, self.radius*2) 
Ejemplo n.º 25
0
 def __init__(self, x, y, width, height, angle, speed):
     Simulton.__init__(self, x, y, width, height)
     self._angle = angle
     self._speed = speed
Ejemplo n.º 26
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, 20, 20)
     self._color = 'black'
     self.counter = 30
Ejemplo n.º 27
0
 def __init__(self, x, y):
     Simulton.__init__(self,
                       x,
                       y,
                       width=Black_Hole.radius,
                       height=Black_Hole.radius)
 def __init__(self,x,y):
     self._image = PhotoImage(file='Black_Hole.gif')
     Simulton.__init__(self,x,y,self._image.width(),self._image.height())
     self.radius = (self._image.height()/2)+((self._image.width()**2)/(8 * self._image.height()))
Ejemplo n.º 29
0
 def contains(self, item):
     return Simulton.distance(self, (item._x, item._y)) < self._width
Ejemplo n.º 30
0
 def contains(self, prey):
     return Simulton.contains(self, prey.get_location())
Ejemplo n.º 31
0
 def __init__(self, x, y, r, c):
     self.radius = r
     self.color = c
     Simulton.__init__(self, x, y, 2*self.radius, 2*self.radius)
Ejemplo n.º 32
0
 def __init__(self,x,y):
     Simulton.__init__(self,x,y,20,20)
     self._color = "BLACK"
Ejemplo n.º 33
0
 def __init__(self,x,y):
     Simulton.__init__(self, x, y, width=self.radius*2,height=self.radius*2)
Ejemplo n.º 34
0
 def __init__(self, x, y):
     self._truth = 0
     Simulton.__init__(self, x, y, 20, 20)
Ejemplo n.º 35
0
 def shrink(self):
     Simulton.set_dimension(self, self.coory[0] - 5, self.coory[1] - 5)
Ejemplo n.º 36
0
 def __init__(self,x,y,width,height,angle,speed):
     Simulton.__init__(self,x,y,width,height)
     self._angle = angle
     self._speed = speed
Ejemplo n.º 37
0
 def __init__(self, x, y):
     black_hole_radius = 2 * Black_Hole.radius
     Simulton.__init__(self, x, y, black_hole_radius, black_hole_radius)
Ejemplo n.º 38
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, Black_Hole.radius * 2, Black_Hole.radius*2)
Ejemplo n.º 39
0
 def __init__(self, x, y):
     self.radius = 10
     self.color = 'black'
     Simulton.__init__(self, x, y, self.radius * 2, self.radius * 2)
Ejemplo n.º 40
0
 def contains(self, coords):
     cor = Simulton.get_dimension(self)
     return math.hypot(coords[0]-self._x, coords[1]-self._y) < (cor[0]/2)
Ejemplo n.º 41
0
 def __init__(self,x,y):
     Simulton.__init__(self,x,y, 2*Black_Hole.radius, 2*Black_Hole.radius)
     self._color = Black_Hole.color
Ejemplo n.º 42
0
 def contains(self, xy):
     return Simulton.distance(self, xy) < Black_Hole.radius
Ejemplo n.º 43
0
 def __init__(self, x, y):
     self._radius = 10
     Simulton.__init__(self, x, y, self._radius * 2, self._radius * 2)
     self._width, self._height = self.get_dimension()
Ejemplo n.º 44
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, Black_Hole.radiusc * 2,
                       Black_Hole.radiusc * 2)
Ejemplo n.º 45
0
 def __init__(self, x, y, width=20, height=20):
     Simulton.__init__(self, x, y, width, height)