Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created May 7, 2016 17:47
Show Gist options
  • Save AndyNovo/dbdc97df3632a01fa3b909da7352f58b to your computer and use it in GitHub Desktop.
Save AndyNovo/dbdc97df3632a01fa3b909da7352f58b to your computer and use it in GitHub Desktop.
import gym
env = gym.make('CartPole-v0')
def ai():
wts=[-.2,0,1,.4]
mms=[0.76464200398541937, 2.3215749215909214, 0.20943257252883613, 2.9815988455023286]
obs=env.reset()
rwd=0
for i in range(200):
move=1 if sum([obs[i]*wts[i]/mms[i] for i in range(len(obs))]) > 0 else 0
obs,r,d,i=env.step(move)
rwd+=r
if d:
return rwd
return rwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment