網頁

2020年7月8日 星期三

互動式 OpenAI gym

https://github.com/openai/gym/blob/master/gym/utils/play.py
env = gym.make("Enduro-v0")
def cb(obs_t, obs_tp1, action, rew, done, info):
    return [rew,]
plotter = PlayPlot(cb, hor0zon_timesteps=(30*5), plot_names=["reward"])
play(env, callback=plotter.callback, zoom=4)

https://github.com/openai/gym/blob/master/gym/core.py
https://github.com/openai/gym/tree/master/gym/wrappers
https://github.com/openai/gym/blob/master/gym/wrappers/atari_preprocessing.py
https://github.com/openai/gym/blob/master/gym/envs/__init__.py
        register(
            id='{}-v0'.format(name),
            entry_point='gym.envs.atari:AtariEnv',
            kwargs={'game': game, 'obs_type': obs_type, 'repeat_action_probability': 0.25},
            max_episode_steps=10000,
            nondeterministic=nondeterministic,
        )
https://github.com/openai/gym/blob/master/gym/envs/atari/atari_env.py
    pip install gym[atari]
    self.ale = atari_py.ALEInterface()
    reward += self.ale.act(action)

https://github.com/openai/atari-py/tree/master/atari_py
https://github.com/openai/atari-py/blob/master/atari_py/__init__.py
https://github.com/openai/atari-py/blob/master/atari_py/ale_python_interface.py
    ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__),
                                            'ale_interface/libale_c.so'))
    def act(self, action):
        return ale_lib.act(self.obj, int(action))
https://github.com/openai/atari-py/blob/master/atari_py/ale_interface/src/ale_interface.cpp
    reward_t reward = environment->act(action, PLAYER_B_NOOP);
https://github.com/openai/atari-py/blob/master/atari_py/ale_interface/src/ale_interface.hpp
std::unique_ptr<StellaEnvironment> environment;
https://github.com/openai/atari-py/blob/master/atari_py/ale_interface/src/environment/stella_environment.cpp
reward_t StellaEnvironment::act(Action player_a_action, Action player_b_action)
    sum_rewards += oneStepAct(m_player_a_action, m_player_b_action);
reward_t StellaEnvironment::oneStepAct(Action player_a_action, Action player_b_action)
    return m_settings->getReward();
https://github.com/openai/atari-py/blob/master/atari_py/ale_interface/src/environment/stella_environment.hpp
    RomSettings *m_settings;
https://github.com/openai/atari-py/blob/master/atari_py/ale_interface/src/games/RomSettings.hpp
    virtual reward_t getReward() const = 0;
https://github.com/openai/atari-py/blob/master/atari_py/ale_interface/src/games/supported/Enduro.cpp

沒有留言:

張貼留言