(1)Gymnasium--安装和测试

1、官方地址

Gymnasium Documentation

2、参考教程

Gymnasium环境搭建与使用 - 知乎

3、安装

#conda 创建和使用环境
conda create -n gym_cp310 python=3.10 
conda activate gym_cp310

#安装相关包
pip install "Gymnasium[all]" 

4、报错Failed to build box2d-py的解决

解决安装强化学习库gymnasium,box2d安装报错的问题_tortorish的博客-CSDN博客

conda install swig

5、测试一下使用

(1)官方例子

import gymnasium as gym
env = gym.make("LunarLander-v2", render_mode="human")
observation, info = env.reset()

for _ in range(1000):
    action = env.action_space.sample()  # agent policy that uses the observation and info
    observation, reward, terminated, truncated, info = env.step(action)

    if terminated or truncated:
        observation, info = env.reset()

env.close()

你可能感兴趣的:(深度学习,python)