[Paper Review] Implementing a Wall-In Building Placement in StarCraft with Declarative Programming
This paper presents a declarative solution using Answer Set Programming (ASP) to automatically generate optimal wall-in building placements in StarCraft, enabling AI bots to block chokepoints against early aggression. By modeling terrain, building placement, walkability gaps, and reachability, the approach efficiently finds valid, gap-minimized wall configurations that prevent enemy units from entering the base.
In real-time strategy games like StarCraft, skilled players often block the entrance to their base with buildings to prevent the opponent's units from getting inside. This technique, called "walling-in", is a vital part of player's skill set, allowing him to survive early aggression. However, current artificial players (bots) do not possess this skill, due to numerous inconveniences surfacing during its implementation in imperative languages like C++ or Java. In this text, written as a guide for bot programmers, we address the problem of finding an appropriate building placement that would block the entrance to player's base, and present a ready to use declarative solution employing the paradigm of answer set programming (ASP). We also encourage the readers to experiment with different declarative approaches to this problem.
Motivation & Objective
- Address the lack of wall-in building placement in AI-controlled StarCraft bots, a key skill in human gameplay.
- Solve the challenge of finding valid building placements that block chokepoints while accounting for game engine-specific walkability gaps.
- Provide a reusable, declarative solution using Answer Set Programming (ASP) to simplify implementation compared to imperative coding.
- Enable optimization of wall designs to minimize gap sizes, improving defensive effectiveness.
- Facilitate experimentation with declarative paradigms for RTS AI subproblems beyond this specific case.
Proposed method
- Model the StarCraft map as a grid of 32×32 px build tiles, with buildings occupying multiple tiles based on their size and type.
- Encode building placement constraints using ASP generator rules, ensuring each building is placed exactly once at a valid, buildable location.
- Represent walkability gaps between buildings using horizontalGap and verticalGap predicates, with sizes hard-coded per building type.
- Define reachability via logic rules that propagate walkable paths through gaps wide enough for enemy units (e.g., 16×16 px Zerglings).
- Use ASP’s generate-and-test paradigm: generate all potential placements and filter only those satisfying all constraints.
- Apply optimization statements to minimize total gap width, favoring more solid, effective walls.
Experimental results
Research questions
- RQ1How can a declarative programming approach like ASP be used to solve the wall-in building placement problem in StarCraft more effectively than imperative coding?
- RQ2What are the key constraints that must be modeled to ensure a wall blocks all enemy unit access through a chokepoint?
- RQ3How can game-specific mechanics—such as non-blocking gaps between buildings—be accurately represented in a logic-based system?
- RQ4Can optimization in ASP produce better wall configurations than brute-force or heuristic methods in terms of gap minimization?
- RQ5To what extent can this ASP-based solution be generalized or adapted to other RTS games or similar defensive placement problems?
Key findings
- The ASP-based solution successfully generates valid wall-in placements that block all potential enemy entry paths through a chokepoint.
- The method correctly models game engine-specific walkability gaps, such as the 12 px gap on the left side of a Forge, which could otherwise allow small units to pass.
- By encoding reachability through gaps wider than the enemy unit size (e.g., ≥16 px for Zerglings), the system accurately identifies paths that bypass the wall.
- The optimization statements effectively minimize total gap width, producing more defensive wall configurations than non-optimized alternatives.
- The solution is computationally efficient enough for real-time use, as it only needs to be computed once per game, making it practical for bot integration.
- The approach is directly usable in BWAPI-based bots and can be extended to other races (e.g., Protoss) by adding unit placement constraints, such as including a Zealot to maintain base access.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.