Gamasutra: The Art & Business of Making Gamesspacer
View All     RSS
October 22, 2014
arrowPress Releases
October 22, 2014
PR Newswire
View All
View All     Submit Event

If you enjoy reading this site, you might also want to check out these UBM Tech sites:

Sun Tzu as an AI Design Guide?
by Dave Mark on 06/10/10 11:17:00 am   Expert Blogs   Featured Blogs

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.


[The following originally appeared June 5th, 2010 on Dave Mark's "IA on AI" blog on Intrinsic Algorithm's site.]

Total War creator, The Creative Assembly, has announced the development of the latest in the line of acclaimed RTS games, Shogun 2. While the Total War franchise has a 10-year history and is fairly well-known for its AI,  this blurb from their web site has spread through the web like an overturned ink well:

Featuring a brand new AI system inspired by the scriptures that influenced Japanese warfare, the millennia old Chinese “Art of War”, the Creative Assembly brings the wisdom of Master Sun Tsu to Shogun 2: Total War. Analysing this ancient text enabled the Creative Assembly to implement easy to understand yet deep strategical gameplay.

Sun Tzu's "The Art of War" has been a staple reference tome since he penned it (or brushed it... or whatever) in the 6th century B.C. It's hard to find many legends that have made it for over 20 centuries. Its applications have been adapted in various ways to go beyond war to arenas such as business and politics. Suffice to say that "The Art of War" lives on as "things that just make sense".

The problem I have here is that this seems to be more of a marketing gimmick than anything. After all, most of what Sun Tzu wrote should, in various forms, already be in game AI anyway.  To say Sun Tzu's ideas are unique to him and would never have been considered without his wisdom is similar to saying that no one thought that killing was a bad idea until Moses wandered down the hill with "Thou Shalt Not Kill" on a big ol' rock. No one stood around saying, "Gee... ya think?" Likewise, Sun Tzu's advice about "knowing your enemy" is hardly an earth-shattering revelation.

Certainly, there is plenty of game AI out there that could have benefited from a quick read of a summary of Art of War. Things like "staying in cover and waiting for the enemy to attack you" come to mind. Of course, in the game world, we call that "camping" (as an individual) or "turtling" (as a group). I can imagine a spirited argument as to whether a camping/turtling AI is necessarily What Our Players Want™, however. It certainly beats the old "Doom model" of "walk straight towards the enemy".

And what about the Sun Tzu concept of letting your two enemies beat the snot out of each other before you jump in? (I believe there are translations that yielded "dog shit" rather than "snot" but the meaning is still clear.) If you are in an RTS and one enemy just sits and waits for the other one whack you around a little bit, it's going to look broken. On the other hand, I admit to doing that in free-for-all Starcraft matches... because it is a brutal tactic!

The problem I have with their claim, however, is that there are many concepts in the Art of War that we already do use in game AI. By looking at Sun Tzu's chapter headings (or whatever he called them) we can see some of his general ideas:

For ease of reference, I pillage the following list from Wikipedia:

  1. Laying Plans/The Calculations
  2. Waging War/The Challenge
  3. Attack by Stratagem/The Plan of Attack
  4. Tactical Dispositions/Positioning
  5. Energy/Directing
  6. Weak Points & Strong/Illusion and Reality
  7. Maneuvering/Engaging The Force
  8. Variation in Tactics/The Nine Variations
  9. The Army on the March/Moving The Force
  10. The Attack by Fire/Fiery Attack
  11. The Use of Spies/The Use of Intelligence
Going into more detail on each of them, we can find many analogues to existing AI practices:
Laying Plans/The Calculations explores the five fundamental factors (and seven elements) that define a successful outcome (the Way, seasons, terrain, leadership, and management). By thinking, assessing and comparing these points you can calculate a victory, deviation from them will ensure failure. Remember that war is a very grave matter of state.
It almost seems to easy to cite planning techniques here because "plans" is in the title. I'll go a step further then and point out that the practice of collecting information and assessing the relative merits of the selection, you can determine potential outcomes or select correct paths of action. This is a common technique in AI decision-making calculations. Even the lowly min/max procedure is, in essence simply comparing various potential paths through the state space.
Waging War/The Challenge explains how to understand the economy of war and how success requires making the winning play, which in turn, requires limiting the cost of competition and conflict.
This one speaks even more to the min/max approach. The phrase "limiting the cost of competition and conflict" expresses the inherent economic calculations that min/max is based on. That is, I need to get the most bang for my buck.
Attack by Stratagem/The Plan of Attack defines the source of strength as unity, not size, and the five ingredients that you need to succeed in any war. In order of importance attack: Strategy, Alliances, Army, lastly Cities.
Any coordinating aspects to the AI forces falls under this category. For example, the hierarchical structure of units into squads and ultimately armies is part of that "unity" aspect. Very few RTS games send units into battle as soon as they are created. They also don't go off and do their own thing. If you have 100 units going to 100 places, you aren't going to have the strength of 100 units working as a collection.  This has been a staple of RTS games since their inception.
Tactical Dispositions/Positioning explains the importance of defending existing positions until you can advance them and how you must recognize opportunities, not try to create them.

Even simply including cover points in a shooter game can be thought of as "defending existing positions". More importantly, individual or squad tactics that do leapfrogging, cover-to-cover, movement is something that has been addressed in various ways for a number of years. Not only in FPS games do we see this (e.g. F.E.A.R.), but even in some of the work that Chris Jurney did originally in Company of Heroes. Simply telling a squad to advance to a point didn't mean they would continue on mindless of their peril. Even while not under fire, they would do a general cover-to-cover movement. When engaged in combat, however, there was a very obvious and concerted effort to move up only when the opportunity presented itself.

This point can be worked in reverse as well. The enemies in Halo 3, as explained by Damián Isla in his various lectures on the subject, defend a point until they can no longer reasonably do so and then fall back to the next defensible point. This is a similar concept to the "advance" model above.

Suffice to say, whether it be advancing opportunistically or retreating prudently, this is something that game AI is already doing.

Energy/Directing explains the use of creativity and timing in building your momentum.
This one is a little more vague simply because of the brevity of the summary on Wikipedia. However, we are all well aware of how some games have diverged from the simple and stale "aggro" models that were the norm 10-15 years ago.
Weak Points & Strong/Illusion and Reality explains how your opportunities come from the openings in the environment caused by the relative weakness of your enemy in a given area.
Identifying the disposition of the enemy screams of influence mapping—something that we have been using in RTS games for quite some time. Even some FPS and RPG titles have begun using it. Influence maps have been around for a long time and their construction and usage are well documented in books and papers. Not only do they use the disposition of forces as suggested above, but many of them have been constructed to incorporate environmental features as Mr. Tzu (Mr. Sun?) entreats us to do.
Maneuvering/Engaging The Force explains the dangers of direct conflict and how to win those confrontations when they are forced upon you.
Again, this one is a bit vague. Not sure where to go there.
Variation in Tactics/The Nine Variations focuses on the need for flexibility in your responses. It explains how to respond to shifting circumstances successfully.

This is an issue that game AI has not dealt with well in the past. If you managed to disrupt a build order for an RTS opponent, for example, it might get confused. Also AI was not always terribly adaptive to changing circumstances. To put it in simple rock-paper-scissors terms, if you kept playing rock over and over, the AI wouldn't catch on and play paper exclusively. In fact, it might still occasionally play scissors despite the guaranteed loss to your rock.

Lately, however, game AI has been far more adaptive to situations. The use of planners, behavior trees, and robust rule-based systems, for example, has allowed for far more flexibility than the more brittle FSMs allowed for. It is much harder to paint an AI into a corner from which it doesn't know how to extricate itself. (Often, with the FSM architecture, the AI wouldn't even realize it was painted into a corner at all and continue on blissfully unaware.)

The Army on the March/Moving The Force describes the different situations inf them.
[editorial comment on the above bullet point: WTF?]I'm not sure to what the above refers, but there has been a long history of movement-based algorithms. Whether it be solo pathfinding, group movement, group formations, or local steering rules, this is an area that is constantly being polished.
The Attack by Fire/Fiery Attack explains the use of weapons generally and the use of the environment as a weapon specifically. It examines the five targets for attack, the five types of environmental attack, and the appropriate responses to such attack.
For all intents and purposes, fire was the only "special attack" that they had in 600 BC. It was their BFG, I suppose. Extrapolated out, this is merely a way of describing when and how to go beyond the typical melee and missile attacks. While not perfect, actions like spell-casting decisions in an RPG are not terribly complicated to make. Also, by tagging environmental objects, we can allow the AI to reason about their uses. One excellent example is how the agents in F.E.A.R. would toss over a couch to create a cover point. That's using the environment to your advantage through a special (not typical) action.
The Use of Spies/The Use of Intelligence focuses on the importance of developing good information sources, specifically the five types of sources and how to manage them.
The interesting point here is that, given that our AI already has the game world at its e-fingertips, we haven't had to accurately simulate the gathering of intelligence information. That has changed in recent years as the technology has allowed us to burn more resources on the problem. We now regularly simulate the AI piercing the Fog of War through scouts, etc. It is only a matter of time and tech before we get even more detailed in this area. Additionally, we will soon be able to model the AI's belief of what we, the player, know of its disposition. This allows for intentional misdirection and subterfuge on the part of the AI. Now that will be fun! 

Anyway, the point of all of this is that, while claiming to use Sun Tzu's "Art of War" makes for good "back of the box" reading, much of what he wrote of we as game AI programmers do already. Is there merit in reading his work to garner a new appreciation of how to think? Sure. Is it the miraculous godsend that it seems to be? Not likely.

In the mean time, marketing fluff aside, I look forward to seeing how it all plays out (so to speak) in the latest Total War installment. (Looks like I might get a peek at E3 next week anyway.)

Related Jobs

Avalanche Studios
Avalanche Studios — New York, New York, United States

UI Programmer
Avalanche Studios
Avalanche Studios — New York, New York, United States

UI Artist/Designer — Hunt Valley, Maryland, United States

Lead UI Engineer — Chicago, Illinois, United States

Lead UI Engineer


Gabriel Lievano
profile image
I enjoyed this post a lot. The Art of War really summarizes the most important concepts to be taken into account for AI design and explains them in a very practical and intelligent way. As you said: "The Art of War" lives on as "things that just make sense".

Kieran Brigden
profile image
Hi Dave,

Myself and our lead Battle AI programmer enjoyed reading through this article, it's an interesting piece, although we're unsure as to what you're concluding?

As you mention much of what Sun Tzu says, has since become common tactical sense. This does not make it any less valid as a design paradigm, indeed it means much of it remains eternally relevant, if somewhat vague. That said, as you point out, common sense isn't always that common, especially when problem spaces differ so radically.

There are some interesting explicit examples too, including those that deal with how to react to enemy numbers. I.e. How to react if you are 1:1 or indeed 2:1 or 10:1 in troop terms.

As Game AI designers our job is to reflect the period and tactics we are covering. Feudal Japan certainly becomes more realistic and accurate when viewed through the tactical prism of Sun Tzu's writing.

Of course there are a multitude of techniques used, including Goal Oriented Programming, Nested State Machines etc. Even at this early stage the combination of current AI techniques with Sun Tzu as an inspirational text, is yielding great results.

I'll close with a comment from the man himself:

Sun Tzu: "A general who thoroughly understands the advantages that accompany variation of tactics knows how to handle his troops."

Looking forward to seeing you at E3 if we get the chance chap!

Kind Regards,

Kieran Brigden

Studio Communications Manager

The Creative Assembly

Dave Mark
profile image
Aha! I have summoned the wizards themselves!

Please know that I didn't mean any disrespect to your work or the title in general. My entire point was the obvious leaning on "we're using The Art of War" as more of a selling point than a design strategy. Certainly, as I pointed out and you confirmed, there are valid nuggets in Sun Tzu's writings. However, those same ideas can be found throughout military literature or, detaching from the military minds entirely, can often be arrived at algorithmically using existing methods.

And example is your "relative strength of forces" point above. Using such diverse methods as decreasing marginal utility, influence mapping, bin-packing, and optimal vertex covering algorithms, you can generate a template for a reasonably suitable battle plan. Now of course, many of these are NP-hard... which means that while it may be a bit complex to calculate via computerized algorithm, we humans can usually snap-judge "this looks about right" and be pretty darn close. That's why pre-defined "playbooks" and subject matter expert systems are often a better choice (much to the dismay of academic AI types).

And that's where we bring ol' Sun back into the picture. It makes a lot of sense to look to him as an SME. Also, since this is a "period piece" if you will, it does lend an air of authenticity.

Overall, I commend you for what you are doing. Too often AI designers and programmers flail around in the dark on how to design AI... be it strategic, tactical, or behavioral. In my book ("Behavioral Mathematics for Game AI") and my GDC lectures, I spend a great deal of time preaching that AI designers need to be observers first and foremost. Look around us at how we (and other people) make decisions. What do we take into account? How do we weigh options? Until you can consider how a person (or a general) makes a decision, you can't begin to accurately model it. By tapping into The Art of War, you are doing exactly that. Kudos.

And yeah, we need to hang out next week. Badly. Go find my email address on my site (rather than me upping my already spectacular spam load by pasting it here) and we'll set it up.

[User Banned]
profile image
This user violated Gamasutra’s Comment Guidelines and has been banned.

Nathan Addison
profile image
I enjoyed your article. Especially when you made mention of Tzu wasn't the first and sure isn't the last one to think on these tactics.

However, I did read the Art of War a few years back; did wonders for my chess game.

Raymond Ngoh
profile image
In regards to the chapter 9, I believe that it is talking about the logistical aspect of warfare. The issue of where to encamp the army and how to use it to your advantage is something that is not often addressed in a RTS game so far.

Dave Mark
profile image
That's actually quite true although it is changing lately. There is a lot of discussion among us AI folks about knowledge representation, terrain analysis, threat analysis, etc.

Raymond Ngoh
profile image
Just one more question that I would like to raise, which is regarding how the AI decides on what grand strategy it should adopt.

It seems that in most RTS games, the AI only have one main motivation, which is to attempt to defeat the enemy regardless of the cost involve. However, it seems that it is rare to see an AI creating a strategy based on survival.

Take the example of Connect 4, where a Human player can decide to aim for a draw rather than a victory if he thinks that his opponent is too good for him.

Take the example of Nuclear warfare for example, where the strategy adopted by almost every nation with nuclear capability to willing to launch nuclear weapons back at their enemy, even if they have been struck first. The reason for this is to ensure that even if our nation is heavy damaged by the nuclear attacks, the other country does not benefit from launching a nuclear attack, and we are all back to square one.

Perhaps if AI can approach warfare in this manner, where it aims to survive over a victory, players might have more of a challenge and at the same time, appreciate the fact the AI is acting in a more human-like manner.

After all, one of the most important concept in Sun Tzu's art of war is that the purpose of war is to help the State survive and not just to gain a victory.

If you are interested, you might want to take a look at this short article on Nuclear warfare, written by Stuart Slade, who has worked in the defence industry.

Dave Mark
profile image
While I am a big believer in your premise, one of the problems that we would find with that approach is people would view it as broken. What you are looking at is a variant on Prisoner's Dilemma in game theory (which I'm speaking about in Austin this fall, btw). However, you can certainly get to the state where both the player and the computer are "turtling" in gamer parlance. And then you've got a boring stalemate. Boring != fun.

If the designers make it so that the computer is always set on attacking, it all but guarantees conflict at some point.

Yes, if the mission involved the computer being entirely on defense of a point and the player's mission was to get to that point, you can certainly include code to "just survive". It's actually not hard to do that. Just a reworking of the strategic code and a little more attention paid to the economics of battle (both monetarily and via the utility of certain units).

Good comment... thanks!