(model, eps, gamma)
| 78 | |
| 79 | |
| 80 | def play_one(model, eps, gamma): |
| 81 | observation = env.reset() |
| 82 | done = False |
| 83 | totalreward = 0 |
| 84 | iters = 0 |
| 85 | while not done and iters < 10000: |
| 86 | action = model.sample_action(observation, eps) |
| 87 | prev_observation = observation |
| 88 | observation, reward, done, info = env.step(action) |
| 89 | |
| 90 | totalreward += reward |
| 91 | |
| 92 | if done and iters < 199: |
| 93 | reward = -300 |
| 94 | |
| 95 | # update the model |
| 96 | G = reward + gamma*np.max(model.predict(observation)) |
| 97 | model.update(prev_observation, action, G) |
| 98 | |
| 99 | iters += 1 |
| 100 | |
| 101 | return totalreward |
| 102 | |
| 103 | |
| 104 | def plot_running_avg(totalrewards): |
no test coverage detected