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?