Professional Documents
Culture Documents
Importing files:
Below files will be used to complete the program.
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)
# loads the environment with the help of gym library
episodes = 5
# will check environment (in other words play the game) 'episode'
(here 5) number of times.
# CartPole has fixed episode length which is 200 frames
for episode in range (1, episodes + 1):
state = env.reset()
# reset the environment and obtain initial observations of
environment
done = False
# episode is not done till now
score = 0
# score for each iteration (episode)
Training: