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)
示例#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
示例#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
示例#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')
示例#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
示例#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))
示例#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)
示例#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
示例#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)
示例#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
示例#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)
示例#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')
示例#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
示例#15
0
 def __init__(self, x, y, width = 20, height = 20):
     Simulton.__init__(self, x, y, width, height)
     self._color = "black"
示例#16
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, 20, 20)
示例#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)
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, self.radius * 2, self.radius * 2)
     self._color = 'black'
示例#19
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, Static_simulton.radius * 2,
                       Static_simulton.radius * 2)
     self.find = False
示例#20
0
 def __init__(self,x,y):   
     Simulton.__init__(self,x,y,2*Black_Hole.radius,2*Black_Hole.radius)
示例#21
0
 def __contains__(self, item):
     return self.distance((Simulton.get_location(item))) < Black_Hole.radius
示例#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()
 def contains(self,xy, search):
     #return ((((xy[0]-self._x)**2) + ((xy[1]-self._y)**2)) <= 25)
     return (Simulton.distance(self, xy) <= (search))
示例#24
0
 def __init__(self, x, y):
     Simulton.__init__(self,x,y,self.radius*2, self.radius*2) 
示例#25
0
 def __init__(self, x, y, width, height, angle, speed):
     Simulton.__init__(self, x, y, width, height)
     self._angle = angle
     self._speed = speed
示例#26
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, 20, 20)
     self._color = 'black'
     self.counter = 30
示例#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()))
示例#29
0
 def contains(self, item):
     return Simulton.distance(self, (item._x, item._y)) < self._width
示例#30
0
 def contains(self, prey):
     return Simulton.contains(self, prey.get_location())
示例#31
0
文件: circle.py 项目: solomc1/python
 def __init__(self, x, y, r, c):
     self.radius = r
     self.color = c
     Simulton.__init__(self, x, y, 2*self.radius, 2*self.radius)
示例#32
0
 def __init__(self,x,y):
     Simulton.__init__(self,x,y,20,20)
     self._color = "BLACK"
示例#33
0
 def __init__(self,x,y):
     Simulton.__init__(self, x, y, width=self.radius*2,height=self.radius*2)
 def __init__(self, x, y):
     self._truth = 0
     Simulton.__init__(self, x, y, 20, 20)
示例#35
0
 def shrink(self):
     Simulton.set_dimension(self, self.coory[0] - 5, self.coory[1] - 5)
示例#36
0
 def __init__(self,x,y,width,height,angle,speed):
     Simulton.__init__(self,x,y,width,height)
     self._angle = angle
     self._speed = speed
示例#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)
示例#38
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, Black_Hole.radius * 2, Black_Hole.radius*2)
示例#39
0
 def __init__(self, x, y):
     self.radius = 10
     self.color = 'black'
     Simulton.__init__(self, x, y, self.radius * 2, self.radius * 2)
示例#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)
示例#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
 def contains(self, xy):
     return Simulton.distance(self, xy) < Black_Hole.radius
示例#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()
示例#44
0
 def __init__(self, x, y):
     Simulton.__init__(self, x, y, Black_Hole.radiusc * 2,
                       Black_Hole.radiusc * 2)
示例#45
0
 def __init__(self, x, y, width=20, height=20):
     Simulton.__init__(self, x, y, width, height)