MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / play_one

Function play_one

rl2/mountaincar/pg_tf_random.py:178–194  ·  view source on GitHub ↗
(env, pmodel, gamma)

Source from the content-addressed store, hash-verified

176
177
178def play_one(env, pmodel, gamma):
179 observation = env.reset()
180 done = False
181 totalreward = 0
182 iters = 0
183
184 while not done and iters < 2000:
185 # if we reach 2000, just quit, don't want this going forever
186 # the 200 limit seems a bit early
187 action = pmodel.sample_action(observation)
188 # oddly, the mountain car environment requires the action to be in
189 # an object where the actual action is stored in object[0]
190 observation, reward, done, info = env.step([action])
191
192 totalreward += reward
193 iters += 1
194 return totalreward
195
196
197def play_multiple_episodes(env, T, pmodel, gamma, print_iters=False):

Callers 1

play_multiple_episodesFunction · 0.70

Calls 3

resetMethod · 0.45
sample_actionMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected