Skip to content

Instantly share code, notes, and snippets.

@araffin
Last active August 19, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save araffin/7a3a83ca19c990dda2bc12e152485b41 to your computer and use it in GitHub Desktop.
Save araffin/7a3a83ca19c990dda2bc12e152485b41 to your computer and use it in GitHub Desktop.
from stable_baselines.common.cmd_util import make_atari_env
from stable_baselines.common.policies import CnnPolicy
from stable_baselines.common.vec_env import VecFrameStack
from stable_baselines import ACER
# There already exists an environment generator
# that will make and wrap atari environments correctly.
# Here we are also multiprocessing training (num_env=4 => 4 processes)
env = make_atari_env('PongNoFrameskip-v4', num_env=4, seed=0)
# Frame-stacking with 4 frames
env = VecFrameStack(env, n_stack=4)
model = ACER(CnnPolicy, env, verbose=1)
model.learn(total_timesteps=25000)
obs = env.reset()
while True:
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment