diff options
author | Florian Jung <flo@windfisch.org> | 2016-01-08 18:06:40 +0100 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2016-01-08 18:06:40 +0100 |
commit | 63a2121abe15a5d7e08d7e7a8f92fdbfbe3b5987 (patch) | |
tree | 3614633849cd165c87de8025457c1d40bd79a806 | |
parent | 1764333ee1923cbb56f05a907c03a19308caea45 (diff) |
--sleep flag
-rw-r--r-- | sol.py | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -73,6 +73,7 @@ if arg['-h']: " default: array" + " --frameskip NUM # frameskip for visualisation\n" + " # default: %f\n" % frameskip + + " --sleep # sleep after every <frameskip> frames\n"+ " --quiet # disable visualisation\n" + " --file FILE # output file for q learning") exit() @@ -81,6 +82,10 @@ if arg['-h']: if arg['-q'] or arg['--quiet']: visu = False +do_sleep = False +if arg['--sleep']: + do_sleep = True + if arg['--frameskip']: frameskip = int(arg['--frameskip']) @@ -350,8 +355,19 @@ else: i=0 stopstate = -1 total_reward = 0. +maxdiff = -1 for i in range(n_episodes): + if (i % (frameskip+1) == 0): + print("iteration %.3d, alpha=%.3e, epsilon=%.3e maxdiff=%.7f"%(i,Q.alpha,epsilon,maxdiff)) + n = 0 + if visu: + n = visualize(maze,Q) + cursor_up(n+2) + + if do_sleep: + input() + s = start for j in range(100): # epsilon-greedy @@ -373,13 +389,6 @@ for i in range(n_episodes): break maxdiff = Q.episode() - if (i % (frameskip+1) == 0): - print("iteration %.3d, alpha=%.3e, epsilon=%.3e maxdiff=%.7f"%(i,Q.alpha,epsilon,maxdiff)) - n = 0 - if visu: - n = visualize(maze,Q) - cursor_up(n+2) - if (logfile != None): print("%d\t%f" % (i, total_reward), file=logfile) |