コード例 #1
0
def load_dict_from_unknown_filetype(filepath):
    try:
        # json.load
        return load_from_json(filepath)
    except:
        # eval of str from file
        return load_dict_from_file(filepath)
コード例 #2
0
def setup_game(run_type, run_dir, run_seed, agent_num, player_idx):
    if run_type == "ppo":
        print("Seed", run_seed)
        agent, config = get_ppo_agent(run_dir, run_seed, best=True)
    elif run_type == "pbt":
        run_path = "data/" + run_type + "_runs/" + run_dir + "/seed_{}".format(
            run_seed)
        config = load_dict_from_file(run_path + "/config.txt")

        agent_path = run_path + '/agent' + str(agent_num) + "/best"
        agent = get_agent_from_saved_model(agent_path, config["sim_threads"])
    elif run_type == "bc":
        agent, config = get_bc_agent_from_saved(run_dir)
    else:
        raise ValueError("Unrecognized run type")

    env = OvercookedEnv(
        OvercookedGridworld.from_layout_name(**config["mdp_params"]),
        **config["env_params"])
    return env, agent, player_idx
コード例 #3
0
 def from_dir(load_folder):
     logs = load_dict_from_file(load_folder + "logs")
     agent_name = logs["agent_name"]
     params = load_dict_from_file(load_folder + "params")
     model = load_baselines_model(load_folder, agent_name)
     return PBTAgent(agent_name, params, start_logs=logs, model=model)
コード例 #4
0
ファイル: __init__.py プロジェクト: ying-wen/overcooked_ai
def read_layout_dict(layout_name):
    return load_dict_from_file(
        os.path.join(LAYOUTS_DIR, layout_name + ".layout"))