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)
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
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
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')
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
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))
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)
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
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)
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
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)
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')
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
def __init__(self, x, y, width = 20, height = 20): Simulton.__init__(self, x, y, width, height) self._color = "black"
def __init__(self, x, y): Simulton.__init__(self, x, y, 20, 20)
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'
def __init__(self, x, y): Simulton.__init__(self, x, y, Static_simulton.radius * 2, Static_simulton.radius * 2) self.find = False
def __init__(self,x,y): Simulton.__init__(self,x,y,2*Black_Hole.radius,2*Black_Hole.radius)
def __contains__(self, item): return self.distance((Simulton.get_location(item))) < Black_Hole.radius
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))
def __init__(self, x, y): Simulton.__init__(self,x,y,self.radius*2, self.radius*2)
def __init__(self, x, y, width, height, angle, speed): Simulton.__init__(self, x, y, width, height) self._angle = angle self._speed = speed
def __init__(self, x, y): Simulton.__init__(self, x, y, 20, 20) self._color = 'black' self.counter = 30
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()))
def contains(self, item): return Simulton.distance(self, (item._x, item._y)) < self._width
def contains(self, prey): return Simulton.contains(self, prey.get_location())
def __init__(self, x, y, r, c): self.radius = r self.color = c Simulton.__init__(self, x, y, 2*self.radius, 2*self.radius)
def __init__(self,x,y): Simulton.__init__(self,x,y,20,20) self._color = "BLACK"
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)
def shrink(self): Simulton.set_dimension(self, self.coory[0] - 5, self.coory[1] - 5)
def __init__(self,x,y,width,height,angle,speed): Simulton.__init__(self,x,y,width,height) self._angle = angle self._speed = speed
def __init__(self, x, y): black_hole_radius = 2 * Black_Hole.radius Simulton.__init__(self, x, y, black_hole_radius, black_hole_radius)
def __init__(self, x, y): Simulton.__init__(self, x, y, Black_Hole.radius * 2, Black_Hole.radius*2)
def __init__(self, x, y): self.radius = 10 self.color = 'black' Simulton.__init__(self, x, y, self.radius * 2, self.radius * 2)
def contains(self, coords): cor = Simulton.get_dimension(self) return math.hypot(coords[0]-self._x, coords[1]-self._y) < (cor[0]/2)
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
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()
def __init__(self, x, y): Simulton.__init__(self, x, y, Black_Hole.radiusc * 2, Black_Hole.radiusc * 2)
def __init__(self, x, y, width=20, height=20): Simulton.__init__(self, x, y, width, height)