IA on AI

Posts Tagged ‘scripting’

Soren Johnson: 7 Deadly Sins for Strategy Games

Wednesday, October 1st, 2008

I am a big fan of Soren Johnson’s work. That being said, I keep an eye on his blog, Designer Notes. In a recent post, he listed what he felt were the “seven deadly sins” of strategy game design. Most of them were dead on for whatever reason. I thought that his first one was particularly interesting specifically because it surprised me with its presence.

He talked about how some strategy games had “too much scripting”. Some of his points included:

The AI takes action depending not on its own development rate or strategic priorities but on whether the human has hit certain triggers. In many scenarios, in fact, the human cannot even lose because – when defeat approaches – the script will freeze the AI and starting pumping in free units for the player. Further, these scenarios are often built around specific “objectives” to achieve, such as destroying a specific structure or capturing a single point. This artificial environment takes decision-making away from the player. Not only is there only one path to victory, but the player’s performance along that path may not even matter. Games without interesting decisions get boring quickly.

The reason that jumped out at me was that scripting just hasn’t seemed to have been a big deal to me in strategy games. I always thing of scripting in the genres of RPGs and lately a lot of FPSs as well. Not that I haven’t encountered them in RTSs of the past. I used to play some of the single-player campaigns in the early RTS games like Warcraft and Starcraft. I vaguely remember the one in Empire Earth – which was one of my favorite RTS games for a long time. I have to admit that, despite my being aware that there is a campaign mode available in Civ 4, I haven’t even opened it up. I don’t even play a lot of the scenarios in Civ 4… just hand me a random map and let me roll.

Still, campaigns just don’t do it for me. They just didn’t hold me. It seemed to me to be an attempt to “personalize” the experience a la RPGs. That’s not why I was playing an RTS, however. I suppose if it was done better, I may be more interested. I like the latest blending of the RPG genre with the the FPS one that seems to have been en vogue of late (e.g. Bioshock). That was a kinda cool… but for some reason, RTS + RPG doesn’t quite cut it.

In the end, I suppose I agree with Soren’s premise then… it is a sin to put scripted events into an RTS. It’s just not what it is meant for.

Starcraft AI Exposed Through a "Bot Flight"

Sunday, April 13th, 2008

Wow. A dude by the name of Shamus Young wrote a great column on the AI of Starcraft on his blog, Twenty-Sided. In fact, it would be worth of a Post-Play’em entry and I almost toyed with writing this post over there. Anyway, he wrote a script that allows 7 AI players to battle it out with the 8th slot being left for the player to control no units but observe the entire map. Often, he would let the game run overnight and see what had transpired come morning. His observations were rather interesting and served to do two things:

  1. Point out the various strengths and weaknesses of the different races
  2. Point out that the AI is largely a rule-based engine with not a lot of forethought, planning or strategic processing… and definitely no learning capabilities.

While, as always, I encourage you to read his article at his blog, I do want to break down a couple of his observations here.

At first I just set the difficulty to “normal”, but I found that the computer players were far too likely to consume all the resources on the map, go broke, and then just sit there. I’d start a game before going to bed, and when I came back in the morning I’d find the battle was down to three sides who couldn’t make any fighting units. I changed the difficulty to “Insane”, which auto-cheats by giving itself 2,000 minerals and gas anytime it goes broke, meaning the thing is always rolling in resources.

It is my opinion that this is a major failing of the game. He points out that on the “insane” difficulty level the AI just simply gives itself more resources if it runs out. Because of that, there is no “end game” scenario that the computer has to plan for. There is no timer ticking down for it. However, there certainly is for the player. You need to make your move before your resources go dry. However, the computer is still playing “as if” the resources are still important. Shamus goes on…

I dislike this auto-cheat for a number of reasons, mostly because it negates a lot of the strategy in the game. None of the players can go broke, but the AI still plays as though resources were important. The only true way to knock a player out of the game is to annihilate their core base with all the critical buildings in it. Expansion bases are (mostly) worthless in a game like this. Yet the computer still builds and defends expansions (because that’s what it’s programmed to do) and still wastes time attacking enemy expansion bases. This introduces a bit of luck into the game: Who wins depends a lot on positioning. The AI tends to attack the nearest base, not the most important one. Sometimes the nearest base is the core base. Sometimes the nearest is an expansion which is pointlessly destroyed and rebuilt over and over again.

Now, that may be by design. I don’t know. From a mentality standpoint, the idea could be not to secure an expansion in order to secure the resources for yourself but rather to keep them from the player(s). That certainly makes sense. I doubt, however, that was the case. It is likely that the 2000 rule was simply a cheat to make things miserable for the player. *shrug* It’s an RTS staple, I suppose.

Moving on, the next section reeks of a scripted build order.

Without the unpredictable actions of a human involved in the match, the AI fights like clockwork. Games have a perceptible rhythm to them. They all build their first couple of buildings within a few seconds of each other. Even these variations are probably the result of minor changes in the layout of each base. If the bases were somehow shaped the same, the players would probably all build in perfect unison.

They build an initial attack force. On insane difficulty this attack force is huge – probably sixteen or so zealots or the given race equivalent. On normal difficulty the force is smaller, but the behavior is the same. They all leave the base at about the same time, and (as far as I can tell) attack a foe totally at random.

That means there may be some sort of rule-based system in place. Age Of Empires/Kings did this exact same thing. All the AIs would seem like they were working in sync, but that was because there all had the same timer settings (i.e. “If Timer = 1500, launch attack”).

For the most part, I can understand doing it this way. Short of putting together some sort of GOAP system in place to sequence individual actions into a cohesive plan, the only thing left would be a random build order… which would start to look silly. One thing that he didn’t mention here is if the build order was always the same… especially in the middle phases. It would be nice to see that the computer doesn’t play an individual race the same way every time. That would be something that, right out of the gate, would start to mix things up a bit.

The interesting bit is “attack a foe at random”. I would say that is, again, just a simplicity cheat. It would be a little mathematically intensive to process it further. However, there may be something not accounted for here. Since all the AIs are in sync at that point of the game, if there IS a mathematical scoring system, they would all come out the same. Therefore, in case of ties, taking “the top of the list” may tend to look random. The obvious fix that was missing, though, is a proximity factor. This helps in two ways:

  • It’s quicker and more manageable to wage war with a foe that is nearby
  • It’s easier to recall forces into a defensive perimeter when your they aren’t across the map

Shamus touches on this:

Nobody has any defenses at this point, so when an enemy comes knocking, their survival is a matter of luck: The defender has an attack force elsewhere on the
map. Is that force still intact, and can it be recalled before the place is destroyed? Are there enough of them left to save the place?

Another artifact of this “shoot anything that moves” strategy is that the AI is truly engaging all 6 of the opponents at all times rather than focusing on one or two of the most threatening (by strength or proximity).

A player can also do really well if they are attacked by two people at exactly the same time – the attackers end up wiping each other out and leaving the buildings alone.

As he notes, that turns messy and wasteful when attacking an enemy. Sure, when defending your own areas, you will want to repel anyone that comes near, however, if you are across the map attacking a base, don’t waste time with the other forces that happen to be in the area unless they attack you as well. Really, this could be handled rather well with an influence map that is laid down spreading from your buildings to determine whether you are in a “defensive” zone or not. If you are, attack anyone that comes in. If not, stick to the plan.

The AI seems to wait until this initial attack force is nearly all dead before entering the next phase: It builds defenses and another attack force. Again, this force is sent out. Once gone, the AI begins trying to build its first expansion base.

The rest of the game is a series of escalating attack waves. As they add more buildings onto their main base they work their way up to air units,

More evidence of a strictly scripted/rule-based system. There are obvious triggers here. If this is truly the case, this method could fall on its face in a number of ways.

For example, if the AI’s attack force survives a battle with just enough units to NOT trigger the next build, but the force it defeated is now in the next build (because their unit count dropped below the threshold), the AI actually starts to fall behind. An exploit would be to NOT kill the AI’s units off but just run them around the map for a while. You can build at will, but the AI is still waiting for the trigger to happen.

One interesting point that he made was regarding the difference in how the AI uses Protoss Templars vs. a human compared to vs. another AI. Check this out…

When I fight the AI Protoss, it uses the Templar Psi Storm with murderous efficiency. I’ll have a tight group of units moving into its base when a Templar will appear in juuuust the right spot, drop a Psi Storm on my guys, and dart away before I can punish him for it. With a couple of Templar available he’ll play hit-and-run with me all day, and do tremendous, infuriating damage to my forces.

Against other AI, the Templar are bumbling comic goofs. They will drop Psi Storm on single enemy units and hit a bunch of their own guys in the process. They will blunder through fortified territory attempting to reach a unit deep inside, and get cut down before they even get close.

I’ve come to suspect that the AI cheats a bit and detects clusters of units which have been grouped by hotkey by human players. This is very naughty if it’s true. What’s worse is that peeking at how my hotkeys are set up seems to be central to its decision making. Deprived of that bit of cheating info, the Templar is helplessly stupid. Boo. (empahsis mine)

Now THAT is interesting. Rather than write up some sort of grouping algorithm or process a very dynamic influence map, use something that the human player is going to likely use. If he doesn’t use hot keys on his groups, he’s a n00b anyway and could stand the help of an ineffectual AI. It would be interesting to try and play without hot-keying your forces and see if the AI Protoss can use those Templars effectively or not.

His complaints about how poor the AI is at playing Terrans are well-founded:

I’m note sure why the thing is so bad at utilizing Terrans. Aside from the issues I mention above, it just seems less aggressive overall. It also has a penchant for building base defenses (bunkers, towers) in places where a base should go, effectively rendering a viable expansion useless. It will attempt to lunch nukes without bothering to cloak the Ghost first. It will risk the painfully expensive Science Vessel in order to irradiate something of very low strategic value. It makes small numbers of all units instead of focusing on a few and using them well.

All of the above could be solved with some mathematical analysis of the units, the situations, the terrain, etc. It’s a shame that wasn’t done.

Now… keep in mind, this game was made 10 years ago. RTS AI was stagnant for the most part during that period. Age of Empires and Age of Kings had horribly inconsistent AI as well. It is my (less than perfect knowledge) opinion that RTS AI didn’t turn the corner until Empire Earth (Stainless Steel Studios) in 2001.

Anyway, Shamus’ project is fantastic and his analysis was very pleasant to read. I may have to find my Starcraft CD so I can download the zip file. I would be very interested to watch through these games and see what else I could see.

Writing AI is Like Parenting

Sunday, April 6th, 2008

Ted Vessenes wrote a nifty little post on his blog where he compared designing and programming AI to being a parent. Here’s the opening paragraph:

“Writing artificial intelligence is a lot like being a parent. It requires an unbelievable amount of work. There are utterly frustrating times where your children (or bots) do completely stupid things and you just can’t figure out what they were thinking. And there are other times they act brilliantly, and all the effort feels satisfying and well spent.”

I have to agree with a lot of the points he makes in his post. I would like to take the analogy one step farther.

I’ve occasionally made the point about both parenting and AI that your job is to not define what your progeny should do but convey an understanding of why. If, as a parent, you tell your child not to run in the street, they will hopefully carry that lesson into the future. However, they may not apply that same edict to driveways, parking lots or any other places where they could get plowed over by a car. This is analogous to the scripted AI methodology. However, if you explain the why of the situation – i.e. “be careful anywhere that cars are moving because the driver may not see you in time to stop and you could get badly hurt” – then the simple rule can be applied to any situation where there are cars (or even car-like objects). This, of course, maps over to rule-based systems or even planning systems.

However, going back to Ted’s point, it is an interesting similarity to put all those rules into place and hope that your little bots realize the appropriate situations in which to use them. I actually wrote a column about this scary process on my weekly column over at AIGameDev.

Anyway, if you are an AI developer, I hope that you are blessed with many children who all grow up to be accomplished in their chosen lives (or deaths).

David Braben on dynamic stories in games

Thursday, January 10th, 2008

Gamasutra recently posted an interview with David Braben (notably a co-writer of “Elite” from the 80s as well as other games). In it, he discusses his upcoming game “The Outsider” where they are working on expanding the concept of dynamic story generation beyond the “branching storyline” feel of many of today’s games.

A selection from page 1 of 4 of the interview:

Most of [the companies that have moved gameplay forward] are quite subtle. We’ve certainly seen things like Oblivion where you’ve got all the side quests that make the world feel a lot better.

The Darkness touched on that a little bit as well, and quite a few games have elements of what you might call ‘side gameplay’ that help feed into the richness, but they don’t fundamentally alter the story: games like Deus Ex where you had branching story, and there was some slight branching in games like Indigo Prophecy. So, I think all of those things are positive, but a lot of them felt, to me, like they hadn’t done the trick.

The problem is, I felt they didn’t quite deliver on their promise. Their promise is not actually the fact that you can play it through and have a different story, because that sounds fundamentally irrelevant — you play a game through and think, “So what, I could have done things slightly differently”. That’s not the point. I find that once you try playing games in a slightly contrary way, you end up finding a lot of blind alleys, things that you just can’t do, which I think is tragic. If you offer that promise, you’ve got to deliver on it.

So it’s not so much the fact of the story being able to go lots of different ways. It’s the fact that you can try a lot of different things and you’ll find a way through. It may not be what you anticipated, but there is a way through. I think it’s that sort of thing — being able to experiment with the world in a fun way.

I would agree that there are a lot of things that could be done to move away from the linearity of gameplay in games. Certain titles that offer sidequests give the appearance of this as Braben mentions.

I played through most of Neverwinter Nights 1 and 2 – and did my utmost to complete all the side-quests. But I was well aware of the fact that a designer had dropped these quests into the game all over. They were smaller carrots than the main theme of the game, but they were dangling veggies nonetheless. I was also well aware of when I had completed all of them and had to get back about the business of the main plotline. Sure, I could wander about the cities and wilderness aimlessly like I was out for a stroll, but no one would have anything to do with me unless there was a quest attached to them. So what was the point? At that stage, I was merely procrastinating with what I was “supposed to be doing” as concevied and presented by the design team.

I think that about the closest we have to open game play these days is RTS and TBS games. Civ 4 is my latest obsession research project. All it does is give me the rules of the world and a variety of potential end goals (note: not just ONE end goal). After that, it turns me loose to do whatever I want. There is no string I have to follow through the maze.

The Sims, Sim City, and other “god games” are similar. “Here’s your sandbox – go make something.” But how does this get mapped succesfully over to the RPG – or even FPS genre? Heck, it took years for the MMO world to get over the chorus of “but what am I supposed to do? What’s the story?” The meek answer from the industry was “uh… make your own story…?

Part of the process will have to be making gamers comfortable with the concept. There are many people who want to be told exactly what to do next. They don’t want to think – they want to act. Until that mentality is softened up a bit, any game that lacks that linear component runs the risk of being critically panned by the media and gamers alike.

It looks like Braben addresses this somewhat in “The Outsider”.

The actual problem is, when you start making a story very flexible, you’re putting your hand in a mincing machine from a design point of view.

But also, you have to cater for a lot of different types of play style. There are still the sort of people who want a brain-off experience, and I think that’s a good thing — I don’t think that’s a criticism. You don’t want to have to think, “Oh, what am I supposed to do now,” because that’s the flipside of this, the unspoken problem.

[Objectives] should still be really obvious, but there’s something nice about when you go through doing what you’re told, and you think, “Wait a second, this isn’t quite right!” And it’s that same element with Outsider where you’ve got corruption, that it’s really quite interesting. Now, you can play through the [straightforward] route, and you end up with quite an interesting ending, but you can also break off at any second, and start questioning why things are happening the way they’re happening.

So really I like where he says he’s going with the game. It will be interesting to see how the implementation plays out (so to speak).

Level Designers trumping AI Programmers

Sunday, January 6th, 2008

I hate glomming on to a blog chain, but I’m going to link to AIGameDev’s article on an article (which may very well be about an article.) The title is Watching Level Designers Use Scripts to Disable Your Autonomous AI: Priceless – which just about covers it. Alex does a nice job of not just reporting on it, but explaining the mindset and even the things to watch out for.

Regular readers of my other blog, Post-Play’em will know that I talked about the idea of scripts over-riding AI behaviors in Call of Duty 2 in a post entitled Call of Duty 2: Omniscience and Invulnerability. Specifically, this was in reference to one of the behaviors mentioned in the other article where an AI agent takes on a temporary god-like quality of invulnerability until such time as he finishes a scripted event – at which time he is no longer important to the level designer’s wishes and is cast back into the pot of cannon fodder so that I can mow him down properly.

Getting back to the initial topic, my thought is that part of the issue between artists/level designers and programmers may very well be that the level designers don’t have a trust in the capabilities of autonomous AI agents… or even and understanding of what could be done with them.

For example, with the use of goal-based agents such as those found in F.E.A.R. (related post), rather than a designer saying “I want the bot to do A then B, then C on his way to doing the final action of D.” he could simply tell the goal-based agent that “D is a damn good goal to accomplish.” If constructed properly, the agent would then realize that a perfectly viable way of accomplishing D would be via A-B-C-D. The difference between these two methods is important. If C is no longer a viable (or intelligent looking) option, then the scripted bot either gets stuck or looks very dumb in still trying to accomplish D through that pre-defined path. The very nature of planning agents, however, would allow the agent to try to find other ways of satisfying D. If one exists, he will find it. If not, perhaps another goal will suffice.

The problem is, while AI programmers understand this concept (especially if you are the one who wrote the planner for that game), level designers and particularly artists, may not have an intuitive grasp on this. They are cut more from the cloth of writers – “and then this happened, and then this, and then it was really cool when I wrote this next thing because I wanted the agent to look smart, and then this…” That is being a writer – and is why many games continue to be largely linear in nature. You are being pulled through an experience on a string of scripted events. (See related post on Doom 3’s scripting vs. AI)

So, can the problem of designers trumping AI programmers be solved? It will always be there to some extent. But education and communication will certainly help the matter.