Pages Menu

Categories Menu

Posted on Jun 21, 2013 in Electronic Games

Unity of Command – A Look Behind its Challenging Artificial Intelligence

By Matt Richardson

Unity of Command,  an operational-level strategy game released in 2012, has been widely praised for its challenging AI. The AI has an uncanny ability to punish the player for mistakes, seemingly combining the creativity of a human player with the analytical ability of a computer. It seems to always know exactly where your forces are weakest and can surprise you with a counterattack, cutting your army off from supply. The AI has its limitations, of course, but it does as fine a job as imitating a skilled human player as any I’ve had the pleasure of playing against.

{default}

I recently had the opportunity to ask 2×2 Games’ AI developer, Ante Turudić, a few questions about how they made their silicon soldier so challenging.

Matt Richardson: What was your original philosophy behind designing the AI for Unity of Command?

Ante Turudić: When designing the AI for Unity of Command we opted for a simple approach, imitating the way a human would play. We, the developers, observed how we responded to certain characteristic situations in the game ourselves, and then we implemented the AI to react similarly.

We identified a bunch of these situation/response combos which, for our purposes, we call “Tactics.” The AI repeatedly searches the map in order to find tactical situations it can recognize, and evaluates the payoff for each. The selected tactic with the best payoff then triggers a preprogrammed response. It’s an approach that would best be described as pattern matching.

With a design this simple, the resulting AI behavior is strongly dependent on the number of available Tactics. When we just started, we had maybe 10 different Tactics, and the AI played in a way that was boring and predictable. However, once the AI had over 15 Tactics programmed, it became increasingly adaptive and unpredictable. One Tactic would open up the way for another in completely non-obvious ways, creating powerful combination of different responses from the AI’s tactical toolbox.

MR: Why did you choose to focus on defensive AI only and not design an offensive AI as well? What advantages does an AI have playing defense? Alternately, what hobbles an AI on the attack?

AT: From the implementation standpoint, a purely defensive AI is a much easier problem to tackle. Attacking really requires a strategy, which means that an attacking AI would need to have some idea of what it wants to achieve over several turns.

The current AI, on the other hand, only considers the current situation on the map (it is strictly stateless, to use a technical term). Even the very concept of a “turn” is not built into it. This is why the AI cannot perform any actions spanning multiple turns, including even such simple things as moving its own units to distant destinations over several turns.

Attacking in Unity of Command also means taking calculated risks. Even small mistakes in estimating risk/reward when attacking could cause the AI to lose the game in a way that would appear “dumb.”

The margin for error is much higher when the AI is defending. For example, we observed player reactions as the defensive AI was responding non-optimally and/or was taking unnecessary losses. In an attacking role, such AI mistakes would be fatal. In defense, these risky counterattacks made the AI appear “aggressive” and there was a good chance they would go unexploited by a less skilled player.

MR: Do you have plans to expand the UoC AI so it can handle offensive missions, too?

AT: Yes, we are looking to add offensive AI for our next game.

Personally, I’m looking forward to the project; it’s all interesting and demanding stuff. The current AI code is a good base to build on, but there are plenty of issues to be addressed before you can expect this AI to mount credible attacks.

MR: Are there certain tasks or situations that the current UoC AI does not handle well?

AT: Oh, sure, there’s plenty of that. The biggest, as already mentioned, is that the AI cannot handle actions longer than one turn. In practice, that’s not so bad because the scenarios are not huge, and the defended territory typically shrinks over time.

Then, there are situations that are handled sub-optimally, or at least not in a way that a human player would handle them. For example, when retreating to defend an objective, the AI will use the strongest unit available. This often turns out to be a strong mobile unit that would better be used elsewhere. There are many smaller issues like that, and we’re obviously looking to make improvements.

MR: In the scenario editor, I noticed that the designer can place “AI Hints” in certain hexes. How important are these designer-placed hints to the AI’s functioning? How much can the AI “figure out” about a given scenario without human input?

AT: There are three groups of hints, broadly speaking. The first is related to controlling how the AI moves to cut or protect supply. The second group controls situations that AI is not that good at handling by itself, and the third is concerned with altering the behavior of the AI in order to play in a historical way (as opposed to just going tactically for the best result).

Supply hints will tell the AI which railroads or bridges are more important than the others for supply purposes. Theoretically, the AI could figure a lot of this out by itself. However, because there are only a handful of hints per scenario, we wanted to let the scenario designer decide how aggressive the AI should be towards different supply directions and locations.

The stuff that AI handles poorly is mostly related to strategic considerations, and this is where we use the second group of hints. When designing the scenario, you can instruct the AI to position units in places where they will be useful in some future turn. Examples of this are strategic bridges and bottlenecks, regroupings, or creating an additional line between the front and the objective.

Changing default AI behavior is used to make the AI more active or passive, in line with historical opponent behavior (this is all the more important if the history is well known by players). For example, the AI can be hinted to be very aggressive in a given area, as used in the Stalingrad scenario. An example of a passive hint can be seen in the Case Blue scenario. There, all Soviet units north of the Don are hinted to stay north of that river. The Germans in the game don’t really want to go there, but the Soviets defended the Don line historically and so we “hinted” the AI to keep its forces in place.

In general, hints are not necessary and the AI will play a pretty decent game by default. Most scenarios require only a handful of supply hints, and only the bigger ones will really need positioning hints. An important piece of advice for scenario designers is that you should not overuse hints. Each hint will cause the AI to allocate resources, and it might end up not having enough to handle its core business of creating a coherent defense.

MR: When you designed the AI, did you study or try to incorporate any historical doctrines? Did you try to have it imitate any famous generals or strategies?

AT: We didn’t use any of that as a starting point, no. The AI tries to imitate the human player, who in turn is playing a strictly abstract strategy game. The AI only seeks to play the best game that it can, and it’s the role of game design to favor realistic strategies (concentrating forces to penetrate the front line, maneuvering to cut off enemy supply, etc.)

One interesting thing that happened was that, while looking for algorithms to use, we stumbled into mathematical tools that are mainly used in military applications. One such example is the arranging of units into a front line, which boils down to what is called an “Interdiction Problem” in graph theory. So in a way the AI does incorporate some actual military thinking, but in this roundabout way rather than directly.

MR: During the original Unity of Command‘s Alpha and Beta testing process, what feedback did you get from the testers as they discovered the AI’s abilities? How did that help you refine the AI’s tactics?

AT: We were pleasantly surprised at the positive reactions during the tests. The testers were the first people to play, apart from a very small group that played the game during development. We didn’t really know what kind of a reaction we’d get: everything was on the table. There were issues of course, but mainly this was tuning and bugfixes.

Personally, I’m very happy with the reception we got, both for the game in general and the AI in particular.

Editor’s note: For additional information, see Matt’s interview with Tomislav Uzelac, lead developer of 2X2 Games and creator of Unity of Command on Matt’s own blog, Ritalingamer. Also see his report on the AI in Unity of Command: Red Turn here on ACG.

About the Author
Matt Richardson is a freelance social media and online marketing consultant in Charlotte, North Carolina. He has a degree in History from Davidson College, with a special interest in military history and the Civil War. He has rotted his mind with video games since childhood. You can follow Matt at @MT_Richardson and read his blog at Ritalingamer.com.

1 Comment

  1. Unity of command is a very good game and one i was very excited to play.As an AI enthusiast i wonder if and how they implemented the mentioned problems in their sequel

Trackbacks/Pingbacks

  1. Unity of Command: Black Turn – PC Game Review | Armchair General | Armchair General Magazine - We Put YOU in Command! - […] AI deserves special mention in any Unity of Command game. As I covered in my interview with the lead…
  2. Interview – The Future of Unity of Command | Ritalin Gamer - […] My interview with Ante Turudić, lead AI developer for 2×2, for Armchair General. […]