[Python] VS code openai issues

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I have been following this tutorial (https://www.youtube.com/watch?v=Mut_u40Sqz4) on learning to make AIs using OpenAI gym and stable baselines-3. The issue is the env.render is not working, There is no screen appearing at all however there is no error and the AI does still work. I understand that the problem is I am using VS code and just plain .py files over .ipynd files however I would like to continue using VS code in a way I am familiar with.

    import os
    import gym
    from stable_baselines3 import PPO
    from stable_baselines3.common.vec_env import DummyVecEnv
    from stable_baselines3.common.evaluation import evaluate_policy

    environment_name = 'CartPole-v0'
    env = gym.make(environment_name)

    episodes = 5
    for episode in range(1, episodes+1):
    state = env.reset()
    done = False
    score = 0

    while not done:
    env.render()
    action = env.action_space.sample()
    n_state, reward, done, confusing_thing, info = env.step(action)
    score+=reward
    print('Episode:{} Score:{}'.format(episode, score))
    env.close()


    Please help, I do understand that there is no point in using VS code over jupyter notebooks but I rather it and am also curious about how to fix the issue.

    Continue reading...

Compartilhe esta Página