OpenAI Gym CarRacing

Viewed 28

I want to create a reinforcement learning model using stable-baselines3 PPO that can drive OpenAI Gym Car racing environment and I have been having a lot of errors and package compatibility issues. I have currently this code just for random actions

import gym 
from stable_baselines3 import PPO

environment_name = "CarRacing-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, info = env.step(action)
        score+=reward
    print('Episode:{} Score:{}'.format(episode, score))
env.close()

Runnning on Ubuntu 20.04, in VSCode Jupyter notebook. With these packages in a conda env enter image description here

Even with random actions I am currently getting an error on state = env.reset() enter image description here

I tried different versions of gym and other packages and none seem to work flawlessly. Could anyone please help me, my only requirement is to make it work (firstly random and then with PPO) no matter what versions of packages.

Thank you

0 Answers
Related