Skip to content

Instantly share code, notes, and snippets.

@fabito
Created August 28, 2018 04:33
Show Gist options
  • Save fabito/0b39469fe242ae2850b2f5c97b6242b8 to your computer and use it in GitHub Desktop.
Save fabito/0b39469fe242ae2850b2f5c97b6242b8 to your computer and use it in GitHub Desktop.
neyboy - play
env = gym.make('neyboy-v0')
while True:
ev = screen.get_key()
action = 0
if ev in (Screen.KEY_LEFT, ord('A'), ord('a')):
action = 1
elif ev in (Screen.KEY_RIGHT, ord('D'), ord('d')):
action = 2
elif ev in (Screen.KEY_UP, ord('W'), ord('w')):
env.reset()
elif ev in (Screen.KEY_ESCAPE, ord('Q'), ord('q')):
env.close()
break
observation, reward, done, info = env.step(action)
# convert frame to ascii and render in the terminal
renderer = ImageFile(observation, height=args.height, colours=screen.colours)
image, colours = renderer.rendered_text
for (i, line) in enumerate(image):
screen.centre(line, i, colour_map=colours[i])
screen.refresh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment