Example #1
0
                if done:
                    print("Epoch %d Train Game %d get %.1f" %
                          (epoch, games_cnt, game.get_total_reward()))
                    break

            if SAVE_MODEL and games_cnt % 100 == 0:
                saver.save(SESSION, model_savefile)
                print("Saving the network weigths to:", model_savefile)

        print("\nTesting...")

        test_scores = []
        for test_step in range(EPISODES_TO_TEST):
            game.reset()
            agent.reset_cell_state()
            while not game.is_episode_finished():
                state = game.get_state()
                action = agent.act(state, train=False)
                game.make_action(action)
            test_scores.append(game.get_total_reward())

        test_scores = np.array(test_scores)

        if SAVE_MODEL:
            saveScore(test_scores)
            if test_scores.mean() > max_avgR:
                max_avgR = test_scores.mean()
                saver.save(SESSION, max_model_savefile)
'''
print("TIME TO WATCH!!")
# Reinitialize the game with window visible