Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import logging
  2. import gym
  3. from agents.SimulatedAnnealing import SimulatedAnnealingAgent
  4.  
  5.  
  6. def main():
  7. logger = logging.getLogger()
  8. logger.setLevel(logging.DEBUG)
  9.  
  10. env = gym.make('Acrobot-v0')
  11.  
  12. agent = SimulatedAnnealingAgent(env.action_space, decay=0.8, alpha=3)
  13. upload = True # Sets whether to upload to OpenAI
  14.  
  15. outdir = '/tmp/' + agent.name + '-results'
  16. env.monitor.start(outdir, force=True)
  17.  
  18. episode_count = 1000
  19.  
  20. for i in xrange(episode_count):
  21. ob = env.reset()
  22. done = False
  23. reward = 0
  24.  
  25. while not done:
  26. action = agent.act(ob, reward, done)
  27. ob, reward, done, _ = env.step(action)
  28.  
  29. agent.act(ob, reward, done) # Final push required so agent receives notification that episode is done and can update model
  30.  
  31. # Dump result info to disk
  32. env.monitor.close()
  33.  
  34. if __name__ == '__main__':
  35. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement