• Stars
    star
    1,215
  • Rank 38,569 (Top 0.8 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An artificial intelligence platform for the StarCraft II with large-scale distributed training and grand-master agents.

Overview

DI-star: A large-scale game AI distributed training platform specially developed for the StarCraft II. We've already trained grand-master AI!This project contains:

  • Play demo and test code (try and play with our agent!)

  • First version of pre-trained SL and RL agent (only Zerg vs Zerg)

  • Training code of Supervised Learning and Reinforcement Learning (updated by 2022-01-31)

  • Training baseline with limited resource(one PC) and training guidance here (New! updated 2022-04-24)

  • Agents fought with Harstem (YouTube) (updated by 2022-04-01)

  • More stronger pre-trained RL agents (WIP)

Usage

Testing software on Windows | 对战软件下载

Please star us (click stars - di-star button in the top-right of this page) to help DI-star agents to grow up faster :)

Installation

Environment requirement:

  • Python: 3.6-3.8

1.Install StarCraftII

Note: There is no retail version on Linux, please follow the instruction here

  • Add SC2 installation path to environment variables SC2PATH (skip this if you use default installation path on MacOS or Windows, which is C:\Program Files (x86)\StarCraft II or /Applications/StarCraft II):

    • On MacOS or Linux, input this in terminal:

      export SC2PATH=<sc2/installation/path>
    • On Windows:

      1. Right-click the Computer icon and choose Properties, or in Windows Control Panel, choose System.
      2. Choose Advanced system settings.
      3. On the Advanced tab, click Environment Variables.
      4. Click New to create a new environment variable, set SC2PATH as the sc2 installation location.
      5. After creating or modifying the environment variable, click Apply and then OK to have the change take effect.

2.Install distar:

git clone https://github.com/opendilab/DI-star.git
cd DI-star
pip install -e .

3.Install pytorch:

Pytorch Version 1.7.1 and CUDA is recommended, Follow instructions from pytorch official site

Note: GPU is neccessary for decent performance in realtime agent test, you can also use pytorch without cuda, but no performance guaranteed due to inference latency on cpu. Make sure you set SC2 at lowest picture quality before testing.

Play with pretrained agent

1. Download StarCraftII version 4.10.0

Double click the file data/replays/replay_4.10.0.SC2Replay, StarCraftII version 4.10.0 will be automatically downloaded.

Note: We trained our models with versions from 4.8.2 to 4.9.3. Patch 5.0.9 has came out in March 15, 2022, Some changes have huge impact on performance, so we fix our version at 4.10.0 in evaluation.

2. Download models:

python -m distar.bin.download_model --name rl_model

Note: Specify rl_model or sl_model after --name to download reinforcement learning model or supervised model.

Model list:

  • sl_model: training with human replays, skill is equal to diamond players.
  • rl_model: used as default, training with reinforcement learning, skill is equal to master or grandmaster.
  • Abathur: one of reinforcement learning models, likes playing mutalisk.
  • Brakk: one of reinforcement learning models, likes lingbane rush.
  • Dehaka: one of reinforcement learning models, likes playing roach ravager.
  • Zagara: one of reinforcement learning models, likes roach rush.

3. Agent test

With the given model, we provide multiple tests with our agent.

Play against Agent
python -m distar.bin.play

It runs 2 StarCraftII instances. First one is controlled by our RL agent. Human player can play on the second one with full screen like normal game.

Note:

  • GPU and CUDA is required on default, add --cpu if you don't have these.
  • Download RL model first or specify other models (like supervised model) with argument --model1 <model_name>
  • In race cases, 2 StarCraftII instances may lose connection and agent won't issue any action. Please restart when this happens.
Agent vs Agent
python -m distar.bin.play --game_type agent_vs_agent

It runs 2 StarCraftII instances both controlled by our RL Agent, specify other model path with argument --model1 <model_name> --model2 <model_name>

Agent vs Bot
python -m distar.bin.play --game_type agent_vs_bot

RL agent plays against built-in elite bot.

Building your own agent with our framework

It is necessary to build different agents within one code base and still be able to make them play against each other. We implement this by making actor and environment as common components and putting everything related to the agent into one directory. The agent called default under distar/agent is an example of this. Every script under default uses relative import, which makes them portable to anywhere as a whole part.

If you want to create a new agent with/without our default agent, follow instructions here

If you want to train a new agent with our framework, follow instructions below and here is a guidance with more details of the whole training pipeline.

Supervised Learning

StarCraftII client is required for replay decoding, follow instructions above.

python -m distar.bin.sl_train --data <path>

path could be either a directory with replays or a file includes a replay path at each line.

Optionally, separating replay decoding and model training could be more efficient, run the three scripts in different terminals:

python -m distar.bin.sl_train --type coordinator
python -m distar.bin.sl_train --type learner --remote
python -m distar.bin.sl_train --type replay_actor --data <path>

For distributed training:

python -m distar.bin.sl_train --init_method <init_method> --rank <rank> --world_size <world_size>
or
python -m distar.bin.sl_train --type coordinator
python -m distar.bin.sl_train --type learner --remote --init_method <init_method> --rank <rank> --world_size <world_size>
python -m distar.bin.sl_train --type replay_actor --data <path>

Here is an example of training on a machine with 4 GPUs in remote mode:

# Run the following scripts in different terminals (windows).
python -m distar.bin.sl_train --type coordinator
# Assume 4 GPUs are on the same machine. 
# If your GPUs are on different machines, you need to configure the init_mehod's IP for each machine.
python -m distar.bin.sl_train --type learner --remote --init_method tcp://127.0.0.1 --rank 0 --world_size 4
python -m distar.bin.sl_train --type learner --remote --init_method tcp://127.0.0.1 --rank 1 --world_size 4
python -m distar.bin.sl_train --type learner --remote --init_method tcp://127.0.0.1 --rank 2 --world_size 4
python -m distar.bin.sl_train --type learner --remote --init_method tcp://127.0.0.1 --rank 3 --world_size 4
python -m distar.bin.sl_train --type replay_actor --data <path>

Reinforcement Learning

Reinforcement learning will use supervised model as initial model, please download it first, StarCraftII client is also required.

1. Training against bots in StarCraftII:
python -m disatr.bin.rl_train
2. Training with self-play
python -m disatr.bin.rl_train --task selfplay

Four components are used for RL training, just like SL training, they can be executed through different process:

python -m distar.bin.rl_train --type league --task selfplay
python -m distar.bin.rl_train --type coordinator
python -m distar.bin.rl_train --type learner
python -m distar.bin.rl_train --type actor

Distributed training is also supported like SL training.

Chat group

Slack: link

Discord server: link

Citation

@misc{distar,
    title={DI-star: An Open-sourse Reinforcement Learning Framework for StarCraftII},
    author={DI-star Contributors},
    publisher = {GitHub},
    howpublished = {\url{https://github.com/opendilab/DI-star}},
    year={2021},
}

License

DI-star released under the Apache 2.0 license.

More Repositories

1

awesome-RLHF

A curated list of reinforcement learning with human feedback resources (continually updated)
3,262
star
2

DI-engine

OpenDILab Decision AI Engine. The Most Comprehensive Reinforcement Learning Framework B.P.
Python
3,041
star
3

PPOxFamily

PPO x Family DRL Tutorial Course(决策智能入门级公开课:8节课帮你盘清算法理论,理顺代码逻辑,玩转决策AI应用实践 )
Python
1,875
star
4

LightZero

[NeurIPS 2023 Spotlight] LightZero: A Unified Benchmark for Monte Carlo Tree Search in General Sequential Decision Scenarios (awesome MCTS)
Python
1,097
star
5

awesome-model-based-RL

A curated list of awesome model based RL resources (continually updated)
851
star
6

awesome-diffusion-model-in-rl

A curated list of Diffusion Model in RL resources (continually updated)
739
star
7

awesome-decision-transformer

A curated list of Decision Transformer resources (continually updated)
671
star
8

LMDrive

[CVPR 2024] LMDrive: Closed-Loop End-to-End Driving with Large Language Models
Jupyter Notebook
592
star
9

DI-drive

Decision Intelligence Platform for Autonomous Driving simulation.
Python
563
star
10

InterFuser

[CoRL 2022] InterFuser: Safety-Enhanced Autonomous Driving Using Interpretable Sensor Fusion Transformer
Python
522
star
11

LLMRiddles

Open-Source Reproduction/Demo of the LLM Riddles Game
Python
515
star
12

GoBigger

[ICLR 2023] Come & try Decision-Intelligence version of "Agar"! Gobigger could also help you with multi-agent decision intelligence study.
Python
459
star
13

DI-sheep

羊了个羊 + 深度强化学习(Deep Reinforcement Learning + 3 Tiles Game)
Python
416
star
14

awesome-end-to-end-autonomous-driving

A curated list of awesome End-to-End Autonomous Driving resources (continually updated)
371
star
15

awesome-multi-modal-reinforcement-learning

A curated list of Multi-Modal Reinforcement Learning resources (continually updated)
367
star
16

awesome-exploration-rl

A curated list of awesome exploration RL resources (continually updated)
365
star
17

SO2

[AAAI2024] A Perspective of Q-value Estimation on Offline-to-Online Reinforcement Learning
Python
285
star
18

DI-engine-docs

DI-engine docs (Chinese and English)
Python
281
star
19

DI-orchestrator

OpenDILab RL Kubernetes Custom Resource and Operator Lib
Go
240
star
20

DI-smartcross

Decision Intelligence platform for Traffic Crossing Signal Control
Python
230
star
21

treevalue

Here are the most awesome tree structure computing solutions, make your life easier. (这里有目前性能最优的树形结构计算解决方案)
Python
228
star
22

DI-hpc

OpenDILab RL HPC OP Lib, including CUDA and Triton kernel
Python
222
star
23

awesome-AI-based-protein-design

A collection of research papers for AI-based protein design
216
star
24

ACE

[AAAI 2023] Official PyTorch implementation of paper "ACE: Cooperative Multi-agent Q-learning with Bidirectional Action-Dependency".
Python
212
star
25

DI-treetensor

Let DI-treetensor help you simplify the structure processing!(树形运算一不小心就逻辑混乱?DI-treetensor快速帮你搞定)
Python
202
star
26

GoBigger-Challenge-2021

Interested in multi-agents? The 1st Go-Bigger Multi-Agent Decision Intelligence Challenge is coming and a big bonus is waiting for you!
Python
195
star
27

Gobigger-Explore

Still struggling with the high threshold or looking for the appropriate baseline? Come here and new starters can also play with your own multi-agents!
Python
185
star
28

DI-store

OpenDILab RL Object Store
Go
177
star
29

LightTuner

Python
173
star
30

DOS

[CVPR 2023] ReasonNet: End-to-End Driving with Temporal and Global Reasoning
Python
145
star
31

DI-toolkit

A simple toolkit package for opendilab
Python
113
star
32

DI-bioseq

Decision Intelligence platform for Biological Sequence Searching
Python
111
star
33

DI-1024

1024 + 深度强化学习(Deep Reinforcement Learning + 1024 Game/ 2048 Game)
Python
109
star
34

SmartRefine

[CVPR 2024] SmartRefine: A Scenario-Adaptive Refinement Framework for Efficient Motion Prediction
Python
107
star
35

DIgging

Decision Intelligence for digging best parameters in target environment.
Python
90
star
36

awesome-driving-behavior-prediction

A collection of research papers for Driving Behavior Prediction
77
star
37

PsyDI

PsyDI: Towards a Personalized and Progressively In-depth Chatbot for Psychological Measurements. (e.g. MBTI Measurement Agent)
TypeScript
70
star
38

DI-adventure

Decision Intelligence Adventure for Beginners
Python
68
star
39

GenerativeRL

Python library for solving reinforcement learning (RL) problems using generative models (e.g. Diffusion Models).
Python
48
star
40

huggingface_ding

Auxiliary code for pulling, loading reinforcement learning models based on DI-engine from the Huggingface Hub, or pushing them onto Huggingface Hub with auto-created model card.
Python
46
star
41

CodeMorpheus

CodeMorpheus: Generate code self-portraits with one click(一键生成代码自画像,决策型 AI + 生成式 AI)
Python
45
star
42

OpenPaL

Building open-ended embodied agent in battle royale FPS game
33
star
43

awesome-ui-agents

A curated list of of awesome UI agents resources, encompassing Web, App, OS, and beyond (continually updated)
31
star
44

.github

The first decision intelligence platform covering the most complete algorithms in academia and industry
19
star
45

CleanS2S

High-quality and streaming Speech-to-Speech interactive agent in a single file. 只用一个文件实现的流式全双工语音交互原型智能体!
1
star