Skip to main content

No project description provided

Project description

Gym-MicroRTS

This repo contains the source code for the gym wrapper of MicroRTS authored by Santiago Ontañón.

Get Started

# Make sure you have Java 8.0+ installed
$ pip install gym_microrts --upgrade

And run either the hello_world.py referenced above or the following file

import gym
import gym_microrts

env = gym.make("MicrortsMining-v1")
env.reset()
for _ in range(10000):
    env.render()
    env.step(env.action_space.sample())
env.close()

demo.gif

Environment Specification

Here is a description of gym-microrts's observation and action space:

  • Observation Space. Given a map of size h x w, the observation is a tensor of shape (h, w, n_f), where n_f is a number of feature planes that have binary values. The observation space used in this paper uses 27 feature planes as shown in the following table. A feature plane can be thought of as a concatenation of multiple one-hot encoded features. As an example, if there is a worker with hit points equal to 1, not carrying any resources, owner being Player 1, and currently not executing any actions, then the one-hot encoding features will look like the following:

    [0,1,0,0,0], [1,0,0,0,0], [1,0,0], [0,0,0,0,1,0,0,0], [1,0,0,0,0,0]

    The 27 values of each feature plane for the position in the map of such worker will thus be:

    [0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0]

  • Action Space. Given a map of size h x w, the action is an 8-dimensional vector of discrete values as specified in the following table. The first component of the action vector represents the unit in the map to issue actions to, the second is the action type, and the rest of components represent the different parameters different action types can take. Depending on which action type is selected, the game engine will use the corresponding parameters to execute the action. As an example, if the RL agent issues a move south action to the worker at $x=3, y=2$ in a 10x10 map, the action will be encoded in the following way:

    [3+2*10,1,2,0,0,0,0,0 ]

obs_action.svg

Preset Envs:

Gym-microrts comes with preset environments for common tasks as well as engaging the full game. Feel free to check out the following benchmark:

Below are the difference between the versioned environments

use frame skipping complete invalid action masking issuing actions to all units simultaneously map size
v1 frame skip = 9 only partial mask on source unit selection no 10x10
v2 no yes yes 10x10
v3 no yes yes 16x16

Developer Guide

Clone the repo

# install gym-microrts
$ git clone --recursive https://github.com/vwxyzjn/gym-microrts.git && \
cd gym-microrts && \
pip install -e .
# build microrts
$ cd gym_microrts/microrts && bash build.sh && cd ..& cd ..
$ python hello_world.py

Papers written using gym-microrts

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gym_microrts-0.1.6.tar.gz (36.4 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page