Created
August 28, 2018 04:33
-
-
Save fabito/0b39469fe242ae2850b2f5c97b6242b8 to your computer and use it in GitHub Desktop.
neyboy - play
This file contains 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
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