Skip to content

Instantly share code, notes, and snippets.

@ViniTheSwan
Last active January 27, 2022 23:43
Show Gist options
  • Save ViniTheSwan/d1a612419ca3439e44df524f53bece4b to your computer and use it in GitHub Desktop.
Save ViniTheSwan/d1a612419ca3439e44df524f53bece4b to your computer and use it in GitHub Desktop.
from stable_baselines3 import PPO
import gym
# Parallel environments
env = gym.make("CartPole-v1")
model = PPO(policy = "MlpPolicy",env = env, verbose=1)
model.learn(total_timesteps=25000)
obs = env.reset()
for i in range(1000):
action, _state = model.predict(obs, deterministic=True)
obs, reward, done, info = env.step(action)
env.render()
if done:
obs = env.reset()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment