0

I am experimenting with gym on PyCharm. This is my code:

import gym
from time import sleep

env = gym.make("Taxi-v3").env

epochs = 0
penalties, reward = 0, 0

frames = []  # for animation

done = False

while not done:
        action = env.action_space.sample()
        state, reward, done, info = env.step(action)

        if reward == -10:
            penalties += 1

        env.render()
        sleep(.1)

        epochs += 1

Currently when I print it, it renders every state one after another on the PyCharm console. I want it to first clear the earlier output from the console and then print the next one. How do I make that happen?

rishi
  • 2,564
  • 6
  • 25
  • 47
  • 1
    You can't do it in an IDE console, you have to do so in a terminal – azro Nov 30 '19 at 08:48
  • Does this answer your question? [How can I overwrite/print over the current line in Windows command line?](https://stackoverflow.com/questions/465348/how-can-i-overwrite-print-over-the-current-line-in-windows-command-line) – azro Nov 30 '19 at 08:49
  • @arzo I was hoping to do it in IDE. But looks like there is no way to do it in IDE – rishi Nov 30 '19 at 08:51
  • 1
    Yep console doesn’t ask the same in IDE – azro Nov 30 '19 at 08:52

0 Answers0