sc2 0.4.0-alpha.1

Rust implementation of the StarCraft II Client API failed to build sc2-0.4.0-alpha.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure builds.
If you believe this is' fault, open an issue.
Visit the last successful build: sc2-0.3.2

Pipeline Status Crates Version License: MIT Documentation

Documentation (master)

This is my Rust implementation of the StarCraft II Client API.

This crate is still under heavy development, and I've only just decided the direction it's going in regarding futures and streams. It currently relies on the nightly #[async]/await!, but if enough people push to support stable futures, I'll consider moving this requirement into a feature, but at the moment, it's really convenient to use the experimental features instead of the stable combinators.

I tried to keep it close to the s2client-api in terms of the division of functionality into interfaces such as the Action interface and Observer interface, however there are several differences because for one idiomatic C++ and idiomatic Rust don't play well together (and for good reason too!), and also I was very interested in the work done with futures-rs and thought that neat asynchronous programming was a good fit for this library. In particular, one of the core differences between s2client-api and this library is the creation of bots and the consumption of events.

s2client-api employs polymorphism to define bots, sc2-rs on the other hand uses channels to communicate between the bot and the API. Let's take a look at the creation of a simple bare-bones bot.

struct SimpleBot;

impl SimpleBot {
    fn new() -> Self {
        Self { }

    /// Spawn our bot's coroutine on the event loop.
    fn spawn(
        handle: &reactor::Handle,
        rx: mpsc::Receiver<(Event, EventAck)>,
    ) -> Result<()> {
        handle.spawn(|e| panic!("{:#?}", e)));


    /// Run the bot.
    fn run(mut self, rx: mpsc::Receiver<(Event, EventAck)>) -> Result<()> {
        // Loop over the game events.
        for (e, ack) in rx.map_err(|_| -> Error { unreachable!() }) {
            self = await!(self.on_event(e))?;

            match e {
                // Triggered once at the start of every game.
                Event::GameStarted => println!("Started a new game!"),
                // Triggered every time the game updates.
                Event::Step => println!("Game Stepped!"),
                // Ignore the other events for now.
                _ => (),

            // Notify the coordinator that we have consumed this event.


This bot is simply designed to take a stream of game events and print messages for GameStarted and GameStepped. Normally, you would use these events as opportunities to observe the game state and/or dispatch orders to units. For now, though, a message is good enough.

fn main() {
    // Create a new event loop.
    let mut core = reactor::Core::new().unwrap();
    let handle = core.handle();

    // Create a new Agent and set the Race to Terran.
    let mut agent = AgentBuilder::new().race(Race::Terran);
    // Instantiate our simple bot.
    let bot = SimpleBot::new();

    // Get the event stream from the Agent and spawn our bot's coroutine.
    bot1.spawn(&handle, agent.take_event_stream().unwrap()).unwrap();

    // Create a match between our bot and a default SC2 built-in AI Opponent.
    let melee = MeleeBuilder::new()
            "maps/Ladder/(2)Bel'ShirVestigeLE (Void).SC2Map"

    // Run the match to completion on the event loop.;


Here we create an event loop, spawn our bot as a coroutine and listen for events from a Melee (PvP) match against a built-in SC2 AI opponent.

An important thing to note is that the default LauncherSettings will only find your SC2 on Windows. However, since the headless Linux version is not ideal for debugging purposes, I've added support for Wine within the library for all of the people like me who are too lazy to dual-boot (or just prefer Linux in general). The good news is that Wine actually supports SC2, the bad news is that last time I checked, the support requires newer (possibly staging versions) of Wine.

Here are some helpful links to get you started with that: