AI Follies: Introduction

By Shamus Posted Wednesday Aug 12, 2009

Filed under: Programming 51 comments

A while back I had a post that criticized the AI of Far Cry, and in the comments Legal Tender asked:

I wonder if you could elaborate further on the super-senses issue with the AI, Shamus?

I don't mean a more detailed description of it but rather what it takes to fix it from a programming point of view.

I remember you wrote a little something about AI behavior. I can't find that post but it left me thinking of…procedural AI? You know, give the AI grunts a set of behaviours and then let them loose on the world.

What can be done about super-senses? I mean, is there a setting, something like AIdetection=1 or AItrackingtrfoliage=1? and then you adjust them to 0.8 so foes will ignore you or can't aim if you are behind obstacles?

I started trying to write a response in the comments, which grew into a post, which grew into a series of posts. I had a post on this back in 2006, where I talked about the problems of having an NPC accompany you through the game. In that post, I said:

People ask why AI sucks so bad? This is why: It's hard, it's expensive, and when it's working right people don't notice because they only notice when the thing screws up. The developer can spend money making the gameworld bigger, or spend money adding lots of detail to some inconsequential NPC just so it doesn't kill immersion.

Developing AI is all about concealing or mitigating AI mishaps and screwups. If you hire a brilliant programmer and he does astounding work, in the end you’ll have spectacularly stupid AI that doesn’t do anything too obviously stupid when the player is looking. That’s the best you can hope for, because that’s the best that you can hope to do with a “mere” 10,000 lines of C++ code and a couple percent of your dual core processor. (Actually, processor isn’t that much of a bottleneck. The check to figure out where a given bullet will go and which of the 1,000,000 polygons in the scene it’s going to hit is going to be an order of magnitude more time consuming than anything your AI coder can throw at it. We don’t really need more AI processing power, because we’ve only just begun to figure out what to do with the power we already have.)

Note that I’ve never written production-quality AI before. I’ve dabbled quite a bit over the last quarter century, like most curious coders, and I’ve made a few simple systems. (Some of my first coding projects way back in 1983 at the tender age of 12 involved AI pathfinding.) But this series is more my overview of the problem and how I’d approach it than a review of work I’ve done in the past. I’m going to be outlining the problem – which is far bigger than a lot of people realize – but not offering any solutions. (If you want the solutions, feel free to send me an overview of the salary and benefits package you’re offering, because we’re going to be working together for a long time. (I’m Kidding. (Mostly.)))

I’m going to be talking mostly about dealing with enemy AI in this series and what a programmer needs to accomplish to reach the lofty goal of having enemies that aren’t obviously complete morons. Let’s assume we’re talking about generalized, dynamic AI as opposed to pre-scripted stuff. Imagine we’re talking about AI to oppose the player in various situations both indoors and outdoors. Ideally, we want the level designer to be able to drop a bunch of enemy AI dudes into the level, click and drag over the group, and say “You lot are all on a team. Work together.” In the end, we want that team to fight in a way that isn’t obviously stupid, unfair, or boring.

I divide combat AI into four distinct parts, in order of descending importance and increasing difficulty to implement: Detection, Targeting, Pathing, Behavior. I’ll talk about each of these in its own post. Later, you see.

Getting Started

If I were developing AI, my first step would be to get as far away from the game engine as possible. AI development is very expensive in terms of experimentation and testing. (Or should be, if you hope to do a good job.) If you’re testing group tactics, you need to test all sorts of situations and behaviors. There are hundreds and hundreds of ways a battle can play out, and you need to be testing a wide variety of scenarios to make sure you’re not just playing whack-a-mole. You don’t want to spend two days fixing the code that lets the AI navigate around buildings only to find you’ve completely broken the code that lets it snipe from a distance, and then spend another day fixing that to find the AI can no longer take turns going through doors.

You need to run a lot of tests, and you don’t want to launch the alpha version of a AAA game engine and sit through a bunch of loading screens every time you want to see the AI do its thing. The game will be very unoptimized and unstable early in development, and you don’t want to deal with long loads and crashes. You also don’t want to have to manually play the level, either. At least, not every single time.

Having a clear view of the battlefield would also help in giving me a nice objective view of things. It’s much more difficult to spot irrational or absurd behavior in a sea of foliage, particle effects, lens flares, tracer rounds, blood decals, and flying ragdolls. This wouldn’t be a problem if I was watching icons battle it out on a sterile “Tron”-style grid. (Aside: Didja see the new Tron Legacy teaser? Whee.)

I have no idea how AI coders work these days, but I would write something exceptionally lightweight. A simple program that moves 2d sprites around a simple “maze” of arbitrary shapes. Ideally, I’d want a program that can launch directly into the battle in a second or two. It would be able to run in accelerated time and fight itself while I watch and analyze the action. I could then iterate on that thing about twenty times faster than someone loading up (say) Crysis every single time they want to see the AI work. Once I had it polished to a mirror shine, then I’d integrate it into the game.

No development approach is perfect, and this one wouldn’t be without faults. But I think this would let me make the AI as smart non-stupid as possible without pushing back the release date until (insert Episode 3 joke here).

 


 

Fallout 3: Green World

By Shamus Posted Tuesday Aug 11, 2009

Filed under: Game Reviews 62 comments

<strong>Top:</strong>  The original game.  </p>
<p><strong>Bottom:</strong> the exact same location with the Green World mod installed.
Top: The original game.

Bottom: the exact same location with the Green World mod installed.

Yesterday I mentioned I’d been surfing through the Fallout 3 mod database. Mixed in with the nude mods, outlandish weapons, and endless clothing packs I found a lot of surprising things. Eventually I found myself playing and installing mods, and enjoying Fallout 3 far more than I did on my original trip through the game.

The most compelling mod I installed is clearly heretical in nature: Green world replaces the brown grass and dead trees with lush greenery. Now, the Fallout games are clearly established as taking place in a more or less lifeless world. It’s an endless wasteland of sterile dirt and rock. This breaks that. I will not defend the mod against the charge that it moves the setting of Fallout 3 even further from the originals, and in fact I admit I would probably have faulted Bethesda if they had made the game look this way by default. But I can’t let my small-minded hypocrisy stand in the way of fun. This is a drastic improvement in many ways. I could not believe how much of a difference this thing made to my enjoyment of the game.

fallout_green2.jpg

The trees introduce a bit of mystery to the horizon. It was often monotonous to march over the unbroken line of lifeless dirt. Now trees block your view in some places. Other places are open. Now when you travel it feels like you’re going somewhere.

The color variety is important as well. The 2D Fallout games had more colorful foes, pools of bright green goo, and slightly more colorful clothing and scenery. That’s been toned down with the move towards photo-realism. Worse, moving the camera to first person means that you’re now seeing all the way to the horizon, which makes the brown sort of pervasive and smothering. You can say that this is how the world of Fallout should look, and I won’t argue with you. But there is only so much brown I can look at in a session, and without the greenery the entire world is the color of dirt and ash. The splashes of green produce some desperately needed contrast to the view.

fallout_green3.jpg

But the biggest change of the mod is just to change our perception of the wasteland. Vanilla Fallout 3 presents a barren, lifeless world. No tress. Barely any grass, most of which is brown. This introduces a lot of questions as to how in the heck anything is still alive after 200 years. No vegetation means no food chain. No food chain means nothing for humans to eat. Humans should have starved about 20 years after the bombs fell, as the last of the old food stores were depleted. The idea that this world could support not just humans, but massive predators like Deathclaws, Yao Guai, Super Mutants, and Mirelurks is ridiculous.

But the wasteland presented in this mod is very different. This isn’t a world rendered uninhabitable by human civilization. This is a world that is simply forgetting human civilization. Grass and trees encroach on the borders of the city. Grass pokes up through the cracked pavement, inexorably reclaiming the land.

With this mod, the food chain is plausible. Sure, the game doesn’t show any crops being grown, but it’s easier to believe in farming that happens off-screen than it is to believe that people are still living off of 200 year old boxes of cereal.

fallout_green4.jpg

There are a few minor issues. The oasis region won’t make any sense now, since your character will make a big deal over seeing green trees even though they’re all over the wasteland now. The trees are non-solid to avoid breaking the AI pathfinding. There are a small number of places where the branches poke through walls, which looks wrong. Still, it’s amazing someone was able to make such vast changes with such minor side-effects.

The overgrown world has a kind of lonely, forlorn feel to it. It reminds me a bit of the New York we see in I am Legend. Lost and empty.

Maybe it’s not Fallout proper, but I like it better this way. Given the other betrayals to canon and continuity that were integrated into the game, this mod is a small deviation with pleasing results.

You can download Green world yourself if you want to give it a try.

Other mods I would consider essential:
* Something to make the interface less stupid on the PC.
* Fast VATS, to speed up the tedious cutscenes that play when you shoot someone. I’m not against a little slo-mo now and again for special moments, but having the game slow down every. single. time. you pull the trigger, and then having the camera linger over their corpse for several seconds, completely ruins the effect. I found myself ignoring VATS, and then turning down the difficulty (the game is much harder without VATS) which more or less reduced the game to DOOM. Which also becomes boring. Much better to play the game as intended, but with less slo-mo nonsense.
* Fellout, which gets rid of the pervasive green tint in the world. Like green world, this gives some visual variety to the lighting and color, as opposed to “all green, all the time”.
* Some variety of level un-capper. It’s no fun hitting the level cap before you’re even halfway through the game, which can easily happen if you come from the Do Every Quest school of thought. You have to be careful here, because these aren’t mods so much as “hacks”. The level 20 cap is built into all sorts of game mechanics, and breaking it can break the game in annoying ways. (The most obvious problem is that you’ll quickly master all skills and accrue a massive, game-breaking load of hitpoints.) Really, I’d be happy with retaining the power of a level 20 character, as long as it still allowed me to clock more levels. There are a lot of mods with varying approaches to this problem. Your mileage may vary.
* Some sort of body mod. Some players want nudity. Some players just want better looking people in the wasteland. Some players just want the people (raiders, mostly) to have underwear that makes some kind of sense. No matter what your preference is, there’s probably a mod that will fix things up. (But above all, I wish there was some dang variety. No mods seem to offer that, sadly.)
* Hunger, Thirst, Sleep. I discovered this yesterday when Rutskarn mentioned it in the comments. I’ve only dabbled with it so far, but I will say that this might be the most interesting mod yet. Even better than Green World. It turns this game into a genuine fight for survival. Pure water is no longer Halloween candy to be handed out to idiot NPCs for free karma. It’s a precious resource, and you will need to fight for it. Last night I came across the random event where some escaped slaves are arguing with some ghouls over who should get some fresh water. In the past I made my decision on how to handle the encounter based on what my alignment was. This time, I made the decision based on TWO AND A HALF DAYS OF WATER? I NEED THIS! This is what playing a good-aligned character should feel like: A battle of need vs. conscience. If you share your water with an NPC, you deserve those karma points, because you have made a tangible in-game sacrifice. The only thing ruining it is your ability to get rid of all radiation for free at home. (Thus allowing you to drink dirty water for free.)

 


 

Stolen Pixels #115: BadWorld

By Shamus Posted Tuesday Aug 11, 2009

Filed under: Column 8 comments

On why Mad World isn’t nearly as offensive as it may seem at first glance.

 


 

Fallout 3: The Truth About Boys and Girls

By Shamus Posted Monday Aug 10, 2009

Filed under: Game Reviews 94 comments

Fair warning: This post is going to be talking about nudity and linking to NSFW pages at the Fallout 3 nexus. The vast majority of the 6,424 mods in the database are perfectly safe and are related to changes in gameplay or additional content. I’m going to be talking about the small number which are risqué. Technically the mod database shouldn’t show you anything R-rated unless you create an account there first, but you know how the internet can be sometimes. Be careful what you click if you’re in a place where seeing naked polygonal men and women might cause you employment, relationship, or self-esteem problems.

Continue reading ⟩⟩ “Fallout 3: The Truth About Boys and Girls”

 


 

The Escapist Show: Putting a SSD in a PS3

By Shamus Posted Saturday Aug 8, 2009

Filed under: Movies 43 comments

I paused halfway through this movie, which talks about replacing the built-in PS3 hard drive with solid-state memory. Here is what I had to say at that point:

I’ve been hard on the PS3. Overpriced, hard to program, small library, etc etc etc. I was dubious of their claim that this would be a “ten year” console. It’s too hard to predict the future like that.

Instead of looking forward ten years, let’s look back to ten years before the PS3 came out. Imagine if someone had sat down in 1996 and designed a “gaming PC” that would still be relevant in 2006. It would have been impossible. They would have built some sort of souped-up version of a PC based on existing technology. No DVD drive. The graphics bus would have been AGP. The display would have been 16 bit. It would basically be a VooDoo chipset of some variety with a “ton” of memory. The designer of the ten-year PC wouldn’t have been able to allow for the move to 32 bit color, PCI busses, or vertex shaders. The machine would have been obsolete by 2002 no matter how much memory or CPU power it had been granted.

But I have to give Sony credit: They made the PS3 flexible enough that parts of the machine can be swapped out easily and without even voiding the warranty. With nothing more than a screwdriver you can take leaps forward and get more out of the machine, giving you access to technology that wasn’t feasible or affordable when the PS3 was conceived. Maybe the difficulty of the machine is the price we pay for this kind of flexibility.

And here is what I have to say after actually getting around to watching the end:

ZERO? NO IMPROVEMENT? This is your “ten year” console, Sony?

Now, there are plenty of reasons why this would be the case. As they mention in the video, the console might deliberately throttle incoming data because it’s easier to code for a system if the hardware is very predictable. But we’ve already established that the PS3 is not an easy platform to develop for. If the Xbox 360 throttled incoming HD data I would understand it as a reasonable development shortcut. But the 360 doesn’t have delusions of still being relevant in 2015. Sony does.

Expensive. Small library. Hard to program. And immunized against technological advances.

And by the way: One minute loading screens in Killzone 2? How is this thing supposed to keep up in 2016 when it seems to be struggling already?

Shameful.

 


 

Experienced Points: The Stupid Season

By Shamus Posted Friday Aug 7, 2009

Filed under: Column 17 comments

Yes, a column about Christmas shopping patterns. Well, it’s more an explanation of the game publishers are forced to play, and why we lose every time they do.

 


 

Stolen Pixels #114: So You Want to be an Indie Developer?

By Shamus Posted Friday Aug 7, 2009

Filed under: Column 16 comments

If you’re an aspiring indie game developer, Travis can help fill out the details of your business plan.

I heard about the 120 new iPhone games a day from Jay Barnson. That translates to 840 games a week. If your 40-hour-a-week job required that you sample every single iPhone game, you’d have to play 21 games an hour to keep up. That is, switch games every 2.8 minutes.

I’m guessing that a lot of people suddenly realized at the exact same time that the iPhone was the Next Big Thing, and all of them dove into development. If you read the post I linked above, you can see the long tail is in effect in a big way. A minuscule group of people make a living, and a vast majority get something in the “couple hundred bucks” range. Given the hundreds of hours that go into making even a simple game, this basically boils down to a lot of developers losing their shirts. Hopefully most of them kept their day jobs and made the games in their spare time.

Things might actually get better once the glut is over. A lot of those “120 games a day” are probably coming from people who thought they were taking part in a gold rush. Once a good number of them go back to their day jobs, the marketplace might regain some sanity. Here’s hoping, anyway.