Updated on 2023-11-16 GMT+08:00
Gym
Adding Gym on Function Details Page
Figure 1 Adding Gym
![](https://support.huaweicloud.com/eu/usermanual-functiongraph/en-us_image_0000001709199544.png)
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
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.