Updated on 2023-11-16 GMT+08:00

Gym

Adding Gym on Function Details Page

Figure 1 Adding Gym

Importing Gym to Code

# Import Gym.
import gym
env = gym.make('CartPole-v0')
env.reset()
 
def handler(event,context):
    for _ in range(10):
        env.render()
        observation, reward, done, info, _ = env.step(env.action_space.sample()) # take a random action
        temp = env.step(env.action_space.sample()) # take a random action
        print('observation:{}, reward:{}, done:{}, info:{}'.format(observation, reward, done, info))
    env.close()