Created
May 7, 2016 17:47
-
-
Save AndyNovo/dbdc97df3632a01fa3b909da7352f58b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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