StarCraft II API

May 7 CommandCenter: An SC2 AI Bot Framework The AI community has been conducting research using the original StarCraft for years, and we appreciate all of the scripted AI work that has been done. One of the most popular frameworks for writing bots in the original StarCraft was UAlbertabot, and many of the top competitive bots are based on this framework. It was also designed as an easy-to-use tool to toy around with AI – you could just plug in a build order and watch it go. In addition to our collaboration with DeepMind, we have also been working with the author of UAlbertabot, David Churchill, on porting this framework over to StarCraft II. His initial version, called CommandCenter, is out now: David, a Computer Science faculty member at Memorial University, has been one of the core pillars of the StarCraft AI community for many years, and the feedback he provided to us during the development of the StarCraft II API has been very helpful. Together with the rest of the AI research community, we look forward to making StarCraft II an awesome environment to continue experimenting with AI bots.Traysent9 May 7
Dec 7, 2017 Welcome to the StarCraft II API Thanks for joining the discussion around the release of the StarCraft II API! For more information on our announcement, please see the following: Blizzard Announcement blog DeepMind Announcement blog To get started, suggest changes, and report bugs, you can participate in our open source project on GitHub: StarCraft II API Library StarCraft II API Protocol Python Protocol Binding Library PySC2 (DeepMind’s toolset) You can also participate in additional discussion on David Churchill’s Facebook group: StarCraft II Artificial Intelligence Facebook Group We’re excited to see the direction that the AI research community takes this in, and we look forward to your discussion! - The StarCraft II API teamTraysent6 Dec 7, 2017
Oct 24, 2016 Forum Guidelines - Please Read! Welcome to the StarCraft II discussion forums! This forum is here to provide you with a friendly environment where you can discuss all aspects of StarCraft II with your fellow players. Community forums work best when participants treat their fellow posters with respect and courtesy. Therefore, we ask that you take the time to read through the Forum Code of Conduct before posting. Search The new search function at the top of the StarCraft II community site is extremely robust. Please be sure to use it to look for similar topics, blog posts, or web pages that may contain the answer before creating your forum topic. Making a new thread on an existing subject will likely result in your thread being deleted. If you continue to repost it you're likely to have your posting privileges suspended for spamming. Worst of all, you'll be making the other forum goers upset that you didn't take a minute to search before posting. Rating The new rating system can be used to promote positive discussion, and demote unhelpful posts, or even report posts that violate the forum code of conduct. By hovering over a post you'll be presented with a thumbs up, and a thumbs down icon. Clicking the 'thumbs down' icon you can choose from a few options. Dislike will rate the comment down. If enough people dislike a post it will be darkened, or with a lot of dislikes it will be hidden. You can also quickly report a post as trolling or spam, or use the report function to fill out a more comprehensive description of the violation. You can only rate each post once. Use it wisely to help foster a positive and helpful forum community. Guidelines In addition to the Forum Code of Conduct, here are some common courtesy guidelines to follow. While these do technically fall within the bounds of the Code of Conduct, these cover more specific examples of common errors that will lead to thread deletions or posting privileges being revoked. The StarCraft II forums are for discussion of topics directly related to StarCraft II The forums here are specifically to discuss the game and related topics. Any topics not related to StarCraft II, or Blizzard are subject to deletion. Don't post in all capital letters, use a misleading title, excessive punctuation, non-standard symbols, etc. While everyone wants their posts read, we ask you to refrain from using these types of tactics in order to bring more people to your thread. Let your post stand on its own merit. Threads violating this guideline are subject to deletion. Using the words Blizzard, Blue, or any community team members name in a thread topic is frowned upon Everyone would like Blizzard to read and acknowledge his or her post, and we understand that. However, use of such words in the topic does not help that come to pass. Please make your thread title relevant to the post subject. Threads violating this guideline are subject to deletion. Posting "First" or IBTL constitutes as spamming You will be suspended if you create a post that is intended to call out that you achieved a specific reply number in a thread. This is considered spamming. Posting IBTL (in before the lock) is not helpful and if you feel a thread should be moderated please use the rating button to do so. Do not bump posts The act of posting simply to bump a thread is considered spamming. This also includes bumping very old threads for no reason (called 'necro bumping' or 'necroing'). Petition posts are frowned upon These are discussion forums, and as such we ask that you hold discussions. Creating a thread to ask for replies as votes is not a discussion. Threads violating this guideline are subject to deletion. Do not post about locked or deleted threads Posts that are moderated have a reason behind the moderation. It's up to you to read the forum code of conduct and these guidelines to determine what you did wrong, learn from your mistake, and attempt to post again without breaking any rules.Rackle0 Oct 24, 2016
May 17 Python code:find race of current player? I was wondering if anyone could help my do something seemingly simple. I need a python script to detect the race of the current player. That's all. I'm not a major programmer, and i've tried to look in the docs for dentosal's python sc2 library, but all i see is a bunch of examples that, out of context, make no sense to me. I just need a line for python to return the race of the current player. Anyone have any ideas on if this is even possible for a live match?Cptnkoala1 May 17
May 7 Compile error help please i have error Assertion failed: == info.width * info.height, file e:\sc2bot\commandcenter\src\maptools.cpp, line 583 when compiling What is the porblem?luckeri0 May 7
Apr 16 Allow Referee|Observer Mode in Public Lobby Allow Referee & Observer Mode in Public Arcade Lobby Currently, you must click the 'create' lobby button to make a private lobby (not public lobby) in order to change players into a referee/observer. Please allow the referee/observer option within public a lobby. Currently, the referee option is disabled within public lobbies.TerraAzure1 Apr 16
Mar 6 Settings on script run Hi, Is there any way to set the settings for the game upon the script running. Im getting pretty tired of changing the game back to fullscreen on every run (I'm testing my bot against myself). Im using the python library sc2 if that helps.Swoop0 Mar 6
Feb 6 Test our SC2 Api Bot VS Human Hello, I want to test my SC2 Bot via SC2 API against real human. What is the best way to do it ? Can I upload my bot to a custom mod in SC2 ? Do I need to deploy my bot to a server for human could connect to the game ? Or the only way is to play on the same computer like mp_bot example ? Human are not neccesary in my city so it will be fine to find a way to do it via Internet with a simple protocol. Thanks for your response.Warth0 Feb 6
Jan 31 Visualization in Linux Hello there! OK, I've just built all necessary sources in Linux Mint. When I start one of examples (sc2client-api/build/bin/bot_simple, for example) I can see the log of some games. But I can't understand how it really works inside. Is there a way for Linux to visualize what happens there? Thank you in advance.Arcoon4 Jan 31
Jan 30 Possible? - An AI that plays on the ladder? Or is there no way to connect the AI to the ladder? If I were to create one I would want to test it against real players and see what rank it can achieve. I have no clue how this could be done though.NinjaNight5 Jan 30
Jan 10 Non-AI related API What I am interested in doing is using the SC2 API to create Twitch overlays (I don't know what kind, as I don't know what data is even available, yet...I understand there is potential for abuse/cheating; that is not relevant to my question) for SC2 streamers (i.e. normal client unranked or ranked games). There was a forum post back when the API was first released somewhere (that I can no longer find) suggesting this was possible (it mentioned "building tools for human players"), but I can't find any information on it whatsoever, nor can I get the normal game client to run in such a way that I can connect to it via websockets. I've run out of ideas to try; I'm assuming that it is, in fact, impossible, but it'd be nice if I could get someone who has some experience with the API confirm that it's impossible, or, if not, help me get started.Omega1 Jan 10
Dec 10, 2018 The Infamous "Entering Lobby" Bug I am experiencing the "Entering Lobby" bug, which I thought would be fixed in the past 2 years. It's happening to everyone! I've asked 10 different people on my friends list who play arcade and they all experience this issue! It occurs when I'm playing in a party or playing alone and want to join a game, I'm stuck in "Entering Lobby" for a long time. It happens on average 1/5 times playing arcade. I have to restart my application after every game I complete. Is this bug ever going to get fixed? any workarounds?NastyNate0 Dec 10, 2018
Nov 18, 2018 How can I find user's Profile ID? In this case, how can i find user's id like '3930043'? Can i find that value with battletag?Dayever2 Nov 18, 2018
Nov 4, 2018 Complex World Editor Engine Change Request Hello, I posted this on the galaxy editor forum, but got the suggestion to post it here based on the changes to the engine that would be needed. There are two types of maps/mods that I really have a desire to create that are quite unique compared to what's currently available on the arcade. Unfortunately, both ideas require new features to be added to the editor: 1. Allow a near-unlimited number of AI players to be added. If there are server issues, then make all AI take from the same APM pool so that it can never be exceeded regardless of the number of AI players. 2. Allow pre-loading of sub-maps. For example, I'd like to create a standard interface between many maps, and at game launch, tell the server which ones to load for this round. I'd like to be able to choose (randomly in my case) multiple maps in a larger pool of maps that adhere to the interface I laid down. Then start the players on a particular map and give them the ability to 'teleport' to another map (with the same effect as if they just teleported to another point on the same map; no load times and not every player has to be teleported). I think these two features would open up an enormous amount of new player-created content, and would certainly not just be for me. ;)Frosty0 Nov 4, 2018
Oct 19, 2018 RequestAvailableMaps returns no maps Im having trouble with maps. First, I never see any .SCMap files downloaded, either after playing ladder games or custom games. So I downloaded the maps here: But RequestAvailableMaps keeps returning an empty list. This is Windows, and I start SC2 with: Target: "C:\Program Files (x86)\StarCraft II\Versions\Base56787\SC2_x64.exe" -sso=1 -launch -uid s2_enus -listen -port 999 Start in: "C:\Program Files (x86)\StarCraft II\Support64" I tried putting them in a Maps directory under c:\Program Files (x86)\StarCraft II, and I also tried them in a Maps directory under c:\Program Files (x86)\StarCraft II\Support64. I tried using full paths like "C:\Program Files (x86)\StarCraft II\Maps\ None of these causes RequestAvailableMaps to return anything. Any idea what I might be doing wrong? AndyPinkFreud3 Oct 19, 2018
Oct 11, 2018 Any way to write a Starcraft2 AI myself? any tutorials or links or ANY resources? I went to this site: but it only had other stuff and didn't have instructions how to write my own SC2 AI that can fight against humans.SmrtAsianGuy2 Oct 11, 2018
Oct 5, 2018 SC2 AI Framework for C#, F# and Python Hi StarCraft II community! We are developing a Framework for writing AIs for StarCraft II in C#, F# and Python as part of our bachelor thesis at the IT University of Copenhagen. It is meant to remove some of the hassles of working with the official C++ API, while still allowing developers full control and direct access to all commands available in the official API. Another key design feature is modularity - enabling developers to write a very small module and easily have it up and running with other already implemented modules. We are going to launch the first version of the framework in just over a month and will gather feedback to improve and evaluate the project. If you are interested in hearing more and maybe help test our framework (or would like to help us understand the SC2 community better) please fill out this short survey: We will provide documentation and 'get started' tutorials before launch! Sincerely Jens Schmidt & Mikkel Lamhauge BSc Students - Software DevelopmentSchmidt4 Oct 5, 2018
Aug 8, 2018 Linux headless is so outdated The last version available to download at is the 4.1.2. Was the support to linux dropped? What is happening?SparFoo0 Aug 8, 2018
Aug 5, 2018 Linux support? I see only support for Windows and Mac. Any support for Linux? Or anyone successfully tried it on Linux?StLiu7 Aug 5, 2018
Jul 21, 2018 loading old replays reliably via API I haven't found an elegant solution though to ensure map VERSION used for in match/replay is the same as the what's supplied as mapdata in the SC2APIProtocol.RequestStartReplay. Kevin@Blizzard clarifies that watching replays with the intended map is necessary in this post: This is fine for loading the initial 3.16* replay packs or for replays created using the same machine, map version, client version, etc. that the match was played on just fine. However, when downloading maps via the developer's API ( ), the maps aren't provided with these replay packs. Nor are they available in the replay packs from WCS, such as the recent 2018 WCS Valencia replay pack ( ). If I load the replay directly using the regular client, the replay loads and plays just fine. The problem is when attempting to load using a versioned client (i.e. ...\Starcraft II\Versions\Base#####\...) using the client protocol -- somehow loading the map data fails. For example, if I load the replay between Has and Serral in the WCS Valencia finals on the map "Catalyst LE" using client version, the protocol replay request I'm using has this basic information: observed_player_id: 1 options { raw: true score: true feature_layer { width: 24.0 } } replay_data: <binary data from Catalyst.SC2Replay> map_data: <binary data from Catalyst LE.SC2Map> The SC2 client then responds with this message: ... I also poked around this replay file using Blizzard's s2protocol ( ) tool using python2.7. From the decoded mpyq file contents, there seems to be precious little that might have anything to do with the map. The info below is all I could find... nothing that seems to suggest the needed map version. Sample decoded mpyq data of "Catalyst LE.SC2Replay" between Serral & Has: ... Is there a reliable way to get the version of the map that the replay was played with? Both version and actual map binary data for that version? How can these replays load using the s2protocol API to extract in-game observation info? issue posted on GitHub: Jul 21, 2018
Jul 21, 2018 Historical versions to load previous replays? We rely on extensive replay data to train our AI agent. However, SC2 by design can only load replays from the latest version (version/base####/sc2.exe) and every update deletes the previous version's executable. Anyone knows where I can download historical base#### for AI replay analyzing purpose?GritBear1 Jul 21, 2018
Jul 14, 2018 Accepting surrender I am playing around with the SC2 API both in C++ and in Python. The Python version regrettably has no action that allows you to accept when an AI want to surrender so I am trying to figure out if there is something along those lines available in the C++ version of the library. Can someone point me in the right direction? Kind regards.DrkNess3 Jul 14, 2018
Jul 12, 2018 GetUnits() sc2::Filter example? I have been trying to use a filter with Observation()->GetUnits, but so far everything I try fails. The documentation says to use a functor of lambda function, but neither of the ways I usually do these seems to work, and I have not found any examples of how to write a filter. Has anyone discovered how this is to be done? I hate to just get a vector of all the objects and then winnow them the hard way. I would be forever grateful if anyone could share an example of a working custom filter other than the standard ones provided like isVisible().Arachnya1 Jul 12, 2018
Jun 10, 2018 Your Development Update - April 16, 2018 Following up on the post from a few weeks ago, it seemed like a good time to check in with everyone to see what's going on in StarCraft community dev. Reply with what you have been working on or any issue you have run into recently! My Update I got co-op support working for sc2reader and have got it working with the spawningtool library as well. Unfortunately, there are a lot of special cases with co-op to handle. There are a ton of new units and upgrades to label and map, and different commanders have talents that change build times, so I have to account for that, too. I have been mostly mining for these by hand, but if anyone knows an easier way to automate that process, that would be helpful.StoicLoofah7 Jun 10, 2018
May 28, 2018 Build and run examples without VS I'd like to know if there is a way to build and run the API without using Visual Studio. The file only shows what to do if you are going to use Visual Studio, the thing is that I feel more comfortable using others IDEs, like CodeBlocks, Sublime Text, etc. Maybe this is a silly question, but I don't know how to do it.Tobías0 May 28, 2018
May 25, 2018 combat mini-games I've been looking for somebody that's created a bunch of maps that will aid an AI to learn how to do combat. pysc2's marines vs. roaches is one thing, but it's extremely limiting compared to the real game. What really seems to be needed is a bunch of different combat scenarios involving many different units across various map situations such that two players (built-in bot or agent) can mash them against each other repeatedly to learn what seems to work best. Hasn't anybody done this yet? If not, is anybody willing to collaborate and create such a repository of combat maps/scenarios?fatz3 May 25, 2018
May 22, 2018 Question about accurate unit statistics Sorry if this is the wrong place to post this, if my post is in the correct location please let me know and I'll repost in the proper place. I am trying to make an ai that accurately micros terran reapers, but to do this I need to be able to encode the precise stats about the unit eg. max speed, acceleration, turn speed, etc. I am currently getting these numbers from reapers created in the map editor - the data source for these reapers is 'Void.SC2Mod'. My question is how accurately the unit stats found in the map editor correspond to the unit stats found in a multiplayer game of StarCraft2 played today. I noticed that some of the numbers found in the editor do not match some of the numbers I have found online. For example, liquipedia lists reaper health regen as 2.8hp/second under combat drugs (, but reaper life regen in the editor is listed as a flat 2. Which number is more current, and what would be the best source for finding accurate unit statistics?ppfishstick2 May 22, 2018
May 19, 2018 How to hook an agent to a custom game lobby? If you want to start a custom melee game and have an AI play in it how do you do that?NinjaNight1 May 19, 2018
May 11, 2018 Parse replays without relaunching the client Hello, I'm creating a program that extracts build orders from replays. I'm only interested in the first 5 minutes of the game, so I call the update function (22*5*60) times. To move on to the next replay, I currently recreate the coordinator and the replay_observer, which quits the game and launches the client again. This process is naturally very slow, and a bottle neck in the system. I was wondering if there is anyway to quit a replay early and start a new replay with the same client. If so, could you please point me to an example or methods I need to use? Thank you!FiNDoL1 May 11, 2018
Apr 30, 2018 How to start sc2 in command line in Windows? I installed sc2 in D:, then ,I run "D:\sc2\StarCraft II\Versions\Base58400\SC2.exe" -listen -port 5000 -displayMode 0 In command line console. But it cannot start with error message like: ... What did I miss?neoooooooooo4 Apr 30, 2018
Mar 29, 2018 Your Development Update - March 26, 2018 Having not been particularly active in this community, I thought it would be fun to have a semi-regular (maybe biweekly thread) where everyone can reply with what they are currently building with the StarCraft 2 API or other related projects. Maybe it will surface some common issues that we're running into. At a minimum, I'm just curious what interesting things you guys are doing! Here's my update: Currently, the spawningtool replay parsing library does a decent job with normal ladder replays, but it doesn't give useful results on co-op games. The first step is recognizing co-op replays, which is an open issue in s2protocol . After that, I need to address some issues with sc2reader, then add a lot more unit types and upgrades as recognized types. What are you guys working on?StoicLoofah1 Mar 29, 2018
Mar 20, 2018 No Maps folder in SC2 Directory? I checked my Starcraft II folders (Windows 10) in C: ProgramFiles(x86) and Documents and neither one has a folder called maps. I'm stuck because to get pysc2 up and running there's supposed to be a maps folder in C: ProgramFiles Starcraft II where you extract their maps, but I don't even have this. What can I do?NinjaNight2 Mar 20, 2018
Feb 28, 2018 blizzard should upgrade the engine there is periodic graphical updates of StarCraft 2. blizzard should boost multicore performance. they could for example run the internet Connection separately from the rendering(on separate cores). for example Connection on 2 cores and rendering on 2 cores. is you have suggestion to how the engine can be further upgraded please post them here.andreasasp0 Feb 28, 2018
Feb 18, 2018 gameloop travel time between map points Is anybody willing to share code that calculates actual in-game travel time for a given unit to a target (global/raw) destination? I don’t know exactly what Blizzard’s implementation is to solve this in-game automatic pathing problem. I suspect it’s some variation of A* search algorithm, be it Dijkstra’s algorithm or something else. I haven’t implemented this before (my current solution is very crude) and I have so many other AI problems to solve too. Yet, it appears that my AI’s decision making is much better if also being able to account for predicted movement time. But I do know my crude solution isn’t adequate; better accuracy is needed. I figure this problem is sufficiently common that others may have already solved it and perchance somebody might be willing to share the code! Perhaps being a bit naive, I included some outlined requirements below for what this function would need to do. Your contributions are greatly appreciated! General requirements: Even if there’s somehow a more efficient/faster solution, I need the reported answer to match actual game time. A general algorithm isn’t helpful unless it’s been proven to ~accurately mirro Blizzard’s. The algorithm must be obtained wholly within the agent/client process. I must assume I cannot query the sc2 game process even if this algorithm is available externally from there. (It’s too slow to make this query with inter-process communication.) Map obstacles must be taken into account, including dynamic obstacles (such as whether rocks are destroyed or not, where impassable buildings are placed, whether mineral nodes are depleted, etc.) In other words, do not assume the map is static. The map state is dynamic. Handle air units differently from ground units; their pathing rules are different. A solution in any programming language is okay, though compatibility with the provided SC2 API is preferred (i.e. python or C++). Inputs: moveable_unit: A unit definition (which also defines its source location, unit type, which also dictates speed, acceleration, turning rate, air/ground movement type, etc.) target_destination: a world map location: (x,y,z) -- although z is optional as we’re clicking on a 2-d screen. map_creep: a worldmap grid defining whether creep is present or not. NOTE: I’m using a worldmap grip as represented by SC2’s observation response, one point for each (x,y) whole value, restricted by actual map dimensions. Example: a 240x180 map would be represented as an array containing 240*180 = 43,200 points. Also, it is unclear to me whether further resolution is needed to truly resolve this problem. map_state: a worldmap grid defining whether the each grid point is ‘passable’ or not. …. Additional input you require is okay. Outputs: The number of gameloops (integer) required for a given unit to reach the intended destination. NOTE: a value that can be converted into a gameloop is also okay (such as milliseconds). Exception-handling: Desired destinations which are non-pathable must reflect an appropriate value (infinite gameloop value, a generated exception, etc.). Bonus points: (not required for general application, but for an optimal algorithm, these requirements would also be handled) Account for altered pathing rules when loaded into a transport (or a non-moveable transport, such as a bunker). I.e. an overlord transport may move at a different speed than a Zergling. Account for alternative map shortcuts, such as Zerg nydus canal or abilities such as Battlecruiser hyperspace or Protoss recall. Account for temporary speed modifers such as creep for select Zerg units, movements impairments such as stasis or fungal growth, or boosts such as medivac boost. Make no assumptions about specific game unit definitions. Alternative game versions may define units differently (different speeds, different abilities, etc.). These should be pre-determined by provided game unit definition(s). Handle exotic movement types such as reaper cliff jumping and colossus walking. This may also necessitate knowing whether a cliff is jumpable or not, but it is unclear to me how to retrieve this information in-game. Identify whether movement is additionally impaired (or impeded entirely) by other units blocking the way. NOTE: workers with gathering orders appear to ignore these movement restrictions.fatz6 Feb 18, 2018
Feb 15, 2018 Making a helpfile of available actions I was wondering if there was something like this yet (or a search of some kind to go through each action) otherwise I am planning on making one.TonyP4 Feb 15, 2018
Feb 15, 2018 unit_type_id of 373 In an Observation, one of the units that I see has unit_type_id value of 373, which I don't see listed in enum class UNIT_TYPEID. What kind of unit is it?PinkFreud3 Feb 15, 2018
Jan 2, 2018 Blacklist API (Export/Add/Clean) ??? My blacklist is full ((( I need save current blacklist and clean it for new "players". How can i make it so ? Can anyone explain. How export my own ingame blacklist ? How to get blacklist in any text format ? How ?lllllllllll8 Jan 2, 2018
Dec 25, 2017 PySC2 Sparse Reward Agent Tutorial Dec 25, 2017
Dec 20, 2017 API for automated tournaments Hi there, I have a newly created Tournament Platform. We run automated tournaments for video games of all kinds. We would like to implement SCII as one of the games we host tournaments for. From what I've read there is no sort of tournament API that will generate any type of lobby codes for players or an automated way to have the API call back match results. What would be the best use of the API or other functions of Blizzard/ to facilitate some sort of automated tournament system? Is there a lobby/tournament code system I do not know about? Can you create password protected / certain user only lobbies? Is there an automatic call back for match reports, or would we have to call the API after a player reports a match as being finished? Any other ideas / advice?ForbidenSoul0 Dec 20, 2017
Dec 7, 2017 Best way to get the entire state of a replay? Real title: What is the best way to get the entire game state of a replay at a specific time? I don't see any straight forward way to do this, so I'm planning on building an API for it, but if someone from blizzard could help me get started, that would be great. I basically want to make this function: GameState getGameState(Replay, Time) Where GameState includes everything, including: All units, and their health and location All structures and their health and location The various scores of both players The visibility of each unit and structure from the perspective of both players The last-seen visibility data for structures, and if it's possible, the last time it was seen* *What I mean by last-seen visibility is how when a structure stops being visible to a player, the player can still view that structure on their map. Also, I don't mind doing the calculations, but if there is a built in way to determine the exact time when a structure went invisible to a player, that would be helpful I see there are a lot of classes in the API that seem to provide the data I need, but there are very few examples that I can find on how to use them. And from what I can tell, when viewing replays, the only way to move through a replay is by stepping rather than just going to a specific time. Do replays have to be calculated from the beginning of time or something? If someone helps me out, I will publish my work publicly so others can make use of it. Thanks in advanceBlix2 Dec 7, 2017
Dec 4, 2017 Which position should I use for Assimilator ? Hi ! I'm currently trying to make my probes build an assimilator but they're acting like they can't go on the geyser. I used the debug interface to ensure the position is correct but my probe are acting like they can't reach the geyser. How should I do it ? if (structure == UNIT_TYPEID::PROTOSS_ASSIMILATOR) { const Unit* geyser = FindNearestVespeneGeyser(unit_to_build->pos); DebugInterface* debug = Debug(); debug->DebugSphereOut(geyser->pos, 1.0f, Colors::Green); debug->DebugSphereOut(unit_to_build->pos, 1.0f, Colors::Red); debug->SendDebug(); rx = geyser->pos.x; ry = geyser->pos.y; } Actions()->UnitCommand(unit_to_build, ABILITY_ID::BUILD_ASSIMILATOR, Point2D(rx, ry)); const Unit* FindNearestVespeneGeyser(const Point2D& start) { Units units = Observation()->GetUnits(Unit::Alliance::Neutral); float distance = std::numeric_limits<float>::max(); const Unit* target = nullptr; for (const auto& u : units) { if (u->unit_type == UNIT_TYPEID::NEUTRAL_VESPENEGEYSER) { float d = DistanceSquared2D(u->pos, start); if (d < distance) { distance = d; target = u; } } } return target; }MetalKitten2 Dec 4, 2017
Dec 1, 2017 Selecting Units I know we can see if individual units are selected (unit.is_selected) but I'm failing to find the ability to select units. Can someone point me in the right direction please?MacAttack1 Dec 1, 2017
Nov 23, 2017 I just drop it here Yo. I don't know whether it is appropriate to write about it here, but I did not find a more suitable section of the forum so... That's what it is, I tried to reassign the hotkey commands on the mouse scroll and found that it was impossible. And nevertheless, it seems to me that using the mouse scroll for example to switch subgroups would be much more convenient. And, in connection with this, I would like to leave this post here, as a suggestion to introduce the ability to use mouse scrolling as hotkeys. I really think it's a good idea. Sorry if this is not the appropriate section of the forum. I'm still not good at this.smellthemgc0 Nov 23, 2017
Nov 21, 2017 Bots in separate processes with C++ I would like to have my bot (written in C++) play against another bot in a different process. This is the same question as in, but for C++. Does anyone have an example for how to do this? I am trying to figure it out from the documentation at in the "Play two bots against each other" section along with the answer to the topic above, but I am having trouble converting the code to C++. Here's my latest attempt in case it helps: int main(int argc, char * argv[]) { Coordinator coordinator; coordinator.LoadSettings(argc, argv); Bot bot = Bot(); // Initialize the bot's ControlInterface? coordinator.SetParticipants({ CreateParticipant(Race::Random, &bot) }); // Port configuration from Ports ports; ports.shared_port = 5002; ports.server_ports.game_port = 5003; ports.server_ports.base_port = 5004; PortSet p1; p1.game_port = 5005; p1.base_port = 5006; ports.client_ports.push_back(p1); PortSet p2; p2.game_port = 5007; p2.base_port = 5008; ports.client_ports.push_back(p2); // I am running the game manually from another console. coordinator.Connect(5000); if (!coordinator.CreateGame("Melee\\Flat48.SC2Map")) { return 1; } if (!bot.Control()->RequestJoinGame(CreateParticipant(Race::Random, &bot), InterfaceSettings(), ports)) { return 1; } while (coordinator.Update()) { } return 0; } I think the client should be the same except it wouldn't call CreateGame. When I run this code, it connects to the game and then exits successfully without waiting for the other bot to connect. What am I missing?arlyngelei4 Nov 21, 2017
Nov 19, 2017 C# - how to use Action class for Training Hello Folks! I tried to use the C# extension of the API found here (, but couldn't really implement any BOT functionality with success. I assume I don't use the main iterating function properly, but without any documentation or source code, I couldn't figure out how to. For starters I'm trying to train an SCV in the Command Center, but nothing is happening. You can find my whole code below in the first comment, please advise me how to fix it. I would be most thankful for a full guide/example similar to the C++ ones (Build SCV, Build Supply Depot, Train Marines, All Combined: Marine Rush). As far as I know, there's none. If I get so far with the help, I'm determined to write those for common use. using Starcraft2; using SC2APIProtocol; using Google.Protobuf.Collections; using Action = SC2APIProtocol.Action; namespace Coop_Mind { public enum BuildingID { CommandCenter = 18, } public enum BuildingTrainingID { SCV = 524, } class Program { static void Main(string[] args) { Sc2SettingsFile.Sc2SettingsFile userSettings = Sc2SettingsFile.settingsFromUserDir(); Instance.StartSettings instanceSettings = Instance.StartSettings.OfUserSettings(userSettings); Func<Instance.Sc2Instance> createInstance = () =>; Sc2Game.Participant[] participants = new Sc2Game.Participant[] { Sc2Game.Participant.CreateParticipant( createInstance(), Race.Terran, MasterAgent_MainLoop), Sc2Game.Participant.CreateComputer(Race.Terran, Difficulty.VeryEasy) }; Sc2Game.GameSettings gameSettings = Sc2Game.GameSettings.OfUserSettings(userSettings) .WithMap(@"Ladder2017Season1\AbyssalReefLE.SC2Map") .WithRealtime(false); // Runs the game to the end with the given bots / map and configuration, participants)); } public static IEnumerable<Action> MasterAgent_MainLoop(GameState gameState) { Action answer = new Action(); Observation newObservation = gameState.NewObservation.Observation; MapState map = newObservation.RawData.MapState; RepeatedField<Unit> allUnits = newObservation.RawData.Units; ulong? unitTag = null; int i = 0; while (unitTag == null && i < allUnits.Count) { if (allUnits[i].UnitType == (int)BuildingID.CommandCenter) { unitTag = allUnits[i].Tag; } i++; } answer.ActionRaw = new ActionRaw(); answer.ActionRaw.ClearAction(); answer.ActionRaw.UnitCommand = new ActionRawUnitCommand(); answer.ActionRaw.UnitCommand.AbilityId = (int)BuildingTrainingID.SCV; answer.ActionRaw.UnitCommand.TargetUnitTag = unitTag.Value; yield return answer; } } }mgherry1 Nov 19, 2017
Nov 15, 2017 Watching old replays Can you use the API to bypass a glitch in order to watch old replays? When I mean older replays I mean replays that are 5-10 months old.Shaneman1 Nov 15, 2017
Nov 14, 2017 PySC2 Attacking Agent Tutorial My latest tutorial is available here: You can learn how to use reinforcement learning to enable your agent to attack the enemy.UnciePooh0 Nov 14, 2017
Nov 9, 2017 Remote SC2 API To Retail SC2 Will I able to have SC2 retail running on mac and use SC2 API on linux (another machine) to connect to this windows / mac client ? Thanks. And how do I start SC2 command in Mac ?CHC0 Nov 9, 2017
Nov 9, 2017 SC2 Developer Bnet Social Group! Hi all! If you're a SC2 dev, we have a new Bnet Social Group dedicated to SC2 developers. It's a small group of us at the moment, but with a wide range of experience! Come join and help bring the SC2 custom and AI scene together! Let's share and help each other build awesome and innovative content for the community! Also general game devs, artist and enthusiasts welcome! Nov 9, 2017
Nov 6, 2017 Weapon Cooldown not set for enemy units Quick question: I noticed that the weapon cooldown is always 0 for an enemy unit. But, the c++ documentation says: //! Time remaining for a weapon on cooldown. Not set for snapshots. float weapon_cooldown;Under the heading: // Not populated for snapshots weapon_cooldown is not under the heading: // Not populated for enemies/snapshots Is the documentation incorrect for this or should weapon_cooldown be set for enemies? I was hoping to use weapon_cooldown to know if an enemy army is actively fighting or move-commanding away, as well as when certain important enemies (such as siege tanks) have fired and left an opening to attack.Dalas1 Nov 6, 2017