UED Bot

Starcraft 2 is one of the most loved real-time strategy games from Blizzard Entertainment. The UED Bot is a project that aims to create a Terran AI bot capable of playing Starcraft 2 at a competitive level. This project is built using C++ and leverages the Starcraft 2 API to interact with the game.


Project Overview

The UED Bot implements various game strategies to make intelligent decisions in real-time. The bot handles resource management, unit production, combat tactics, and strategic planning - all crucial aspects of competitive Starcraft 2 gameplay. UED Bot is an undefeated champion, securing 1st place in a tournament of 11 StarCraft 2 bots with an impressive record of 57 wins, 3 draws, and 0 losses.

UED Bot is available on GitHub.


Key Features

  • Dynamic Ramp Blocking: Strategically blocks key ramps with Supply Depots and a Barracks for early-game defense, preventing enemy advancement.

  • Optimized Resource Collection: Efficiently utilizes SCVs and Mules for mineral and gas gathering, ensuring a consistent economic advantage.

  • Advanced Unit Kiting: Implements professional-level kiting tactics with Marines and Battlecruisers to maximize damage output while minimizing losses.

  • Rapid Rush Attack Strategy: Executes a powerful early-game offensive using Battlecruiser teleportation before the 5:30 mark, followed by Marine and Siege Tank reinforcements.

  • Multi-layered Defense System: Deploys a combination of Marines, Siege Tanks, and Missile Turrets to create a robust defense while expanding territory.


Strategy Deep Dive

Professional Starcraft 2 gameplay is typically divided into three phases:

  • Early Game: First ~5 minutes

  • Mid Game: 5–10 minutes

  • Late Game: Beyond 10 minutes

Since some team members were new to Starcraft 2 and tournament matches usually lasted around 10 minutes, we prioritized developing robust early and mid game strategies. This focus allowed us to maximize our competitive edge during the most impactful phases of each match.

After analyzing previous tournament games, we observed that most bots employed Cheese Rush strategies—aggressive tactics designed to end the game quickly.

Anticipating that many teams would adopt similar approaches, we considered two options:

  • develop an even stronger cheese rush strategy, or

  • design countermeasures to effectively defend against these early-game attacks.

Our team’s pick was the latter, leading us to create a defensive but powerful mid game strategy that could withstand early cheese rushes while still being capable of launching a strong counterattack.

One-One-One Terran Strategy

Terran is renowned for its strong defensive play and formidable firepower enabled by advanced technology. The 1-1-1 Terran strategy focuses on rapidly advancing the tech tree by constructing one Barracks, one Factory, and one Starport early in the game. This approach provides our bot with flexibility, allowing for a balanced and adaptable army composition. It supports solid defensive setups while enabling swift transitions to powerful counterattacks using advanced units and tactics.

Terran’s 1-1-1 strategy was well-suited for what we wanted to achieve. It allowed us to build a strong defense against early cheese rushes while also preparing for a powerful mid-game counterattack. The strategy’s flexibility meant we could adapt our unit composition based on the opponent’s actions, making it a perfect fit for our bot’s design.

All the videos below were recorded to showcase the UED Bot’s performance in various scenarios, demonstrating its capabilities and strategies in action.

Scout

SCV scouting the enemy base early in the game

In Starcraft 2, scouting is crucial for gathering information about the opponent’s strategy and adapting accordingly. The UED Bot employs a dedicated SCV to scout the enemy base early in the game. This scout provides valuable insights. Especially for the UED Bot, the location of the enemy’s base is critical for planning our defense and counterattacks.

Simcity & Defense

“Simcity” is a term used in Starcraft to describe the strategic placement of buildings to create a defensive structure. The UED Bot uses this concept to build a strong defense around its base, utilizing Supply Depots and Barracks to block key chokepoints. This techtic provides strong advantage to overcome outnumber units against early cheese rushes.

Importance of "Simcity"

The video above demonstrates how crucial the placement of buildings is for effective defense. Each building occupies a different number of tiles (1x1, 2x2, 3x3, 5x5) on the terrain, and each unit has its own size.

Depending on the placement of the buildings, some units can pass through certain gaps while others cannot.

Defensive Advantage Due to "Simcity"

Buildings of Terran can be lifted and moved, allowing for dynamic defense adjustments.

Kiting

Kiting is the practice of moving a unit while attacking to maximize damage output while minimizing exposure to enemy fire.

Advantage of Kiting

The UED Bot implements advanced kiting techniques, particularly with Marines and Battlecruisers. This allows our bot to engage enemies effectively while minimizing losses. Our bot can kite units by moving them away from enemy fire while still attacking, ensuring that it deals damage without taking unnecessary risks.

End Game

End Game Scenario with Battlecruisers

The UED Bot’s end game strategy centers on executing a decisive push with Battlecruisers, leveraging their ability to teleport directly into the enemy base around the 5:30 mark. This aggressive maneuver is immediately supported by reinforcements of Marines and Siege Tanks, enabling sustained pressure and territorial expansion. The core objective is to survive and defend effectively during the early and mid game, buying enough time for the first Battlecruiser to be produced and deployed for a game-ending assault.


My Contributions

I researched the requirements for implementing the 1-1-1 Terran strategy by studying professional Starcraft 2 players and analyzing other bots. Based on this analysis, I proposed adopting the 1-1-1 Terran strategy for the UED Bot.

Resource Management

In Starcraft 2, optimized resource management is crucial for maintaining a competitive edge. Even if a strategy is suboptimal, a strong economy can allow a player to outproduce and overwhelm opponents. The game features two primary resources: minerals and gas. The 1-1-1 Terran strategy is particularly gas-intensive, as advanced units like Siege Tanks and Battlecruisers require significant gas investment. Balancing mineral and gas collection was a key challenge, as it directly affected the timing of unit production and tech advancement.

Timing Management

Timing Management is a critical aspect of Starcraft 2 gameplay, directly tied to resource management. The timing of constructing buildings and producing units depends on resource availability, but also on strategic priorities. Since every action—whether building, training, or researching—takes time, optimizing when these actions occur is essential for maintaining momentum and gaining an advantage. The goal is to minimize idle time for all units and production facilities, ensuring that resources are constantly being converted into strategic value. Achieving this requires careful planning and precise coordination, as even small delays can impact the effectiveness of a build order or response to the opponent.

For example, effective timing management in Starcraft 2 involves making strategic decisions such as:

  • When to construct key buildings like Supply Depots, Barracks, Factory, or Starport
  • When to expand to a new base to increase resource income
  • When to initiate research for upgrades to gain a technological edge
  • Determining the optimal number of SCVs to produce for efficient resource gathering
  • Allocating SCVs between mining minerals, collecting gas, and repairing structures or units
  • Deciding how many Marines and Siege Tanks to build before producing the first Battlecruiser
  • Continuously adapting these timings based on the evolving game state and opponent actions

These decisions are critical for maintaining a smooth build order, minimizing idle time, and ensuring UED bot can respond effectively to both threats and opportunities throughout the match.

Building Placement

Buildable Tiles

In the video above, the green tiles—custom-debugged by me—highlight areas where buildings can be placed. Effective building placement requires considering both the size of each building and the footprint of each unit, as well as the strategic value of different locations. Using the SC2 API, you can access the loaded map and retrieve information about every tile, including its coordinates, height, and whether it is buildable or accessible. When a builder unit enters construction mode, buildable tiles are shown in green.

Two key challenges I faced when it came to building placement were:

  • Simply knowing the coordinates of tiles is not enough: Starcraft 2’s buildable map is not directly mapped from in-game coordinates.

The buildable map is a transformed representation of the map that indicates where buildings can be placed.

  • How to find the exact coordinates of buildable tiles next to ramps?

To implement the “Simcity” strategy effectively, I needed to identify the specific buildable tiles adjacent to ramps. This involved analyzing map data and understanding how ramps interact with buildable areas. With help from the SC2 community, I learned that ramps are accessible but not buildable, and pinpointed the coordinates of buildable tiles right next to them—crucial for executing the “Simcity” strategy.

Testing and Code Quality

When all the components of UED bot were implemented, I tested our bot in various scenarios to ensure that it performed as expected. This involved running our bot against different opponents and myself, analyzing its performance, and making adjustments as needed. I also worked on improving our bot’s code quality, ensuring that it was well-structured, maintainable, and efficient.


Resources and Documentation

Progress Report - UED Bot
Final Report - UED Bot
Final Presentation - UED Bot

Note: The final presentation tab displays a PDF converted from the original PowerPoint file, so formatting and visuals may differ from the intended design.