def __init__(self, state, xy: (int, int), bearing: float, color, brain=None): """ Creates a germ given the canvas on which to create it, the coordinates, color, and initial velocity. state - the world state. xy - coordinates; location of the germ. To prevent sticking, must be between 0 and bounding area, _exclusively_. color - a tkinter-viable color (can be hex) """ # The tag in tkinter representing all parts of this germ. Appended "str" to the front b/c tags don't work if they don't contain letters for some reason. self.tag = "str" + str(id(self)) # 'Adopts' the canvas, and then creates itself on the canvas with the color given. # Then moves itself to the given xy coordinate. self.state = state self.canvas = state.canvas self.brain = Brain.from_random() if not brain else brain self.bearing = bearing self.body = self.canvas.create_oval(0, 0, 11, 11, fill=color, tags="germ") self.canvas.move(self.body, *xy) self.color = color # Saving this mostly just for debugging purposes.