openai / procgen

Procgen Benchmark: Procedurally-Generated Game-Like Gym-Environments
https://openai.com/blog/procgen-benchmark/
MIT License
1.01k stars 209 forks source link

Which level is being played in a specific Procgen game #36

Closed hfeniser closed 4 years ago

hfeniser commented 4 years ago

Does the current Procgen environment provide the function to learn which game level is being played ?

Currently, I am planning to learn it by looking at the "observation" returned by the environment at the beginning of the game.

christopherhesse commented 4 years ago

You can view the current level seed in the info dictionary, is that what you mean?

hfeniser commented 4 years ago

Here is an example scenario: I set env_name to starpilot, distribution_mode to hard, num_levels to 2 and start_level to 0 and start watching my trained agent to play the game with the code piece below:

    env.reset() 
    while True:
        actions, _, _, _ = model.step(obs)
        time.sleep(0.1)
        obs, rew, done, _ = env.step(actions)
        episode_rew += rew
        env.render()
        if done:
            print('episode_rew={}'.format(episode_rew))
            episode_rew = 0

I observe that the first level being played can be one of the two possible (fixed) levels for different runs. I don't know how the first level being played is determined and I want to know it. Alternatively, fixing the order of levels can solve my problem. Because, then I will now on which level the agent is tested. I hope now it is clear.

I am new in both Gym and Procgen, I am not how much this issue makes sense. My ultimate goal is to induce some artificial actions on the policies of some specific game levels.

christopherhesse commented 4 years ago

Instead of obs, rew, done, _ = env.step(actions) you should be able to do obs, rew, done, info = env.step(actions) and the info dictionary should tell you which level you are on.

hfeniser commented 4 years ago

Thanks, this solved my issue. I also updated the other issue that I opened.