def __init__(self, win): self.ep = 0 self.ga = 2 self.al = 2 self.step_count = 0 self.__init_gui(win) if robot_type == 'crawler': self.robot = crawler.CrawlingRobot(self.canvas) self.robot_environment = crawler.CrawlingRobotEnvironment( self.robot) else: raise ValueError("Unknown RobotType") # Init Agent actionFn = lambda state: self.robot_environment.get_possible_actions( state) self.learner = agents_q_learning.QLearningAgent(actionFn=actionFn) self.learner.set_epsilon(self.epsilon) self.learner.set_learning_rate(self.alpha) self.learner.set_discount(self.gamma) # Start GUI self.running = True self.stopped = False self.steps_to_skip = 0 self.thread = threading.Thread(target=self.run) self.thread.start()
def __init__(self, win): self.ep = 0 self.ga = 2 self.al = 2 self.stepCount = 0 # Init Gui self.__initGUI(win) # Init environment if robotType == 'crawler': self.robot = crawler.CrawlingRobot(self.canvas) self.robotEnvironment = crawler.CrawlingRobotEnvironment( self.robot) elif robotType == 'pendulum': self.robot = pendulum.PendulumRobot(self.canvas) self.robotEnvironment = \ pendulum.PendulumRobotEnvironment(self.robot) else: raise ValueError('Unknown RobotType') # Init Agent def simulationFn(agent): return \ simulation.SimulationEnvironment(self.robotEnvironment, agent) def actionFn(state): return \ self.robotEnvironment.getPossibleActions(state) self.learner = qlearningAgents.QLearningAgent(actionFn=actionFn) self.learner.setEpsilon(self.epsilon) self.learner.setLearningRate(self.alpha) self.learner.setDiscount(self.gamma) # Start GUI self.running = True self.stopped = False self.stepsToSkip = 0 self.thread = threading.Thread(target=self.run) self.thread.start()
def __init__(self, win): self.ep = 0 self.ga = 2 self.al = 2 self.step_count = 0 ## Init Gui self.__init_gui(win) # Init environment if robot_type == 'crawler': self.robot = crawler.CrawlingRobot(self.canvas) self.robot_environment = crawler.CrawlingRobotEnvironment( self.robot) elif robot_type == 'pendulum': self.robot = pendulum.PendulumRobot(self.canvas) self.robot_environment = \ pendulum.PendulumRobotEnvironment(self.robot) else: raise Exception("Unknown RobotType") # Init Agent simulation_fn = lambda agent: \ simulation.SimulationEnvironment(self.robot_environment, agent) action_fn = lambda state: \ self.robot_environment.get_possible_actions(state) self.learner = q_learning_agents.QLearningAgent(action_fn=action_fn) self.learner.set_epsilon(self.epsilon) self.learner.set_learning_rate(self.alpha) self.learner.set_discount(self.gamma) # Start GUI self.running = True self.stopped = False self.steps_to_skip = 0 self.thread = threading.Thread(target=self.run) self.thread.start()
def __init__(self, win): self.ep = 0 self.ga = 2 self.al = 2 self.stepCount = 0 ## Init Gui self.__initGUI(win) # Init environment if robotType == 'crawler': self.robot = crawler.CrawlingRobot(self.canvas) self.robotEnvironment = crawler.CrawlingRobotEnvironment( self.robot) #elif robotType == 'pendulum': # self.robot = pendulum.PendulumRobot(self.canvas) # self.robotEnvironment = \ # pendulum.PendulumRobotEnvironment(self.robot) else: raise Exception("Unknown RobotType") # Init Agent #simulationFn = lambda agent: \ # simulation.SimulationEnvironment(self.robotEnvironment,agent) actionFn = lambda state: \ self.robotEnvironment.getPossibleActions(state) self.learner = qlearningAgents.QLearningAgent(actionFn=actionFn) self.learner.setEpsilon(self.epsilon) self.learner.setLearningRate(self.alpha) self.learner.setDiscount(self.gamma) # Start GUI self.running = True self.stopped = False self.stepsToSkip = 0 self.thread = threading.Thread(target=self.run) self.thread.start()
def __init__(self, win): self.epsilon = 0.1 self.gamma = 0.8 self.alpha = 0.9 self.average_reward = 0 ## Init Gui self.__initGUI(win) # Init environment if robotType == 'crawler': self.robot = crawler.CrawlingRobot(self.canvas) self.robotEnvironment = crawler.CrawlingRobotEnvironment(self.robot) elif robotType == 'pendulum': self.robot = pendulum.PendulumRobot(self.canvas) self.robotEnvironment = \ pendulum.PendulumRobotEnvironment(self.robot) else: raise "Unknown RobotType" # Init Agent self.learner = agent.QLearningAgent(self.robotEnvironment.getPossibleActions) self.learner.setEpsilon(self.epsilon) self.learner.setLearningRate(self.alpha) self.learner.setDiscount(self.gamma) # Start GUI self.running = True self.stopped = False self.stepsToSkip = 0 self.thread = threading.Thread(target=self.run) self.thread.start()