(test_episodes_per_epoch, game, agent)
| 223 | |
| 224 | |
| 225 | def test(test_episodes_per_epoch, game, agent): |
| 226 | test_scores = [] |
| 227 | |
| 228 | print("\nTesting...") |
| 229 | for test_episode in trange(test_episodes_per_epoch, leave=False): |
| 230 | game.new_episode() |
| 231 | while not game.is_episode_finished(): |
| 232 | state = preprocess(game.get_state().screen_buffer) |
| 233 | best_action_index = agent.choose_action(state) |
| 234 | game.make_action(actions[best_action_index], frames_per_action) |
| 235 | |
| 236 | r = game.get_total_reward() |
| 237 | test_scores.append(r) |
| 238 | |
| 239 | test_scores = np.array(test_scores) |
| 240 | print( |
| 241 | f"Results: mean: {test_scores.mean():.1f}±{test_scores.std():.1f},", |
| 242 | "min: %.1f" % test_scores.min(), |
| 243 | "max: %.1f" % test_scores.max(), |
| 244 | ) |
| 245 | |
| 246 | |
| 247 | class DQN(Model): |
no test coverage detected