def setup_atari_env():
    # create Atari environment
    max_num_frames = 500000
    if game == 'pitfall':
        max_num_frames = 72000
    env = atari.AtariEnvironment(game_dir + '/' + game + '.bin', use_gui=True, max_num_frames=max_num_frames)
    num_actions = len(env.ale.getMinimalActionSet())
    return env, num_actions
Beispiel #2
0
def setup_atari_env():
    # create Atari environment
    env = atari.AtariEnvironment(game_dir + '/' + game + '.bin')
    num_actions = len(env.ale.getMinimalActionSet())
    return env, num_actions
import copy
import os
game_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        '../roms/')
game = 'montezuma_revenge'

bitKeysMap = [
    0, 1, 2, 10, 3, 11, 6, 14, 4, 12, 7, 15, -1, -1, -1, -1, 5, 13, -1, -1, 8,
    16, -1, -1, 9, 17, -1, -1, -1, -1, -1, -1
]

if __name__ == "__main__":
    abstraction_tree = ma.abstraction_tree
    # create Atari environment
    env = atari.AtariEnvironment(game_dir + '/' + game + '.bin',
                                 frame_skip=4,
                                 abstraction_tree=abstraction_tree,
                                 terminate_on_end_life=True)
    abstraction_tree.setEnv(env)
    abs_vec_func = ma.montezuma_abstraction_vector
    abs_size = 35 + 9
    num_actions = len(env.ale.getMinimalActionSet())
    dqn = l0_learner.MultiHeadedDQLearner(abs_size,
                                          len(env.get_actions_for_state(None)),
                                          1)
    dqn.saver.restore(dqn.sess, './mr_net')
    l1_state = abstraction_tree.get_abstract_state()
    print ma.abstraction_tree.get_agent_sector()
    right = False
    left = False
    up = False
    down = False
Beispiel #4
0
bitKeysMap = [
    0, 1, 2, 10, 3, 11, 6, 14, 4, 12, 7, 15, -1, -1, -1, -1, 5, 13, -1, -1, 8,
    16, -1, -1, 9, 17, -1, -1, -1, -1, -1, -1
]


def get_bit(a, i):
    return a & (2**i) != 0


if __name__ == "__main__":
    # create Atari environment
    env = atari.AtariEnvironment(game_dir + '/' + game + '.bin',
                                 frame_skip=1,
                                 terminate_on_end_life=True,
                                 use_gui=True,
                                 max_num_frames=72000)
    abstraction = mr_abstraction_ram.MRAbstraction(env, use_sectors=True)
    abstraction = venture_abstraction.VentureAbstraction(env, use_sectors=True)
    # abstraction = pitfall_abstraction.PitfallAbstraction(env, use_sectors=True)
    # env = mr_environment.MREnvironment(game_dir + '/' + game + '.bin', frame_skip=1, terminate_on_end_life=True, use_gui=True)
    # abstraction = hero_abstraction.HeroAbstraction(env, use_sectors=True)
    num_actions = len(env.ale.getMinimalActionSet())
    if abstraction is not None:
        abstraction.update_state(env.getRAM())
        abstraction.env = env
        env.abstraction = abstraction
        l1_state = abstraction.oo_abstraction_function(None)

    right = False