def update(self,cart): """ update the gui drawing the cart. wait if to maintain the required framerate. """ self._draw(cart) gui.tick(self.frameRate)
def update(self, cart): """ update the gui drawing the cart. wait if to maintain the required framerate. """ self._draw(cart) gui.tick(self.frameRate)
force_scale = 10.0 sizes = [2, 1] net = brain.loadBrain() INIT_ANG = 0.3 cart.setAngle(math.pi + INIT_ANG) while not gui.check_for_quit(): # loop until user hits escape # Test for falling over # if fallen then reset with a random angle input = copy.deepcopy(cart.getState()) input[0] = input[0] - math.pi out = net.ffwd(input) force = (out[0] - 0.5) * force_scale # step the car for a single GUI frame cart.step(force, dt) # draw the cart and display info draw(screen, cart, force) # slow the gui down to the given frameRate gui.tick(frameRate)
net.setWeights(guess) time=0; input = copy.deepcopy(cart.getState()) input[0]=input[0]-math.pi out=net.ffwd(input) force=(out[0]-0.5)*force_scale # step the car for a single GUI frame cart.step(force,dt) time+=dt tot_time+=dt fit=time-cart.getX() ################ RESET CODE ############################## ############################################################ if graphics: # draw the cart and display info draw(screen,cart,force) # slow the gui down to the given frameRate gui.tick(frameRate)