Building the Battlefield AI Experience

17,810 views

Published on

This keynote explores the development of the AI in Battlefield: Bad Company and Battlefield: Bad Company 2 and what caused the difference in quality between the games. It describes challenges in the development of the games and the design philosophies we used to overcome them.

See http://publications.dice.se for the .ppt file and extra movies.

1 Comment
4 Likes
Statistics
Notes
  • http://www.sendspace.com/file/8kn03w
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
17,810
On SlideShare
0
From Embeds
0
Number of Embeds
15,469
Actions
Shares
0
Downloads
42
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide
  • I'd like to start this off by doing a summary of sorts, of the end result of the games that we've been working on.Battlefield: Bad Company was pretty much universally loved for its destruction, heralded for its sound and hated because of the AI. It was the first attempt at making a single player game DICE had made.
  • I'd like to start this off by doing a summary of sorts, of the end result of the games that we've been working on.Battlefield: Bad Company was pretty much universally loved for its destruction, heralded for its sound and hated because of the AI. It was the first attempt at making a single player game DICE had made.
  • I'd like to start this off by doing a summary of sorts, of the end result of the games that we've been working on.Battlefield: Bad Company was pretty much universally loved for its destruction, heralded for its sound and hated because of the AI. It was the first attempt at making a single player game DICE had made.
  • I'd like to start this off by doing a summary of sorts, of the end result of the games that we've been working on.Battlefield: Bad Company was pretty much universally loved for its destruction, heralded for its sound and hated because of the AI. It was the first attempt at making a single player game DICE had made.
  • So for a quick overview of this talk, I'll be starting off with the challenges we faced when we started making these games, moving through a discussion on what AI actually means to us to the Design Philosophy we've applied to try to make the AI as good as possible.I'll be focusing on the improvements we did between the first game and the second, and then finish off with an overview of some of the things we did to solve these challenges.
  • Sometimes when I look back at making these games I wonder if we were actively trying to make it as difficult as possible, compared to other games. The number one challenge for us absolutely must be the Uncanny valley.The uncanny valley is a discrepancy between the human mind’s extraordinary ability to identify symbols and its incredible ability to read body language and human behavior. This means that as something goes from being a symbol of a human towards actually looking like a human being, it actually becomes less believable in the paradox which is called uncanny valley.If you listen to the highly talented guys over at Bungie talk about their AI, a whole lot of their ideas don't work in the context of infantry soldiers. For instance, they talk about extaggering behavioral differences between different types of enemies. This works for them, since the enemies are different kind of aliens.For instance, they say instead of just letting your enemies run away when hurt, you should have them run away while screaming at the top of their lungs and waving their hands around madly. Having our soldiers run away screaming and waving their arms around would never be accepted as real.The worst thing with the uncanny valley is that people don’t recognize it, so during development you’re going to have some bugs and everyone is going to think your AI is completely broken, which seems entirely backwards. This is why all the AI demos middleware companies do always look kind of cool with their stick figure graphics, but why soldier AI always seems to suck until the last week, when it suddenly becomes awesome.
  • There’s this thing with AI developers and producers: when we see a broken AI, we look at it and go “oh boy that looks stupid”. There’s a failsafe here, in that 99% of all the players are going to just shoot the guy in the face and go about their business.So that doesn't happen with friendly AI. It's made even worse by the fact that our friendly squad is immortal, and not only are they immortal, they’re also personalities that you’ll recognize, so just leaving them behind if they get stuck isn’t an option either.I did some timing on a video capture of one of our levels, and came up with some numbers on lifetimes. So this is the screen life time of an enemy NPC, which means the time from the first time it’s visible on the screen until it’s either dead or permanently out of view. The average is slightly shy of 5 seconds, with the median value being around 3 seconds.In comparison, the friendlies have an almost infinite amount of time and opportunity to screw up.
  • But of course it isn’t just about characters… the very game model itself becomes a problem. The Battlefield series is famous for its variety of weapons and vehicles, which of course meant we need to teach our AI to shoot them all, drive them all and pilot them all, or whatever it could be.This also meant that whenever the physics model of any of the vehicles changed, our controlling code would need re-tweaking.
  • But of course it isn’t just about characters… the very game model itself becomes a problem. The Battlefield series is famous for its variety of weapons and vehicles, which of course meant we need to teach our AI to shoot them all, drive them all and pilot them all, or whatever it could be.This also meant that whenever the physics model of any of the vehicles changed, our controlling code would need re-tweaking.
  • But of course it isn’t just about characters… the very game model itself becomes a problem. The Battlefield series is famous for its variety of weapons and vehicles, which of course meant we need to teach our AI to shoot them all, drive them all and pilot them all, or whatever it could be.This also meant that whenever the physics model of any of the vehicles changed, our controlling code would need re-tweaking.
  • But of course it isn’t just about characters… the very game model itself becomes a problem. The Battlefield series is famous for its variety of weapons and vehicles, which of course meant we need to teach our AI to shoot them all, drive them all and pilot them all, or whatever it could be.This also meant that whenever the physics model of any of the vehicles changed, our controlling code would need re-tweaking.
  • So other games have vehicle gameplay too, lets make it even harder. The entire gameplay and game engine is centered around destruction. Obviously this creates a problem when it comes to pathfinding, since you will need to update the possible paths depending on what's whole, broken or rubble.But there are other, less obvious, problems as well. Kill zone did some really cool precomputed visibility cube maps which was not an option for us, since new line of sight could open up by destroying a part of a house. There were plenty of times where we had to reject very cool precomputed algorithms because of destruction.
  • So other games have vehicle gameplay too, lets make it even harder. The entire gameplay and game engine is centered around destruction. Obviously this creates a problem when it comes to pathfinding, since you will need to update the possible paths depending on what's whole, broken or rubble.But there are other, less obvious, problems as well. Kill zone did some really cool precomputed visibility cube maps which was not an option for us, since new line of sight could open up by destroying a part of a house. There were plenty of times where we had to reject very cool precomputed algorithms because of destruction.
  • So other games have vehicle gameplay too, lets make it even harder. The entire gameplay and game engine is centered around destruction. Obviously this creates a problem when it comes to pathfinding, since you will need to update the possible paths depending on what's whole, broken or rubble.But there are other, less obvious, problems as well. Kill zone did some really cool precomputed visibility cube maps which was not an option for us, since new line of sight could open up by destroying a part of a house. There were plenty of times where we had to reject very cool precomputed algorithms because of destruction.
  • The open world gameplay really puts a lot of pressure on the AI to look good regardless of where the player is coming from or what route he's taken to get there.So in combination with destruction, this was a problem not just for AI system code, but also it made scripting a lot harder, since we never knew where a player could go, and this was perhaps the area where we had to spend most of our effort in Bad Company 2.If you look at some of our competitors you’ll notice how they’ll block off the player with a wooden wall or some metal fence – we didn’t have that option so we had to work really hard to make the environment both as destructible as possible but also as believable as possible when it came to funneling gameplay the direction we wanted.
  • The open world gameplay really puts a lot of pressure on the AI to look good regardless of where the player is coming from or what route he's taken to get there.So in combination with destruction, this was a problem not just for AI system code, but also it made scripting a lot harder, since we never knew where a player could go, and this was perhaps the area where we had to spend most of our effort in Bad Company 2.If you look at some of our competitors you’ll notice how they’ll block off the player with a wooden wall or some metal fence – we didn’t have that option so we had to work really hard to make the environment both as destructible as possible but also as believable as possible when it came to funneling gameplay the direction we wanted.
  • When we started making Bad Company, DICE had pretty much never made a single player game before, and the culture was very much that of a MP studio. Everyone loved multiplayer, noone knew anything about singleplayer games.I had to really fight to drive home the message that what we were doing here was something representing an actor in the game, not someone playing a multiplayer game.
  • So this kind of lack of familiarity with SP and AI means someone in charge thinks “well, AI, hmm? We have this AI from BF2 that sort of works. Lets use that one”So while the entire engine team is building a game engine for this new console generation, the AI team is busy porting this old, very PC-style code AI system. And once we get it up and running, of course it doesn't do anything we need it to do, and its full of technical debt from having been used for bots in four games already.And so that's what I have to work with when I take over.
  • So this kind of lack of familiarity with SP and AI means someone in charge thinks “well, AI, hmm? We have this AI from BF2 that sort of works. Lets use that one”So while the entire engine team is building a game engine for this new console generation, the AI team is busy porting this old, very PC-style code AI system. And once we get it up and running, of course it doesn't do anything we need it to do, and its full of technical debt from having been used for bots in four games already.And so that's what I have to work with when I take over.
  • So this kind of lack of familiarity with SP and AI means someone in charge thinks “well, AI, hmm? We have this AI from BF2 that sort of works. Lets use that one”So while the entire engine team is building a game engine for this new console generation, the AI team is busy porting this old, very PC-style code AI system. And once we get it up and running, of course it doesn't do anything we need it to do, and its full of technical debt from having been used for bots in four games already.And so that's what I have to work with when I take over.
  • So this kind of lack of familiarity with SP and AI means someone in charge thinks “well, AI, hmm? We have this AI from BF2 that sort of works. Lets use that one”So while the entire engine team is building a game engine for this new console generation, the AI team is busy porting this old, very PC-style code AI system. And once we get it up and running, of course it doesn't do anything we need it to do, and its full of technical debt from having been used for bots in four games already.And so that's what I have to work with when I take over.
  • So I start tearing into this codebase trying to get it into shape. At the same time we have this issue of trying to define what AI actually is. I'm over in one corner trying to fix our behavior system, but in the other corner, our execs are looking at competing games and loving their AI kicking in a door, which is really cool.
  • So there’s a kind of mismatch here between what people think is cool AI, and what we’re seeing as AI and what we’re working on.Which menas we shift focus to providing some special animations that will look really cool, under the term “Kick in door AI”, while iterating on trying to rework the bot AI into something suitable for a singleplayer game.
  • Said and done, which of course gave us a cool moment, but not a very cool AI overall. We end up creating a group to work on the concept Character Experience.So this is where I feel like we're starting to get somewhere with things, because now we're working as a group of AI coders, animation coders and animators, producing one experience of characters.
  • Problem with that is that there are character-related things that aren't AI, and there are AI things that aren't related to the character… so there are still going to be things that the reviews mark your AI down on that have nothing to do with what you think is AI.So we switched our focus to the concept of the “AI Experience” rather than trying to isolate the AI or split it into several subsystems. The important thing is simply the experience you have when you interact with the AI or any NPCs in the game. This is a very cross-disciplinary field, and I’m certain the only way to really make a good AI experience is to gather all those disciplines in one group with that experience as a focus.
  • What that kind of means is that AI is what the user experiences as AI, which is not necessarily what you meant to be AI. This also matches what you will read criticism for in the reviews of your game, which is good. It doesn't matter if your behavior system is world-class if the player still thinks your AI sucks.Much of that is going to be animations and the coupling between AI behaviors and animations.Humans are masters of body language. It just makes sense then that any character that jerks and snaps is going to be seen as slightly less smart. This mirrors the sad reality of how people act in real life too, where you can see people with nerve disabilities be treated like they were stupid.
  • My colleague from Mirror's Edge put it, our experiences are that for AI, the more you can cheat, the better it works. And as we started with Bad Company, DICE was very much a multiplayer studio and the attitude was very much “No cheating!”But I think this is a cue to take from Hollywood, where it doesn't matter how unrealistic it really is, as long as it looks believable. I usually call this Hollywood realism when I’m trying to explain this to people.I want to show you an example of this. This is a section of gameplay from our High Value Target mission, and you’re in a humvee convoy. There’s going to be a tank around the corner, and that tank is the subject of a fair amount of cheating.The tank teleports twice, and doesn’t fire a single shot that comes close to hitting you.
  • Which leads us into the design philosophy behind this stuff. Instead of looking at the AI as a set of subsystems, we divide it into two parts. We talk about roughly 80% of the AI is the bulk. That's the stuff you'll never think of, it's just there.The remaining 20% is the kick in door stuff. It's what the player will remember as the awesome AI.Here's the catch though – that only works if the bulk is flawless. Any little glitch in the bulk means that the illusion falls apart and we come crashing down into the uncanny valley.I think this is a large part about what made us fail so horribly in Bad Company 1. With the sandbox size, the AI system had to do both the bulk and the wow factor, and the split focus meant our bulk suffered.
  • So that brings us to the question of what we actually fixed to make such a difference for BC2. We implemented a bunch of things here, and while we did it, we were talking to people about what they thought.Which one do you think was the single best improvement in AI experience, overall?
  • According to that very simple research, the number one improvement to AI was adding a death animation before the soldier turns ragdoll on dying.So at a glance, that doesn't have much to do with artificial intelligence at all. The guy isn't intelligent, he's dead! But going back to our definition of the AI experience, apparently that is a factor. I think this is actually a place where the uncanny valley works in our favor. Call it uncanny hill or something.If you think about it, it's not very strange. Remember that the average AI only lives about 5 seconds. A major part of the experience of the AI is going to be killing them off. If the feedback you get doing that isn't satisfying, the AI experience wont be either.
  • According to that very simple research, the number one improvement to AI was adding a death animation before the soldier turns ragdoll on dying.So at a glance, that doesn't have much to do with artificial intelligence at all. The guy isn't intelligent, he's dead! But going back to our definition of the AI experience, apparently that is a factor. I think this is actually a place where the uncanny valley works in our favor. Call it uncanny hill or something.If you think about it, it's not very strange. Remember that the average AI only lives about 5 seconds. A major part of the experience of the AI is going to be killing them off. If the feedback you get doing that isn't satisfying, the AI experience wont be either.
  • One of the main complaints from Bad Company was that the AI would see you at great ranges. So I rewrote the sensing and the way actors would talk to each others, which took care of that problem.You'll still see some complaints that the AI knows where you are at all times and so on, which they don't. They do track you though, and throw grenades at there you ducked into cover. I think some people would probably say the same thing even if AI were played by humans.
  • We went into the production of Bad Company 2 with the mindset of creating a great experience for the player. So what happened then was that we tried to separate the AI bulk from the memorable moments to have more and better memorable moments, and that meant narrowing the sandbox. If you compare Bad Company 1 to Bad Company 2, you’ll notice that while Bad Company is very much open all the way, Bad Company 2 is linear, then an open section, then linear, and so on. Still even when it’s linear it’s never as narrow as most other corridor shooters, and destruction creats a lot of possible variations.This both let us create much grander wow moments and put a lot more focus on the bulk AI, and the result is both a stable basic experience and a memorable one.I think the major challenge here is to be able to expand on this, to be able to do even grander wow moments and to be able to create a good sandbox experience including them.
  • So one of the major problems we still had to solve was how to deal with this world. Our game worlds for the first game were simply too large to manually author positions for the AI to choose from and encode information about the environment there. Even for the second game, our sections are pretty wide and we still have level elements that are open world.So we needed to solve that to give our AI a grasp of the world. Influence maps are a fair match for this, but we have a fair bit of vertical gameplay and complex geometry which means influence maps don’t work very well.
  • So one of the major problems we still had to solve was how to deal with this world. Our game worlds for the first game were simply too large to manually author positions for the AI to choose from and encode information about the environment there. Even for the second game, our sections are pretty wide and we still have level elements that are open world.So we needed to solve that to give our AI a grasp of the world. Influence maps are a fair match for this, but we have a fair bit of vertical gameplay and complex geometry which means influence maps don’t work very well.
  • Instead I came up with a system called the Frontline system. You could see it as an influence map implemented on top of spatial information from the pathfinding system.When spreading the information in the map, we accumulate the distance to each team, which means we get a fairly accurate split of the world into friendly and enemy territory. This also gives each actor a distance to the closest enemy, which is really useful.This system means we can use distance selection for personalities. For instance, our shotgun guys prefer to get up close and personal to you, while the machine gun guys stays far away, and the snipers very far.
  • We also had to come up with some way of finding covers.The normal way of doing that would be to hand-place a bunch of cover nodes to use. We couldn’t do that because the world was simply too large. Now, that usually means you’d want to pre-calculate the cover nodes. We couldn't do that either because of destruction.What we do is use a combination of pathfinding and physics tests to find covering surfaces in the world. The process is spread out over frames, but reasonably fast.
  • Our behavior and decision system is also very much based around a choice of reactivity over planning, because the battlefield is changing so rapidly. In a way, you could say that kind of makes our AI pretty dumb, and you’d be right. It doesn’t really function well over time without guidance, but as long as enemies live around 5 seconds, that’s not going to matter much, is it?The system itself is a layered structure of behaviors lists where each layer is ordered by the layer on top of it. It sort of becomes a behavior tree, but not quite... but it’s fairly complicated to understand, and it turned out that it was slightly too reactive and making anything that even remotely resembles a state machine in it is a painful experience... So I’m not going to go into that in any further detail, and it’s something we’re moving away from now.
  • So to sum it up, the uncanny valley sucks. If you’re going to make a human AI, be prepared for it to be significantly harder than making an alien or monster AI. What the player sees and thinks is AI is what you need to care about. Trying to separate AI from animation system and from scripting and animations is bound to fail, and that’s what led us to think about our AI in terms of bulk AI and memorable moments. Also, cheat as much as you can.
  • Building the Battlefield AI Experience

    1. 1. Building the Battlefield AI Experience<br />Mikael Hedberg<br />Lead AI Programmer<br />Email: mhedberg@ea.com<br />Twitter: slicedlime<br />
    2. 2. Critical acclaim for BF: BC<br />
    3. 3. Critical acclaim for BF: BC<br />
    4. 4. Critical acclaim for BF: BC<br />
    5. 5. Critical acclaim for BF: BC<br />
    6. 6. Critical acclaim for BF: BC 2<br />
    7. 7. Critical acclaim for BF: BC 2<br />
    8. 8. Critical acclaim for BF: BC 2<br />
    9. 9. Critical acclaim for BF: BC 2<br />
    10. 10. Critical acclaim for BF: BC 2<br />
    11. 11. Overview<br />Challenges<br />What is AI?<br />Design Philosophy<br />Improvements<br />The Frostbite AI<br />
    12. 12. Battlefield AI Challenges<br />Working with Soldiers<br />The Uncanny Valley<br />
    13. 13. Battlefield AI Challenges<br />Friendly Squad AI<br />Immortal friends<br />Personalities<br />
    14. 14. Battlefield AI Challenges<br />”Battlefield”<br />Infantry<br />Stationary Guns<br />Armed cars<br />Tanks<br />Helicopters<br />Quad bikes<br />Passenger Positions<br />
    15. 15. Battlefield AI Challenges<br />”Battlefield”<br />Infantry<br />Stationary Guns<br />Armed cars<br />Tanks<br />Helicopters<br />Quad bikes<br />Passenger Positions<br />
    16. 16. Battlefield AI Challenges<br />”Battlefield”<br />Infantry<br />Stationary Guns<br />Armed cars<br />Tanks<br />Helicopters<br />Quad bikes<br />Passenger Positions<br />
    17. 17. Battlefield AI Challenges<br />”Battlefield”<br />Infantry<br />Stationary Guns<br />Armed cars<br />Tanks<br />Helicopters<br />Quad bikes<br />Passenger Positions<br />
    18. 18. Battlefield AI Challenges<br />Destruction<br />
    19. 19. Battlefield AI Challenges<br />Destruction<br />
    20. 20. Battlefield AI Challenges<br />Destruction<br />
    21. 21. Open world<br />Battlefield AI Challenges<br />
    22. 22. Battlefield AI Challenges<br />Open world<br />
    23. 23. Battlefield AI Challenges<br />DICE + Single Player = ?<br />
    24. 24. Battlefield AI Challenges<br />Code base from BF2, BFV, BF1942<br />Multi-player bot-style AI<br />
    25. 25. Battlefield AI Challenges<br />Code base from BF2, BFV, BF1942<br />Multi-player bot-style AI<br />
    26. 26. Battlefield AI Challenges<br />Code base from BF2, BFV, BF1942<br />Multi-player bot-style AI<br />
    27. 27. Battlefield AI Challenges<br />Code base from BF2, BFV, BF1942<br />Multi-player bot-style AI<br />
    28. 28. What is AI?<br />Behaviors?<br />
    29. 29. What is AI?<br /><ul><li>Behaviors
    30. 30. Animations?</li></li></ul><li>What is AI?<br /><ul><li>Behaviors
    31. 31. Animations
    32. 32. Character Experience?</li></li></ul><li>What is AI?<br /><ul><li>Behaviors
    33. 33. Animations
    34. 34. Character Experience
    35. 35. AI Experience:
    36. 36. Decision system
    37. 37. Behaviors
    38. 38. Animations
    39. 39. Scripting
    40. 40. Voice overs
    41. 41. ... more?</li></li></ul><li>AI Experience – Main Problems<br />Coupling between:<br />AI behaviors<br />Scripting<br />Animations<br />Animation fluidness<br />Non-reactive NPCs<br />Decision Oscillations<br />
    42. 42. AI Experience – Acting<br />Cheating = win<br />
    43. 43. AI Experience<br />80% bulk AI behaviors<br />20% memorable moments<br />
    44. 44. Improvements for BF: BC 2<br />Dynamic Pathfinding Features<br />Sensing Rewrite<br />Improved AI-Animation Integration<br />Seemless Cutscene to AI transitions<br />AI Insertion Sequences<br />AI Soldier Death Animations<br />Improved Scripting Support<br />Improved Combat Cover Selection<br />New Cover Animations<br />
    45. 45. Improvements for BF: BC 2<br />Death animations<br />
    46. 46. Improvements for BF: BC 2<br />Death animations<br />
    47. 47. Improvements for BF: BC 2<br />Sensing rewrite<br />
    48. 48. Improvements for BF: BC 2<br />Focus on the player experience<br />Script the memorable moments<br />Open world -> wide corridor, arenas<br />
    49. 49. The Frostbite AI<br />Environmental awareness<br />
    50. 50. The Frostbite AI<br />Environmental awareness<br />
    51. 51. The Frostbite AI<br />Frontlines<br />Positional awareness<br />Personalities<br />
    52. 52. The Frostbite AI<br />Automatic cover detection<br />
    53. 53. The Frostbite AI<br />Reactivity over planning<br />Layers of ordered behavior lists<br />
    54. 54. Summary<br />Uncanny Valley<br />Player impression of AI is what matters<br />Stable bulk + memorable moments<br />Cheating = win<br />
    55. 55. Questions?<br />Mikael Hedberg<br />Lead AI Programmer<br />Email: mhedberg@ea.com<br />Twitter: slicedlime<br />

    ×