Help Center/ FunctionGraph/ User Guide/ Configuring Functions/ Configuring Dependencies/ Public Dependency Demos/ Gym
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() Parent topic: Public Dependency Demos
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.