StarCraft II 强化学习示例项目技术文档
1. 安装指南
1.1 获取 PySC2
最简单的获取 PySC2 的方法是使用 pip 安装:
$ pip install git+https://github.com/deepmind/pysc2
同时,你还需要安装 baselines 库:
$ pip install git+https://github.com/openai/baselines
1.2 安装 StarCraft II
1.2.1 Mac / Win
你需要购买并安装 StarCraft II,或者使用 Starter Edition 也可以。
1.2.2 Linux 包
按照 Blizzard 的 文档 获取 Linux 版本。默认情况下,PySC2 期望游戏安装在 ~/StarCraftII/ 目录下。
1.3 下载地图
下载 ladder maps 和 mini games,并将它们解压到你的 StarcraftII/Maps/ 目录下。
2. 项目使用说明
2.1 训练模型
2.1.1 使用 A2C 算法训练
$ python train_mineral_shards.py --algorithm=a2c
2.1.2 使用 DQN 算法训练
$ python train_mineral_shards.py --algorithm=deepq --prioritized=True --dueling=True --timesteps=2000000 --exploration_fraction=0.2
2.2 运行模型
$ python enjoy_mineral_shards.py
3. 项目API使用文档
3.1 参数说明
| 参数名 | 描述 | 默认值 | 参数类型 | |----------------------|-------------------------------------------|---------------------------------|----------------| | map | Gym 环境 | CollectMineralShards | string | | log | 日志类型 : tensorboard, stdout | tensorboard | string | | algorithm | 当前支持的算法 : deepq, a2c | a2c | string | | timesteps | 总训练步数 | 2000000 | int | | exploration_fraction | 探索分数 | 0.5 | float | | prioritized | 是否使用优先回放的 DQN | False | boolean | | dueling | 是否使用 dueling network 的 DQN | False | boolean | | lr | 学习率 (如果为 0,则随机设置为 e-5 ~ e-3) | 0.0005 | float | | num_agents | A2C 的代理数量 | 4 | int | | num_scripts | A2C 的脚本代理数量 | 4 | int | | nsteps | 更新策略的步数 | 20 | int |
4. 项目安装方式
4.1 安装依赖库
$ pip install git+https://github.com/deepmind/pysc2
$ pip install git+https://github.com/openai/baselines
4.2 安装 StarCraft II
根据操作系统的不同,按照上述指南安装 StarCraft II。
4.3 下载地图
下载并解压所需的地图文件到指定目录。
4.4 运行项目
按照使用说明中的命令运行项目。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考



