Skip to content

Instantly share code, notes, and snippets.

@PixelyIon
Last active May 24, 2018 12:26
Show Gist options
  • Save PixelyIon/35452d235138f2b32c7f8c17b4553d61 to your computer and use it in GitHub Desktop.
Save PixelyIon/35452d235138f2b32c7f8c17b4553d61 to your computer and use it in GitHub Desktop.
This provides easy to use interface for the actionspace.
class esy_ctl:
out=np.zeros(8)
def up(self):
self.out[4]=1
if(self.out[5]==1):
self.out[5]=0
def down(self):
self.out[5]=1
if(self.out[4]==1):
self.out[4]=0
def left(self):
self.out[6]=1
if(self.out[7]==1):
self.out[7]=0
def right(self):
self.out[7]=1
if(self.out[6]==1):
self.out[6]=0
def jmp(self):
if(self.out[0]==0):
self.out[0]=1
self.out[1]=0
else:
self.out[0]=not self.out[0]
self.out[1]=not self.out[1]
def stall(self):
self.out=np.zeros(8)
Usage:
ctl=esy_ctl()
while True:
obs, rew, done, info = env.step(ctl.out)
# Run right
ctl.right()
# Jump while running
ctl.jump()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment