Skip to content

Instantly share code, notes, and snippets.

@sosiristseng
Forked from stefanopalmieri/whatever.py
Last active January 4, 2020 03:20
Show Gist options
  • Save sosiristseng/b57eb8c05b2b9126d48e763206a1667a to your computer and use it in GitHub Desktop.
Save sosiristseng/b57eb8c05b2b9126d48e763206a1667a to your computer and use it in GitHub Desktop.
Cartpole using simple policy
import numpy as np
import gym
from gym import wrappers
env = gym.make('CartPole-v1')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-v1', force=True)
for i_episode in range(100):
observation = env.reset()
while True:
action = np.argmax([0,observation[2] + observation[3]])
observation, reward, done, _ = env.step(action)
if done:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment