MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / play_one

Function play_one

rl2/mountaincar/td_lambda.py:78–98  ·  view source on GitHub ↗
(model, env, eps, gamma, lambda_)

Source from the content-addressed store, hash-verified

76
77# returns a list of states_and_rewards, and the total reward
78def play_one(model, env, eps, gamma, lambda_):
79 observation = env.reset()
80 done = False
81 totalreward = 0
82 iters = 0
83 # while not done and iters < 200:
84 while not done and iters < 10000:
85 action = model.sample_action(observation, eps)
86 prev_observation = observation
87 observation, reward, done, info = env.step(action)
88
89 # update the model
90 Qnext = model.predict(observation)
91 assert(Qnext.shape == (1, env.action_space.n))
92 G = reward + gamma*np.max(Qnext[0])
93 model.update(prev_observation, action, G, gamma, lambda_)
94
95 totalreward += reward
96 iters += 1
97
98 return totalreward
99
100
101if __name__ == '__main__':

Callers 1

td_lambda.pyFile · 0.70

Calls 5

resetMethod · 0.45
sample_actionMethod · 0.45
stepMethod · 0.45
predictMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected