Open Discussion
L4D2_ProceduralStairs1.medium

Procedural Level Geometry from Left 4 Dead 2: Spying on the AI Director 2.0

Alex J. Champandard on November 6, 2009

Since Valve announced Left 4 Dead 2, the feature of the AI Director 2.0 that grabbed the most attention has to be the dynamically changing level geometry. Apparently the game can not only control the weather patterns, but it can also change the route the survivors take while moving through the world.

In this article, you'll find out exactly how the AI Director 2.0 adapts the geometry procedurally. There's also proof in the form of exclusive screenshots from the demo of L4D2, which was released to the general public a few days ago. (The screenshots are exclusive in the sense that I took them myself, and nobody else has these!)

(Special thanks to @RevFry on Twitter for helping isolate all these variations.)

How It Works

Last week we held a Zombie AI Halloween Special, in which Phil Carlisle and I (Alex Champandard) speculated how L4D2 would handle the procedural geometry. Based on our combined experience, and the in-depth Premium feature I wrote about the original AI Director in Left 4 Dead 1, it turns out we came really close.

Here's how it works:

  1. There are individual variations in the geometry that are manually edited by level designers.

  2. These are grouped into sets of possibilities for the geometry around a particular location in the level.

  3. The AI Director uses it's pseudo-random selection among these sets to determine what happens in each game.

This approach is very similar to the way the AI Director handled the placement of scavenge items and weapons in the original game, allowing control by the designers yet sufficient unpredictability to keep things interesting.

The Demo

The only part that wasn't easy to guess was the scale at which the levels would be varied. Phil assumed there would be small rooms or segments in the world that would change, and I figured doors and fences would be the easiest way to introduce variation into the levels.

Based on the demo so far, the AI Director 20 is indeed using boarded doors, riot fences, and walls to block off alleys. In this part of the first level, there are three different paths the survivors can take. From experimental evidence, 1-2 of these paths are left open and the other 1-2 are closed off procedurally. This seems to happen only in Advanced and Expert modes.

(See the screenshots below. Click to enlarge.)

The Stairs

The Alley

The Door

Discuss!

Anyway, based on this we can start speculating about the rest of Left 4 Dead 2!

  • Do you expect there to be larger segments of geometry that change in the full version?

  • Will such local path changes (barely 10-20 meters difference) affects the gameplay enough?

  • How do you think this kind of technology can be applied to other games or genres?

Let everyone know what you think and post your reply by commenting in the forums.

Discussion 15 Comments

nikko_bertoa on November 6th, 2009

I think that dynamically changes in the level geometry will not improve the game experience too much. Except the door I think the another changes are exaggerated.

jefft on November 6th, 2009

I think that the potential to change the gameplay experience is quite large. Whether they do is another question. All it would take is a couple changes to turn a quick run through the back streets into a forced charge through a central plaza full of zombies. Or make someone go through buildings instead, another scary option. Also it prevents people getting lazy and developing a path/strategy that they always use. Finally I guess it makes the world feel more alive, although I'd prefer dynamic blocks (e.g. a fence or a car on fire etc) rather than "this alley is bricked up for no good reason". Now whether the director can use these in a meaningful way rather than just random variations... I have no idea.

Ian Morrison on November 8th, 2009

I get the impression that, like a lot of things in the demo, it was selected for the purpose of showing the game off best. Heavily dynamic environments with a lot of influence on the scenario aren't a good fit for a 20 minute demo, since they've got a good reason to want to tailor the experience. If one time it's straightforward and the next time a maze, that means that the person with the wide open route is probably going to feel a little dissatisfied with it. So, like the weapons staying while being picked up, I think this is more about giving everyone a chance to try all the toys and have comparably awesome experiences. The random paths that remain are mainly just a confirmation that yes, the feature IS in the game! Now, I expect the full game to make much better use of it. Hell, I've heard that the New Orleans cemetary in the game can be a single quick dash or a sprawling maze based on the director's whims. Hopefully, that's the sort of thing we're looking at. Now, as for having designer placed variations, I can't help but think that having something like the random world generation that Hellgate: London had would be a brilliant fit to Valve's director and gameplay. However, it's definitely NOT friendly to Valve's iterative, test-heavy process and desire for narrative and gameplay consistency. Yet I find myself eager to see how the two technologies could be combined.

Andrew on November 8th, 2009

I think this won't make much of a difference in the standard vs. AI Director play. However, this is a great twist for versus mode - human vs. human. Personally, I don't think it goes nearly far enough. I was highly unimpressed by the demo (not going to get the game until it's cheaper myself) despite the fact this would be a good thing to show off. Like jeff said, dynamically placed objects - cars, wrecks, etc. would be more cool. A level that looks simply randomised each time makes it that much more special when you have you getting past tons of burning cars, or perhaps just rubble, or lots of fences... (I presume it likely is an AI thing that they can't do the pathfinding dynamically enough for this, sadly). Would also be cool for the tank, randomly placing things to be thrown :) I personally also don't think this will be done on the AI Directors whim, whatever that means. I think it's randomised when the level is restarted. We'll have to wait for the full game to see :D

z777ik on November 12th, 2009

I think the tech is a cool way to keep the player from experiencing the same thing over and over. Most players after a few runs get used to knowing the whole map and what to do when and it almost becomes a chore. This tech helps keep the player from getting into a fixed rut that is caused by playing the same level over and over. This as I see it turns one level into many levels, taking away the need to release more maps a few months after release. As long as changing the level geometry takes a map and makes the next experience apart from the other possibilities. This could lead to other games doing the same. Imagine playing any other game with a tech like this. Multi-player maps could dynamically change up the experience so players feel the game is delivering more.

bakerman on November 16th, 2009

I just played through the Skedar homeworld level in Perfect Dark and realised... dude, this has been done. :P Okay, so obviously not in remotely this style. But the first objective in that mission is to place three target designators on pillars around the level. And after dying and restarting the mission... hey, I've got to place them on different pillars! Of course, these pillars were probably randomly chosen. But the idea of using random (or procedural) generation to change up a level isn't new. That said, it [i]is[/i] surprisingly under-used. But thanks to Valve, that's about to change (because now every man and his dog, me included, will be doing it - but for the record, I thought of this before hearing about it in L4D ;)).

jadnohra on November 16th, 2009

It doesn't matter ... what counts is who is the first to give it a name and call it their own invention .... always been like that (sadly maybe).

bakerman on November 16th, 2009

Oh, I realise that. Just felt like bringing it up since I had PD on top of my memory stack, so to speak :P.

Ian Morrison on November 17th, 2009

The first to do it on a large scale in 3D games, to my knowledge, was Hellgate: London, though the game was apparently too crappy to have made much of an impression. Random level generation has been done since... what, NetHack? The innovation here, if it is indeed acting as Valve says it does, that the level randomization is being done with a shred of intelligence and player reactivity. Not necessarily the case, though... it seems to almost be a clever marketing strategy to anthropomorphize the director to make it seem smarter. The L4D1 director, when it was dissected on this blog, was extraordinarily simple, if very well tuned, always using the simplest possible implementation under the hood and relying on chance interaction between subsystems to give the illusion of complex behaviour. They may have just decided on the simplest possible implementation for the director level changes: make it random. If so, then I'm a little disappointed that they would market it as a feature. The source engine has been able to do random level changes for a while... there's a CS:S map that does it! Still, I don't think the level generation in the demo can be considered representative, for the reasons I mentioned above. I don't think it would demo well, so I wouldn't be surprised if they didn't include it beyond the trivial proof-of-existence level alterations that we've seen.

bakerman on November 18th, 2009

[quote]The L4D1 director, when it was dissected on this blog, was extraordinarily simple, if very well tuned, always using the simplest possible implementation under the hood and relying on chance interaction between subsystems to give the illusion of complex behaviour. They may have just decided on the simplest possible implementation for the director level changes: make it random. If so, then I'm a little disappointed that they would market it as a feature.[/quote] That's a very good point - I'd also like to know just how much 'AI' the director does and how much of it is our perception of semi-random events. It'd be a great test of the system to be able to expose the director to user input. For example, to let players specify if they want a tense game versus a more relaxed one, and the director would take these situations into account. Maybe that's already accounted for by difficulty levels though, but I can imagine other adjectives that affect different things. For example, I might want a cliched game, where the director even hooks into the survivors' responses to deliver every zombie movie cliche that the level can support (as if that isn't done already :P). Or to ask for a 'surprising' playthrough versus one where the zombies are in typical locations and can be seen from further off. I know I'm talking about spawning instead of level generation now, though...

Ian Morrison on November 19th, 2009

If I remember correctly, the zombie placement was done with a simple noise function... presumably with different thresholds depending on the density desired, but actual placement of individual common infected was effectively random.

Kevin Dill on November 19th, 2009

There was more to it than that, I believe. Obviously, infected had to be spawned out of sight of the player, but close enough to be relevant. In addition, certain infected would be placed in front of the players (i.e. closer to the exit), while others would be placed behind the players. I believe that bosses and random wanderers were generally placed in front, while mobs were placed behind. My recollection is that they did this by selecting candidate locations and then scoring them. I don't know what other factors, if any, were included in the scoring function. They also had a notion of "intensity," which was used to guide *when* to spawn different sorts of infected. And probably other stuff that I don't recall offhand. If you missed Michael Booth's AIIDE talk, I'd definitely try to check it out once the talks are posted (probably not for a couple months yet, and I'm not sure if they'll be publicly accessible or if you'll have to pay for them). Alternately, see if you can find somebody who has a recording of his GDC talk, which was less AI-centric but outstanding never the less.

Ian Morrison on November 20th, 2009

Ah, I was specifically thinking about the wandering infected, not the hoards or specials. I do recall the talk having something more elaborate for the other types of spawns, but unless my memory fails me the placement for the wandering infected was effectively just a noise function.

infinite_loop on December 2nd, 2009

Maybe because of my work with unreal and their mover class, i am a little underwhelmed with this feature. The actual movement of the meshes is incredibly simple, and from my play experience the change in paths isnt dynamic enough. I understand that valve still wants to keep their paths clear enough for the player but simply covering and uncovering a door or having a fence present isnt quite enough. I think they are on the right track but I dont they they have fully realized what they have. hopefully the mod community will come up with some fun and creative ideas with this system once the authoring tools are updated.

Ian Morrison on December 13th, 2009

I've been underwhelmed with most of the director "improvements" actually. Even if they are being done in a way that's used to control pacing, they're seeing too little use, the randomizer in particular. Insofar as I can tell, it's no different from the randomizer used in CS:S maps like cs_havana. Were it actually making huge changes during individual runs, I probably still wouldn't consider it a significant AI feat but definitly would consider it an impressive feat of level design. And if it actually was placing prefabs throughout the level intelligently... well, that'd make my day. SEVERAL days, actually. Still, I was VERY impressed by the "weather control". Again, it's tough to tell if it's anything but random, since you only even see it on the later half of the Hard Rain campaign. It's easier to imagine it being more tightly controlled by the director, of course. It's a simple binary switch, and it has a clear gameplay effect: reduce visibility and make it tougher to keep track of each other. What's impossible to deny, though, is that it made for the tensest, most nerve wracking of the L4D2 campaigns, so even if it WAS random I think we need to give their designers and artists credit for pulling it off. I just wish those kind of game-altering random events would occur in the other campaigns, too.

If you'd like to add a comment or question on this page, simply log-in to the site. You can create an account from the sign-up page if necessary... It takes less than a minute!