MCPcopy Create free account
hub / github.com/Farama-Foundation/ViZDoom / test

Function test

examples/python/learning_pytorch.py:80–101  ·  view source on GitHub ↗

Runs a test_episodes_per_epoch episodes and prints the result

(game, agent)

Source from the content-addressed store, hash-verified

78
79
80def test(game, agent):
81 """Runs a test_episodes_per_epoch episodes and prints the result"""
82 print("\nTesting...")
83 test_scores = []
84 for test_episode in trange(test_episodes_per_epoch, leave=False):
85 game.new_episode()
86 while not game.is_episode_finished():
87 state = preprocess(game.get_state().screen_buffer)
88 best_action_index = agent.get_action(state)
89
90 game.make_action(actions[best_action_index], frame_repeat)
91 r = game.get_total_reward()
92 test_scores.append(r)
93
94 test_scores = np.array(test_scores)
95 print(
96 "Results: mean: {:.1f} +/- {:.1f},".format(
97 test_scores.mean(), test_scores.std()
98 ),
99 "min: %.1f" % test_scores.min(),
100 "max: %.1f" % test_scores.max(),
101 )
102
103
104def run(game, agent, actions, num_epochs, frame_repeat, steps_per_epoch=2000):

Callers 1

runFunction · 0.70

Calls 2

get_actionMethod · 0.80
preprocessFunction · 0.70

Tested by

no test coverage detected