Discover more from AI and Games
Why ‘Into the Breach’ Kept Their AI Opponents as Simple as Possible
Sometimes complex AI isn't what the game needs
AI and Games is a YouTube series made possible thanks to crowdfunding on Patreon as well as right here with paid subscriptions on Substack.
Support the show to have your name in video credits, contribute to future episode topics, watch content in early access and receive exclusive supporters-only content.
When building the AI for your game, sometimes keeping it simple, is the best approach possible. Your game may employ a variety of systems for reacting to player behaviour, calculating their stress levels, anticipating their future actions, coordinating a tactical response, or even learning their behaviour such that you can reproduce it in front of them. But ultimately, a developer’s job is to ensure the systems built will service the intent of the game's design. And sometimes, that means you're better off designing AI that is, actually quite simple.
Perhaps one of the most interesting examples of this can be found in Subset Games' 2018 release 'Into the Breach': a tile-based puzzle game that presents players with increasingly challenging scenarios as the Vek seek to destroy all life on earth, and the player must often make difficult decisions on how to act next: whether to attack now and run the risk of collateral damage, or even ignore an enemy only for them to put the player in a near impossible situation to overcome. While the army of giant monsters is sufficiently diverse to enable for a range of interesting tactical scenarios, they are - contrary to popular belief - all built using simple techniques, all in an effort to satisfy the design goals.
For this episode of AI and Games, we're going to explain how Into the Breach's AI works, and how keeping it simple, and even dumbing it down, helps not only manage the intensity of the game but how it inadvertently led to players thinking it’s much smarter than it really is.
From Difficult to Unsolvable
Into the Breach applies a roguelike approach to tile-based strategy games: with players travelling back through time in high-powered mechs to save the world from the Vek invasion. You have a limited number of characters, weapons and resources, and must spend them wisely while ensuring civilians and key infrastructure are spared from total destruction.
It's important for games of this nature to provide a range of options for the player to solve the task ahead. Otherwise, it runs the risk of the player starting a level only to see quite quickly that they have no hope of completing it. As detailed in a development blog by Matthew Davis, the co-creator and programmer/designer of Into the Breach:
"AI / balancing / difficulty was the biggest challenge in making the game. The important thing to remember about Into the Breach’s design philosophy is that the game is more of a puzzle game than a strategy game. Things don’t just get “hard” they get “unsolvable” if everything isn’t working correctly. And unsolvable is a really frustrating state to find yourself in as a player. "
And so this was a driving influence on keeping the AI relatively simple, and often nerfing its capabilities to prevent annoying or awkward gameplay scenarios that players would find frustrating.
How it Works
As Davis states in their write-up, the implementation is also built to be simpler in an effort to ensure that the codebase is easier to maintain, and potentially extend down the line.
The crux of Into the Breach's AI is that it simply evaluates every action it can take in proximity, and selects one of the best to act upon. An action is typically comprised of both a move action and then an attack. So the AI will often do these together where possible. The scoring works in two stages: it evaluates all the tiles it can move towards, and then for each reachable tile, it scores the targets it can attack. Once scoring is completed, it orders all actions by score and selects one of the best actions at random.
This is what we refer to as a Utility AI system: in that it uses a metric for computing the efficacy of a given action, and providing a mechanism for how evaluating how 'good' two actions are compared to one another. We're going to focus on the specifics of the implementation here, but if you want to learn more about how Utility AI is used in a variety of games, check out the dedicated AI 101 episode on the topic.
So let's dig deeper into how the scoring system works:
The system starts by compiling everything that a unit can do in a given turn. This includes which tiles it can move to on that turn, as well as every tile it can conceivably shoot at as well based on its range of movement and firing pattern. This identifies a whole collection of tiles in the game map that have some sort of value to the AI unit, which can often be in the double digits, as the movement range enables up to 20-30 tiles a unit can reach. It will then score each tile based on the damage it can attain by attacking from that point in all four directions.
Scoring is fairly simple in practice: for every enemy it can hit on a given tile, it scores 5 points. Meanwhile, a building is also scored as 5 points. Plus, any friendly units being damaged by their actions from that tile will see a penalty of -2 points.
Now the vanilla version of the AI, and the one that is in the game for much of its development, simply ranks all available tiles by their score, and then selected the best. Some tiles have much higher scores due to their potential, given you can attack multiple units at once, or they can attack in alternating directions across multiple turns lest the player finds a way to stop them.
Over time this process became more complex: some of the subsequent changes were a reflection of the complexity of the game itself, while others were small balancing and difficulty adjustments.
For example, two simple ways to reduce the difficulty of the enemy AI were first to change the logic such that instead of acting on the most optimal tile for each turn, Vek units can instead randomly select from the top options, or simply pick the second or third best opportunity. This then leaves scope for higher difficulty levels to focus solely on the optimal actions. Meanwhile, another small adjustment is to add a negative score to any tile or target that was selected on the previous turn. This discourages the Vek from attacking the same unit twice.
As the game moved closer to release, the scoring process was also enhanced slightly to separate the score for the location itself, meaning the tile has one score, which is distinct from the target score: the value it has in attacking opponents.
The location score is useful given it highlights the potential of that location. Hence it could be close to a good tile for targeting enemies, but the Vek can't reach it. Hence in the event, there are no target tiles with a score above 0 on a given turn, the unit can prioritise the highest-scoring tile to move towards, given it could then attack on a subsequent move. In addition, the location score is also given a strong negative value in the event that the tile is dangerous, such as it is on fire, in a pit, or runs the risk of then being attacked by the player. Meaning it will now avoid them.
In addition to this, different Vek archetypes also have additional rules on how to weight tiles based on their play style. For example, melee units prefer to get close to their targets, so locations closer to enemies are always considered more desirable even if they can't attack yet. Meanwhile, there is also a consideration for keeping Vek units away from the map edges. If they're hiding out on an edge it can be difficult to reach or attack them, so they also add a negative weight to the edges of the map, such that they avoid them where possible.
As we now know, the AI of Into the Breach makes smart decisions on which tile to attack, but even then the implementation is far more vanilla than many would assume. This often leads to some misconceptions by players as to what the system does versus the reality.
For instance, no two enemies in a given level are aware of one another and what they're attempting to do. Action selection is done on a per-unit basis, and they don't co-operative to achieve maximum damage. In fact, the only time one enemy recognises the actions of another is if one enemy attacks a given tile, then the tile will be marked as 'dangerous' for the monster, which will mean when it's their turn to attack they will actively avoid it.
Perhaps most interestingly, as you'll have noticed from the scoring the enemies don't delineate between a player character and a building and don't prioritise one over the other. Both score equally in the utility calculation. This actually helps maintain the notion that the Vek army is rather mindless in its behaviour, and also seldom considers your team of pilots an actual threat to them. Reinforcing this concept: not only does the enemy not distinguish a building from a player mech, but it also doesn't factor any of your weapon load-outs or mods, which technically make you stronger and more powerful.
And lastly, as we've highlighted thus far, the Vek units only factor in the current state of the game. They don't consider how the player might respond to their actions, or what strategic opportunities their actions might create in subsequent turns. They also don't factor in whether their actions will lead to an unsolvable solution for that level. This might sound naive, and run the risk of creating even more issues for players down the line, but there is a myriad of smaller design decisions that are made to balance this out, and actually nerf the AI even further.
Among all of this, there are additional tweaks done to bring the whole thing together and play into the design of the AI such that each encounter is reasonably balanced.
Given the issues that can arise from map corners and other terrain being difficult for players to fight around, all of the maps in Into the Breach are handmade, with only a tiny amount of procedural generation applied to the likes of forests and other decorative elements. The rationale for this handmade approach, rather than allowing a PCG to generate all maps, was largely to avoid issues with odd corner shapes that could conceivably arise at runtime.
Meanwhile, the unit spawning is also heavily constrained on a per-difficulty basis and was one of the largest parts of balancing the entire game. Often it was the difference of adding just one unit that could turn a perfectly solvable instance into a nightmare that would strip the game of any fun it sought to achieve.
But this isn't to say that there isn't some real-time adaptation, with more units being spawned in should you have a good start and wipe out the opposition. Effectively creating units to replace them, but nonetheless, this is carefully managed within acceptable ranges.
Keep it Simple Stupid
So what have we learned today? In truth, you can create a highly engaging tactical combat game, without spending an inordinate amount of time and energy building complex AI systems. But rather, if you can identify what the key aspects of your game are, and where your AI opponents and gameplay systems interact with them, then quite often building something simple and manageable and adapting to suit, can help keep your game lean, and agile and enable it to thrive.
This is perhaps best summarised by Davis's in their documentation:
"There are definitely more complex options for the AI in Into the Breach, even options that may have made a “better” game. But as the sole programmer on the team, “good enough” is generally what I’m aiming for."
Into the Breach is a game that reinforces the design principle known as KISS, or Keep it Simple, Stupid! A design principle that advocates that systems work best when designed to be as simple as possible.
It's a term commonly used in software development that has roots within the US Military. While the less incendiary version of the acronym - Keep it Short and Simple, dates back to an article in a 1938 issue of the Minneapolis Star, it is more commonly attributed to Clarence Leonard ‘Kelly’ Johnson, who was a lead engineer at the Lockheed Skunk Works in Burbank, California in the early 1940s.
Johnson's use of the word ‘stupid’ is not meant as a slight against the engineers, but rather as means to express the tenuous relationship between how things break, and the often highly-complex processes required to repair them (as anyone who has ever broken their washing machine has since discovered).
Into the Breach continues to be a popular game now in 2023, with the Advanced Edition update released in the summer of 2022 for PC and Switch, while the iOS and Android versions were only now coming to market. While it continues to provide a fun and engaging experience, it's a solid reminder that sometimes the secret to making your game really click with audiences, is keeping systems within it as simple as possible.
Thanks for watching this episode of AI and Games. I figured it would be a fun exercise to go at Into the Breach, given - as I've already said at great length - it's quite simple, it works, and it's a fun game. This episode kind of sits nicely alongside the previous video on Halo Infinite in highlighting that sometimes you just don't need super fancy AI to really have an impact on the player: you just need to spend more time thinking about how your enemy players service the games needs and whether it enhances the overall design. Some food for thought for all you devs out there.