Starcraft 2 AI Tournament announced

The twitch channel Inside the Champ has featured some Starcraft 2 AI related streams, talking to some of the people from the community. Here you can find their twitch and youtube channels. They have announced on discord that they are going to organise a Starcraft 2 AI tournament. The tournament is to be held somewhere at the end of June. It will be the first Starcraft 2 tournament since the ladder stopped featuring seasons. It will also be the first tournament for my bot to participate in.

In the meantime I am working on new features for my bot. The last game on the ladder, against HjaxAI ended in a timeout. My bot managed to destroy the enemy’s main, but it had already expanded. My bot didn’t bother to look for the new expand. Instead the Zealots just danced around on the ruins of the Zerg base. I have already created a fix for this, so my bot will start looking for expansions when the opponent main has been destroyed.

I have also set up the code necessary for my bot to take expands and gasses, and to manage the workers to mine from those new bases and Assimilators. I am now going to improve my building placement code. I hope I can get all the necessary features in before the tournament!

First results are in

My bot has played its first few games on the ladder! Already there are some interesting results. It won just one game out of the five games played so far. Three of the losses were against the top two bots, 5minBot and tscmoo. It won one game against 4raxBot, but it also lost a second game.

Tyr vs. 4raxBot

In the game against 4raxBot that I lost, 4raxBot kept its Marines as a single group at home before moving out. My Zealots went in one by one and got killed easily. In the other game, however, 4raxBot sent its Marines one by one, allowing my Zealots to kill them easily. I’m not sure why 4raxBot behaved so differently in the two games, but I am happy with the win!

Tyr vs. 5minBot

In the first game against 5minBot, my bot actually managed to do a lot of damage. I managed to kill a fair number of SCVs before he got his bunker up. When he finally did get it up, I was ahead by four workers, although he was ahead a base. My Zealots a-moved into the bunker one by one, though, and got themselves killed. So the rest of the game was an easy victory for 5minBot.

In the meantime I am continueing work on my bot. I am working on some basic infrastructure, such as the BuildOrder and Task systems I mentioned in a previous post. I also wrote code to recognize expansions on the map and to figure out the correct placement for a base. Next up: fixing worker management when building multiple bases.

Blank example bot

For anyone who is also interested in creating their own Starcraft 2 bot in C#, I have created a GitHub repository with an example bot. Just follow the instructions in the README and you will have a bot ready to play on the ladder! Now that this is done, I will get back to improving my own bot. GLHF, and I hope to see you on the ladder!

It’s alive!

I have finally managed to get my SC2 bot working with the LadderManager! I have uploaded the bot to the ladder and hope it will be online soon. I haven’t been able to get the LadderManager itself working on my own PC, but thankfully Archiatrus has tested it for me on his machine. He also told me that my bots first game against tscmoo was a win. Double success!

Thank you Archiatrus, for all the help with testing, and for giving me the final hint I needed to fix the problem!

The current version of my bot is very simple. It builds zealots and a-moves them to the enemy as soon as they finish. It doesn’t know how to expand, or how to make anything other than zealots. I expect that there will be a number of bots vulnerable to this kind of aggressive strategy, however I still expect the better bots to be able to hold it off.

There is also still a bug, where my bot tries to place a Gateway outside of the power grid. I do have code to check if this is the case, but it doesn’t seem to work correctly.

I am very curious to see where my bot will end up on the ladder once I fix the bug.

Stone and Iron

Stone is a Brood War bot which performs an SCV rush. It first came to the scene in 2015, but its first tournament didn’t go very well. It ended 19th out of 22 during AIIDE 2015. The next tournament was SSCAIT and here it did much better, getting 3rd place.

Despite the somewhat silly strategy – on paper a worker rush simply should not work – it is still a very strong opponent. The SCV micro is absolutely amazing, attacking the enemy worker line and retreating when too many of the workers start to fight back. It also makes very good use of repair to keep its SCVs alive. Due to the great micro it gives many bots problems.

Igor Dimitrijevic, author of stone, was not done yet, though. After Stone, he started working on his next bot, Iron. Iron does play a full strategy instead of just a worker rush. It has some interesting skills. For instance it knows how to build a wall and float his command center to the natural. Its truly amazing aspect is its Vulture micro. The Vultures are amazing at picking of single units that get too far away from the rest of the army. They constantly harass the opponent and whittle them down little by little. They also know how to do the occasional runby.

Combine the deadly vultures with a strong tank push and you have the nearly unstoppable bot that is Iron. It managed second place during its first tournament, CIG 2016 and it got first place at AIIDE 2016. It led the SSCAIT ladder for a time in 2017 and since then it has rarely dropped below second place.

I believe that the key to Iron’s success is the attention to detail. It only realy knows one strategy; Terran mech, but it has refined that strategy to an art.

Plans for SC2 Tyr

Work on my Starcraft 2 bot is still slow going. Mainly because I want to write it in C#, and I am having trouble getting the dotnet SC2 API to work together with the ladder manager and with Starcraft 2 itself. I do still plan to make it work, though. Right now, I want to talk about my plans for the structure of the bot itself. Specifically, I will talk about which parts of my Brood War bot I intend to use for my SC2 bot.

Two main components of my Brood War bot are Tasks and BuildOrders. A Task tries to accomplish a goal using a select set of units. For instance a task may be to attack the opponent with the entire army, or send out a small drop to the enemy. There can also be a task to send out a single worker to scout for the enemy base. There can be multiple tasks active at the same time.

The second component I mentioned was the BuildOrder. The BuildOrder determines what the bot builds and when. Unlike what you would normally consider a build order, it also makes some high level decisions about when to attack, whether it should harass, what kind of units to harass with etc.. It doesn’t control the units for an attack itself, but it uses the Tasks to do this. The BuildOrder gets to turn Tasks on and off as it sees fit, to accomplish the goals it needs.

I put the actual build order together with the high level decisions because they are often related. When I have an aggressive build, I want to attack the opponent much sooner then when I have a macro focused build. If I want to, say, harass the opponent with Zealots, then I need to make sure to build the Zealots in time.

This abstraction of a BuildOrder and a number of Tasks works very well for me. When I create a new build for my Brood War bot I can usually manage with one new BuildOrder, perhaps a few Tasks. I usually need to change very little in the rest of the code. I hope that these will work as well for the Starcraft 2 bot.

Steamhammer

The previous post was about UAlbertaBot, this post will be about its descendant, Steamhammer. Steamhammer is programmed by Jay Scott. Jay also writes a blog, which I definitely recommend if you enjoy mine.

One of the things I find interesting about reading Jays blog is that it gives you an insight into how he approaches programming Steamhammer. His approach is to focus on solid improvements over quick and dirty fixes. Now this might seem like an obvious approach, bot there are a lot of bot authors which like to take a shortcut, myself included. The development method for Steamhammer means that improvements will take longer to become apparent in actual playing strength.

When I am programming my bot and a tournament is coming up, I usually take the approach of picking one opponent I currently lose to and try to figure out what I might do to beat them. This approach obviously pays off for the tournament. I can now beat one more opponent and will get a better score. However, in the process, I might ignore weaknesses or bugs which do not obviously cause any of my losses. In the long term, those bugs may hold my bot back.

Due to the solid approach in building Steamhammer, it is very suitable as a starting bot. In many ways, it is a more refined and more solid version of UAlbertaBot. Because of this, there are a lot of bots that use Steamhammer as a starting bot. Here is a list:

  • Locutus
  • Microwave
  • 5Pool
  • Arrakhammer
  • Antiga

Note that each of these was also on the list in my previous blog post, since they are also descended from UAlbertaBot. Again, there may be bots I have missed.

Here are some of the improvements in Steamhammer, compared to UAlbertaBot:

Combat simulator

UAlbertaBot uses the SparCraft combat simulator, made by Dave Churchill, to determine whether it should take a fight or not. In Steamhammer this has been replaced by FAP, created by N00byEdge. Not all types of units are supported in SparCraft, which can be problematic. Some people use workarounds, like adding units of a different type, but this muddies the results of the simulation. FAP supports a much wider range of units. FAP is simpler, in that it uses a simple heuristic to determine the behaviour of units. SparCraft allows you to script unit behaviour. The simplicity does have the benefit of being much faster to run.

Build Order Search System

UAlbertaBot uses the Build Order Search System (BOSS)  to determine what units and structures to build. You tell it what sort of army composition you want and it gives you a build order of what units and structures to build in what order. This works well enough for Terran and Protoss, however it is somewhat lacking for Zerg. One of the difficulties of Zerg is that you need to react to what the opponent is doing, much more than the other races. You usually want to be droning up to get a good economy before building up your army, but if the opponent is attacking in full force you are going to need to build your own army much faster. BOSS is not well suited for these changes in plans.

Opening learning

Steamhammer has some of the most sophisticated opening learning of any bot. Most bots have a form of opening learning that only takes into account wins and losses. For instance opening 1 loses a lot against this opponent, but opening 2 seems to win often, let’s stick to that one. Learning openings this way takes a lot of games. Steamhammer actually analyses what strategy the opponent is going for. If it sees greedy play in the first game it will immediately counter with a rush play in the next game. This means it needs to try a lot fewer games to find a decent opening. During tournaments you only have a limited number of games, and any game you lose while trying to figure out what opening you should be using will cost you.

There are of course many more improvements between UAlbertaBot and Steamhammer. If you want to know more about it, go check out Jay’s blog!

UAlbertaBot

UAlbertaBot is a Brood War bot, written by Dave Churchill. It plays all three races. It is intended as a starting point for other bot developers. In fact it is by far the bot with the most ‘children’. Here is a list of all the bots I could find to be descended of UAlbertaBot:

  • LetaBot
  • WullBot
  • NeoEdmundZerg
  • AILien
  • NUSBot
  • Bonjwa
  • TerranUAB
  • Odin
  • Overkill
  • Flash
  • Steamhammer
  • Locutus
  • BananaBrain
  • Microwave
  • 5Pool
  • Arrakhammer
  • Antiga

Note that quite a few bots are actually based on steamhammer and only indirectly based on UAlbertaBot.

UAlbertaBot has been around for a long time, even getting the first place at AIIDE and CIG in 2013. Nowadays it is no longer among the top bots. It has however left a great legacy of bots.

For Starcraft 2, Dave Churchill has built the CommandCenter bot (which can also play Brood war, by the way). It too serves as a base for other bots. I am looking forward to seeing what bots we will see come out of it!

Human vs Bot matches: Starcraft2

My previous two posts were about human versus bot matches in the Brood War scene. This post will be about two human versus bot matches in the Starcraft2 scene. Keaneu Tan shared these replays about two weeks ago on Discord. The replays can be downloaded here. The bot is 5minBot by Archiatrus, which is currently at the top of the Starcraft 2 ladder.

The bot is called 5minBot because it goes for a 5 minute Medivac stim timing. The first game highlights two important weaknesses in 5minBot:

  • It doesn’t understand liberators.
  • It gets its workers killed trying to defend against cyclones.

To deal with liberators you need to stay outside of their liberation zone. 5minBot clearly has no concept of the liberation zone. It will happily keep its workers mining and send its marines inside the liberation zone to attack the liberator. This is understandable, since 5minBot is a fairly new bot (I am using Brood War bot standards; by those standards all Starcraft2 bots are fairly new). There are no other bots which use liberators, so little reason there to implement specific skills to defend against them. I suspect that for now, defending against liberators will remain a low priority skill to implement.

Proper worker defense is much more important. This is also something the Brood War bots do fairly well. Some of the weaker bots will send their entire worker force to defend against any attack, but the smarter bots will weigh their options. Can my workers even defeat this attack? should they try to stay away and hope they can survive? I expect that this skill will soon be improved in the Starcraft2 bots as well.

The second game features a proxy reaper opening by the human player. As I mentioned in my previous post, I expect to see Starcraft2 bots implement rushes, since they are easy to code and hard to hold off. In this game we see how effective a good rush can be. The reapers quickly kill all the worker of 5minBot, without suffering much damage. The game is easily won by the human player.

We have seen that there is still a long way to go, before bots can defeat human players in Starcraft2. Matches like these allow a bot programmer to improve obvious weaknesses. They also can give you ideas for creating a new bot. I would love to see a bot perform a proxy reaper rush, or for them to use liberators. Having bots use these skills will push the other bots to develop their defenses against them.

Human vs Bot matches: The end of rush humans?

The previous blog post I wrote about a number of matches between Iruian (the human player) and Krasi0 (the AI). LetaBot (Martin Rooijackers) commented asking whether Iruian could also beat his bot with a zergling rush. You may remember that Martin Rooijackers once wrote a blog post declaring the end of rush bots. He stated that holding off rushes is a solved problem for bots. Iruian took up the challenge and shared the replays on discord. There are 7 replays here, games one and seven Iruian 5-pools, games two and three he 5-pools and in the remaining three games he 9-pools.

LetaBot manages to hold off the 4 and 5 pools much better than Krasi0. He builds his bunker so that it protects the entire mineral line. He also builds his buildings close to the bunker. Occasionally buildings will be built outside of the range of the bunker. The marines are smart enough to not stay put inside the bunker though. They will move out to fend off those zerglings that try to attack, so that even the buildings farther away are protected. When the zerglings get to close to the marines, the marines retreat back into the bunker. LetaBot scores 4-0 against the 4 and 5 pools.

Against the 9 pool, however, he doesn’t fare so well. Iruian upgrades zergling speed and this allows his zerglings to pick off the marines as they try to retreat to the bunker. He methodically picks off a few marines and scvs before retreating. By repeating this again and again he manages to take out LetaBots defenses. LetaBot loses 0-3 to the 9-pool builds.

Admittedly, in his blog post, Martin Rooijackers specifically writes about holding off 4 and 5 pools and his bot does that very well. It is nice to see a bot play this well against it. Perhaps the next version of LetaBot will have an improvement to beat the 9 pool as well?