10分钟上手ReBeL:非完美信息游戏AI开发的快速启动指南
10分钟上手ReBeL:非完美信息游戏AI开发的快速启动指南
【免费下载链接】rebelAn algorithm that generalizes the paradigm of self-play reinforcement learning and search to imperfect-information games.项目地址: https://gitcode.com/gh_mirrors/rebe/rebel
ReBeL是一种将自我对弈强化学习与搜索范式推广到非完美信息游戏的先进算法。本指南将帮助你快速掌握ReBeL的安装配置与基础使用,让你在10分钟内开启非完美信息游戏AI的开发之旅。
🌟 关于ReBeL
ReBeL(Combining deep reinforcement learning and search for imperfect-information games)由Facebook Research团队开发,发表于NeurIPS 2020。该算法创新性地融合了深度强化学习与搜索技术,特别适用于扑克、说谎者骰子等存在信息不对称的游戏场景。本仓库包含针对经典非完美信息游戏Liar's Dice的完整实现。
🚀 一键安装步骤
1. 环境准备
推荐使用conda管理环境,确保系统已安装conda。执行以下命令克隆仓库并创建专用环境:
git clone --recursive https://gitcode.com/gh_mirrors/rebe/rebel cd rebel conda create --yes -n rebel python=3.7 source activate rebel2. 依赖安装
安装Python依赖与编译工具:
pip install -r requirements.txt conda install cmake3. 编译C++核心模块
ReBeL的高性能数据生成模块使用C++实现,执行以下命令完成编译:
make⚡ 快速训练你的第一个AI模型
基础训练命令
使用CPU生成数据训练价值网络(适合入门体验):
python run.py --adhoc --cfg conf/c02_selfplay/liars_sp.yaml \ env.num_dice=1 \ env.num_faces=4 \ env.subgame_params.use_cfr=true \ selfplay.cpu_gen_threads=60多GPU加速训练
若你的设备有多个GPU,可使用以下命令启用GPU加速(假设1个GPU用于训练,其余用于数据生成):
python run.py --adhoc --cfg conf/c02_selfplay/liars_sp.yaml \ env.num_dice=1 \ env.num_faces=4 \ env.subgame_params.use_cfr=true \ selfplay.cpu_gen_threads=0 \ selfplay.threads_per_gpu=8⚠️ 提示:所有可配置参数详见conf/c02_selfplay/liars_sp.yaml。如需在Slurm集群运行,添加
launcher=slurm_8gpus launcher.num_gpus=NUM_GPUS参数即可。
📊 模型评估方法
训练过程中每10个epoch会保存TorchScript格式的模型 checkpoint。使用以下命令评估模型策略的可利用性(exploitability):
build/recursive_eval \ --net path/to/model.torchscript \ --mdp_depth 2 \ --num_faces 4 \ --num_dice 1 \ --subgame_iters 1024 \ --num_repeats 4097 \ --num_threads 10 \ --cfr💡 技巧:设置
--num_repeats为正数可启用采样策略评估,通过平均多个子博弈算法迭代的结果获得可利用性上限。评估报告会同时显示全树求解与递归求解的性能指标。
📁 代码结构解析
ReBeL的代码组织清晰,核心模块包括:
- 训练逻辑:cfvpy/selfplay.py实现Python训练循环
- 数据生成:C++核心代码位于csrc/liars_dice目录
- 配置文件:conf/目录包含环境、优化器等参数配置
- 评估工具:scripts/eval_all.py可批量下载评估预训练模型
📚 预训练模型资源
官方提供1x4f、1x5f、1x6f和2x3f等游戏场景的预训练模型 checkpoint,可通过scripts/eval_all.py脚本一键下载并评估。这些模型的平均可利用性指标已在原论文中报告。
📄 许可证与引用
ReBeL基于Apache许可证开源,详见LICENSE文件。若使用本项目成果,请引用原论文:
@article{brown2020rebel, title={Combining deep reinforcement learning and search for imperfect-information games}, author={Brown, Noam and Bakhtin, Anton and Lerer, Adam and Gong, Qucheng}, journal={Advances in Neural Information Processing Systems}, volume={33}, year={2020} }通过本指南,你已掌握ReBeL的基础使用方法。如需深入研究,建议阅读原始论文并探索代码中的高级配置选项。祝你在非完美信息游戏AI的开发之路上取得突破!
【免费下载链接】rebelAn algorithm that generalizes the paradigm of self-play reinforcement learning and search to imperfect-information games.项目地址: https://gitcode.com/gh_mirrors/rebe/rebel
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考