Esempio n. 1
0
            state = doom.get_current_state()
            action_index = doomguy.act(state)
            next_state, reward, done = doom.step(action_index)
            doomguy.remember(state, action_index, reward, next_state, done)

            step += 1

        loss = doomguy.train()
        doomguy.reset_memory()
        print('Total steps: {}, loss was: {}'.format(step, loss))

if show_results:
    doom = VizdoomWrapper(config_path=config_path,
                          reward_table=reward_table,
                          frame_resolution=resolution,
                          show_mode=True,
                          frame_stack=4)
    for episode in range(3):
        doom.new_game()
        done = False

        while not done:
            state = doom.get_current_state()
            action_index = doomguy.act(state)
            done = doom.set_action(action_index)

        # Sleep between episodes
        sleep(1.0)
        score = doom.get_total_reward()
        print('Total score: {}'.format(score))
Esempio n. 2
0
episodes_to_watch = 2

print('Initialising VizDoom...')
config_path = 'scenarios/basic.cfg'
actor_path = 'models/defend_the_center_actor.hd5'
critic_path = 'models/defend_the_center_critic.hd5'
reward_table = OrderedDict({'FRAGCOUNT': 1})
resolution = (90, 60)
doom = VizdoomWrapper(config_path=config_path,
                      reward_table=reward_table,
                      frame_resolution=resolution,
                      show_mode=True,
                      frame_stack=1)

print('Initialising Doomguy...')
doomguy = BaseQDoom(doom.get_state_size(), doom.get_action_size())
doomguy.load_model()

for _ in range(episodes_to_watch):
    done = False
    doom.new_game()
    while not done:
        state = doom.get_current_state()
        best_action = doomguy.act(state)
        done = doom.set_action(best_action)

    # Sleep between episodes
    sleep(1.0)
    score = doom.get_total_reward()
    print('Total score: {}'.format(score))