diff options
-rw-r--r-- | sol.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -212,14 +212,18 @@ class QArray: def __init__(self): self.Q = [ [ [0. for k in range(4)] for i in range(a.xlen) ] for j in range(a.ylen) ] + # calculates Q(x,y) def eval(self,x,y = None): if y==None: x,y = x return self.Q[y][x] + def change(self, s, action, diff): self.Q[s[1]][s[0]][action] += diff + def episode(self): + pass # implements the Q function not through an array, but through a neuronal network instead. class QNN: @@ -250,6 +254,9 @@ class QNN: self.NN.train(list(s), [x/10. for x in newval]) + def episode(self): + pass + a = World(maze, start) Q = None @@ -283,6 +290,7 @@ for i in range(1000000): s = ss if a.is_final(ss): break + Q.episode() if (i % (frameskip+1) == 0): print("iteration %.3d, alpha=%.3e, epsilon=%.3e maxdiff=%.7f"%(i,alpha,epsilon,maxdiff)) |