[image:78171 align=right hspace=5 vspace=5 border=0 size=thumbnail] Bungie AI programmer Max Dyckhoff last month mentioned a long-standing bug in Halo's driving code he'd found and eliminated. He was later kind enough to go into a bit more detail about how Halo's AI figures out how to handle driving and riding in vehicles.

Q: You're one of several active community members who went on to actually work at Bungie. How many Halo games have you worked on now, and what were your primary contributions to each?

A: I started at Bungie at the beginning of production on Halo 3, where I worked with Damian Isla on the AI systems. I spent some time adding a few AI features for ODST as well, such as Firefight, before moving on to Reach, where I have again been working on the AI team. For Reach I've added a bunch of great things like new flying behaviors, better vehicle driving, Elite combat, and so on. The AI team is typically very small, just 2-3 for most of Reach, but we get a lot done.

Q: You recently mentioned a revision to the AI driving routines in Reach that should provide a noticeable improvement. What was the problem that caused driver issues in previous games, and how is it being remedied?

A: There were a few things that I fixed actually, the first actually happened by chance. I was driving the Warthog myself, and I needed to back up to get out of a sticky situation. I turned while backing up, and noticed that I didn't turn in a circle while I did; instead I turned like a forklift, with the front wheels swinging around. Do it yourself in Halo 3 and you'll see what I mean.

The AI assumes that all of our turns are going to be circular; we give them a turning circle and they use this to plot various possible turns, and then they check them to see if they are going to lead them into walls or off cliffs. Because of the way the Warthog backs up (essentially in a straight line, with the front sweeping around), our "backwards" turns were always being plotted wrongly, and would often lead us off cliffs or into walls, when the AI assumed it was going to be clear.

I talked with the physics guys, and the Warthog turns like this because it's more fun for the player, which is fair enough. Visually, the rear wheels steer, but the physics says they don't do any steering. The fix was to make the rear wheels steer when the AI is driving. Various other things were done to make this not drastically affect the turning circle of the 'Hog when driven by AI, but that's basically it. Check it out in Reach; when an AI backs up, he will do so in a circle.

The second major fix was also based on the physics. If you take a Warthog and try making a hard turn with the throttle held down, your rear wheels will quickly lose traction and the vehicle will start slipping sideways across the ground. This is super fun, and the player can control it pretty intuitively, but the way the AI were modeling turns didn't accommodate enough for this. To fix this, I added some code which modulates the Warthog throttle when an AI is cornering; he'll turn into the corner, release the throttle a little and let the wheels gain traction, and then slam on the throttle again. It looks great, and has resulted in AI taking corners in a much more controlled fashion.

[image:78174 align=left hspace=5 vspace=5 border=0 size=thumbnail]Q: Marines seem to drive into things a lot. An improvement that helps them get unstuck is great, but why would a marine drive straight into a rock in the first place?

There are many reasons, the answer to the above question being one of them. The AI has a big problem to solve when driving; continuous fast movement through a very complicated space. The way the AI represents the world is through a massive mesh of "sectors" that specify where they can move. Sometimes these sectors can misrepresent a space, indicating that a rock is smaller than you might expect or something similar. We've done a lot of work to improve the pathfinding representation, and I am very happy with the end results.

Another reason would be poor understanding of how the physics works. As humans we can understand the physics of the Warthog very easily, but the AI has limited computing power to model how the Warthog is going to react to various controls. The throttling back as we go around corners is one improvement we made, and we tweaked various other ways that we model the physical behavior of the Warthog.

In my opinion, it's this sort of thing that makes Halo such an awesome game. We could just hardcode the AI into the vehicle and make them follow a path completely accurately, but instead we have all these systems which are grounded in reality, and we make them work together. The physics guys do an awesome job of simulating how a vehicle moves, and I make the AI understand how to drive the vehicle given the physical constraints.

Q: How does an AI driver in a Halo game "see" the playing field, and how does it compare to what a human player sees?

The environment in a Halo game is simplified into a "pathfinding mesh" for the purposes of AI navigation. This is a pretty standard structure used in video games, I'm sure you can go and Google it if you'd like to know more.

On top of this we have a layer of what are called "firing points"; these are essentially points in space that the AI will consider occupying when he wants to move. When an AI wants to move, he will evaluate a few hundred nearby firing points to identify the most optimal, and then he'll move there. This is identical for drivers and infantry, although flying vehicles use a separate system entirely unrelated to firing points (new in Reach!)

For the most part, the AI ignores the actual geometry of the level. When doing line of sight checks he will use it, but otherwise he sees himself as standing on the pathfinding mesh, and his target as standing somewhere else on that mesh. This allows the designer to specify areas as "non pathfindable" if they don't want an AI wandering in there.

[image:78173 align=right hspace=5 vspace=5 border=0 size=thumbnail] Q: How do AI characters decide whether to drive, gun, or ride shotgun for each vehicle type? I know I love trying to get rocket marines into a passenger hog on The Storm in Halo 3, but those guys sure do love their mongeese.

A: Hah! I believe that the rocket marines on The Storm were hard scripted by the level designer to get into the Mongeese, because that's how he wanted the encounter to play out. We very rarely do things like that, but occasionally it's a good idea.

The seat occupancy for AI characters is pretty easy to understand. If a character notices a vehicle is nearby they will "attach" to it, and then calculate their preference score for each of the available seats. Other nearby characters will do the same thing, and essentially whoever has the highest score, wins. The score includes checks like "do I have a rocket launcher?" (if so, a passenger seat is preferable), "am I a hero character (a member of Noble team, or the Arbiter in Halo 3, for example)?" (if so, give me a huge preference boost over a lowly marine). There are then a bunch of behaviors which make them get in or out of the seat based on these preference scores.

While being very simply implemented, it is actually a somewhat hard problem to get right. Essentially, we are trying to model what the player is expecting. Because there are very limited user inputs to say whom I want to go where, we need to be very intelligent and rigorous about who goes where. If the player gets out of a vehicle, should the marine passengers get out too? What if the player is just getting out to switch his weapon for a rocket launcher, something that an AI character can't possibly know he is about to do? If the player pulls an AI character out of a seat, is it because he wants that seat, or because he doesn't want me in the vehicle?

We basically had to come to a consensus on what various player actions "meant", and then wrote the code to support this. It's largely the same as the Halo 3 system with a few tweaks to make other Noble Team members more highly preferred. I'm actually very happy with the end results, and I hope all our fans are too.

Q: I think a lot of Halo players tend to list the levels focused on outdoor action including vehicles among their favorites: Silent Cartographer, Assault on the Control Room, the end of Outskirts, Metropolis, Delta Halo, The Ark, The Covenant. Halo seems to be at its best-- and its worst-- when the player is a passenger for certain sequences, especially on higher difficulties. (I'm thinking here of the outdoor theater in Metropolis where the Gauss hog wants a gunner, but on Legendary the hog gets killed very quickly.) Would you expect this to change for the better in Reach?

I have successfully been a passenger in every vehicle section in Reach on Heroic difficulty; and I believe our test team has done the same on Legendary. Various "survivability" behaviors were tweaked so that the AI driver will try and keep his player passenger alive better, and the new handling of the vehicle makes it much more robust at navigating around a combat encounter.

[image:78167 align=left hspace=5 vspace=5 border=0 size=thumbnail] Q: I once wandered away from a Warthog at the start of Delta Halo and came back to find it full of Elites who refused to get out or drive. It was hilarious-- but I'd have loved it if the Elites came after me with the hog! Do enemy AI have to be specially set up to take advantage of vehicles on the playfield, human or Covenant?

Hah! I actually saw this just the other day in a level on Reach; I got out of a Warthog to complete some objective inside a building, and I come out to find a pair of Elites getting into it. Fortunately I managed to destroy them all with a rocket launcher before they took it and started driving doughnuts around me.

The answer to your question is basically "yes". The firing points I mentioned before are actually filtered based on vehicle or infantry. We want infantry firing points inside, and on a higher resolution than vehicle points. If a designer hasn't placed any vehicle firing points in an area, then the AI will be unable to drive vehicles in that encounter. Most encounters that you can approach in a vehicle will have Covenant vehicles opposing you though, which means that they will be able to drive just fine.