TorchCraftAI
  • Tutorials
  • API
  • Blog
  • GitHub

›Getting Started

Getting Started

  • Installation (Linux)
  • Installation (Windows)
  • Installation (macOS)
  • Play games with CherryPi

TorchCraftAI

  • Overview
  • System Architecture
  • Core Abstractions
  • Modules Overview
  • Module Training Blueprints

Tutorial - Building Placement

  • Building Placement Intro
  • Neural Network Architecture
  • Supervised Learning
  • Reinforcement Learning

Tutorial - Micro-Manamagent

  • Micromanagement Intro
  • Model
  • Training Setup

Installation (Windows)

TorchCraftAI's modular framework and its CherryPi bot work on Windows. For training machine learning models, you may need to install Linux on a virtual machine and refer to the Linux instructions

Prerequisites

Install Required Packages

  • StarCraft: Brood War 1.16.1 (newer versions like 1.18 and Remastered are incompatible with the Brood War API)
  • Visual Studio 2017 (the Community edition is free)
  • BWAPI (Brood War API) 4.2.0
  • Anaconda, the Python 3 version.
  • Git for Windows, for Git Bash
  • CUDA if you have a GPU

Clone the TorchCraftAI Repository

Git bash is probably easiest for this step:

git clone https://github.com/TorchCraft/TorchCraftAI --recursive cd TorchCraftAI git submodule update --init --recursive 

Build PyTorch Backend Libraries

Do everything in an Anaconda prompt.

Initialize Environment

Note: This assumes you're using the Community Edition of VS, change the path below accordingly

set "VS150COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build" set CMAKE_GENERATOR=Visual Studio 15 2017 Win64 set DISTUTILS_USE_SDK=1 call "%VS150COMNTOOLS%\vcvarsall.bat" x64 -vcvars_ver=14.11 

Build PyTorch

$WORKDIR is where we launch cherrypi.exe, most commonly the repository root directory. It is also where bwapi-data/read and bwapi-data/write is. conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing python setup.py build xcopy 3rdparty\pytorch\torch\lib\c10.dll $WORKDIR xcopy 3rdparty\pytorch\torch\lib\torch.dll $WORKDIR xcopy 3rdparty\pytorch\torch\lib\caffe2.dll $WORKDIR PyTorch will run most performantly using the environment variable `OMP_NUM_THREADS=1`. If you have no specific need for this value to differ, we recommend setting this as the system default. #### If you have an NVIDIA GPU xcopy 3rdparty\pytorch\torch\lib\caffe2_gpu.dll $WORKDIR This step is needed to find nvtools correctly: - xcopy "C:\Program Files\NVIDIA Corporation\NvToolsExt\bin\x64\nvToolsExt64_1.dll" $WORKDIR 

Note: You may have to disable TDR somehow, but don't do that unless the code won't run.

Install StarCraft

See Play Games with CherryPi.

Compilation and Usage

Build TorchCraftAI and CherryPi

Do everything in an Anaconda prompt. Anaconda is only needed for pytorch, but we use the same environment to reduce build issues. Additionally, make sure the prompt has the commands run in Initialize Environment

Build gflags

cd 3rdparty\gflags del /s /q build mkdir build cd build cmake .. -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP" -G "Visual Studio 15 2017 Win64" msbuild gflags.sln /property:Configuration=Release /m xcopy /y lib\Release\gflags_static.lib ..\.. cd ..\..\.. 

Build glog

cd 3rdparty\glog rd /s build && mkdir build && cd build set gflags_DIR=../../gflags/build/ cmake .. -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP" -G "Visual Studio 15 2017 Win64" msbuild glog.sln /property:Configuration=Release /m xcopy /y Release\glog.lib ..\.. cd ..\..\.. 

Build ZeroMQ, a messaging library

cd 3rdparty rd /s libzmq && robocopy /e ..\3rdparty\torchcraft\BWEnv\include\libzmq .\libzmq cd libzmq msbuild ./builds/msvc/vs2017/libzmq.sln /property:Configuration=DynRelease xcopy /y bin\x64\Release\v141\dynamic\libzmq.lib ..\zmq.lib cd ..\..\ 

Build CherryPi!

rd /s deps && mkdir deps xcopy 3rdparty deps mkdir build && cd build cmake .. -DMSVC=true -DZMQ_LIBRARY="../3rdparty/zmq.lib" -DZMQ_INCLUDE_DIR="../3rdparty/libzmq/include" -DGFLAGS_LIBRARY="../3rdparty/gflags_static.lib" -DGFLAGS_INCLUDE_DIR="../3rdparty/gflags/build/include" -DGLOG_ROOT_DIR="../3rdparty/glog" -DCMAKE_CXX_FLAGS_RELEASE="/MP /EHsc" -G "Visual Studio 15 2017 Win64" # It will complain about missing GFLAGS_LIBRARY, but that's fine. msbuild CherryPi.sln /property:Configuration=Release /m 

Play your first game with CherryPi

See Play Games with CherryPi

← Installation (Linux)Installation (macOS) →
  • Prerequisites
    • Install Required Packages
    • Clone the TorchCraftAI Repository
    • Build PyTorch Backend Libraries
    • Install StarCraft
  • Compilation and Usage
    • Build TorchCraftAI and CherryPi
    • Play your first game with CherryPi
TorchCraftAI
Docs
Getting Started (Linux)Getting Started (Windows)Getting Started (Mac)API Reference
Community
Starcraft AI DiscordStarcraft AI Facebook groupTorchCraftAI on GitHub
More
TorchCraft on GitHubStarData on GitHubBlog
Facebook Open Source
Copyright © 2019 Facebook