Is there any way to get keyboard input such as arrow keys with gym games? For example, I just want to make a simple interactive cart pole using keyboard (LEFT, RIGHT). I tried with readchar, but cart pole hangs.
def human_play(replay_buffer): s = env.reset() while True: env.render() # Choose an action from keyboard # FIXME: keyin does not work gym ai key = readchar.readkey() if key not in arrow_keys.keys(): print("Game aborted!") break a = arrow_keys[key] print(a) s1, reward, done, _ = env.step(a) if done: break