def __init__(self, canvas_size=600, cell_size=10): CellWorld.__init__(self, canvas_size, cell_size) self.title('GIS Modeling and Problem Solving Final Project- Shaky Sherpa') # the interpreter executes user-provided code self.inter = Interpreter(self, globals()) self.setup()
def __init__(self, canvas_size=600, cell_size=5): CellWorld.__init__(self, canvas_size, cell_size) self.title('TurmiteWorld') # the interpreter executes user-provided code self.inter = Interpreter(self, globals()) self.setup()
# these are functions that perfrom the vector operations def vadd(p1, p2): """Adds vectors p1 and p2 (returns a new vector).""" return [x+y for x,y in zip(p1, p2)] def vscale(p, s): """Multiplies p by a scalar (returns a new vector).""" return [x*s for x in p] def vmid(p1, p2): """Returns a new vector that is the pointwise average of p1 and p2.""" return vscale(vadd(p1, p2), 0.5) def rotate(v, n=1): """Rotates the elements of a sequence by (n) places. Returns a new list. """ n %= len(v) return v[n:] + v[:n] if __name__ == '__main__': world = CellWorld(interactive=True) world.bind() world.mainloop() world = AntWorld() world.mainloop()