Skip to content

Creating the BATTLEFIELD AI Experience

Keynote. Discover what choices helped DICE improve the AI/gameplay from good to great in their most recent franchise.

Mikael Hedberg (Software Engineer at DICE (Electronic Arts), working on the Battlefield franchise).

AiGameDev.com summary and slides.

My Thoughts

Having recently played the game I did realise it had scripted sequences. More then I realised actually! It was also interesting how the original game apparently had such bad AI – the sequel might be better, but it sadly wasn’t very smart, however coping with building destruction and cover manipulation is something you don’t see very often.

Talk Content

Battlefield: Bad Company’s AI was complained about in reviews. Battlefield: Bad Company 2 got better AI reviews, at least noting a lot of improvements.

Challenges

Working with soldiers and the uncanny valley because they are not creepy crawlies. Short description of the uncanny valley here. Can’t follow some other games like Halo such as grunt fleeing since it wouldn’t be accepted as real.

One good failsafe is that if an AI goes wrong the player will just shoot it and move on. Lifespan of enemies in BF:BC2 is also quite low – average of around 5 seconds, median of 3, and so don’t have much time to mess up. Friendly AI is also immortal, and have personalities.

AI run a lot of items too; infantry, guns, armed cars, tanks,helicopters, quad bikes and passenger positions. Tweaking the game had knock on effects – tweaking physics meant the AI might end up landing a helicopter upside down.

Destruction is also a challenge – since a lot of buildings can be blown up and sometimes forces the player to use it. It needs to take this into account – BF:BC didn’t, but BF:BC2 does. Couldn’t use the Killzone mapping algorithms because Line of Sight can be opened from any part of a building being destroyed.

There is also an open world with some levels. Players can come from multiple angles and paths so can’t script it a lot. Caused a problem even in the sequel when things were narrowed down a bit.

DICE was also a multiplayer studio before Battlefield: Bad Company. Always made the AI to have it used in co-op and has just come out for BF:BC2.

Code base from BF2, BFV, BF1942, BF2042. Multi-player bot-style AI. Not a good fit for singleplayer game. Essentially starting from scratch but some AI code from 4 games available.

What is AI?

Behaviours – got some scripted moments in the original BF:BC which were not AI (kicking in doors, grenades), so the AI still sucked. AI isn’t just the behaviours.

Animations – AI isn’t just the animations.

Character Experience – The whole character experience; decision system, behaviours, animations, scripting, voice overs..and even more. Kept together in one team so someone is responsible for it.

AI Experience – Main Problems

Coupling between AI behaviours, Scripting and Animations. Animation fluidness, non-reactive NPC’s and decision oscillation need to be looked at. Gets back to the uncanny valley situation. Twitches for instance make something seem stupid.

AI Experience – Acting

Doesn’t work in multiplayer but cheating = win for singleplayer. Designers wanted cool things to happen. In the end was cheating pretty much as much as possible.

Tank in a sequence of the game with jeeps it teleports twice as well as not aiming at the player. If it didn’t it wouldn’t have been able to keep up so wouldn’t have been cool. Talking about hollywood realism – things that move way to fast or explode a lot.

AI Experience

80% bulk AI behaviours, 20% memorable moments. Was probably the reason it was a problem in BF:BC since it was all attempted in the AI system.

Improvements for BF:BC2

See picture of list of items. Less canned animations (jumping out or over things, taking cover), better pathfinding with destroyed buildings with improved cover selection (where it goes and gets there).

Which feature was the biggest improvement? Death animations. It’s not all that strange, the only interactions you have is you’re fighting them, for a very short time, and killing them. The feedback from that needs to be satisfying.

Sensing rewrite also helped – cannot see you across the map, and also throw grenades to last known positions or blowing up cover with explosive weapons.

Was also a big focus on the player experience. Scripted a lot of memorable moments, moving from open world to wide corridors/arenas. Still very wide corridors compared to most FPS games, so still AI issues. Don’t see the issues you see in Bad Company 1.

The Frostbite AI

Environmental awareness was created. The AI doesn’t have the nuances the player has but instead a graph of nodes. Couldn’t use maps generally because of the resolution issues (too big is impossible on large levels). However did add pathfinding based maps to move closer if you’re combat troops, hang back if a machinegunner and far back if a sniper.

Cover detection is automatic too; especially since cover changes and gets destroyed. Done in run time. First broad search on pathfinding mesh, and also the physics test which is expensive but also can be cached (for all AI’s) and doesn’t need to run fast – can find cover in a few seconds which is fast enough.

The AI is reactivity over planning, layers of ordered behaviour lists. This is because of the short lifetime span of the AI. This however does mean it is hard to write things to cover a lot of areas.

Summary

Uncanny valley is the main problem. Aliens or creepy crawlies would be good. You’re in for a ride using human characters.

The players impression of AI is what matters so there are divisions of memorable moments.

Also do cheat!

Questions

Q. How did you handle scripting with destructible environments such as allies taking cover?

Scripting is really hard with destruction, and there are areas where you can break the scripting but in actual results it doesn’t happen all too much. Tend to not script the AI into certain covers too often, or done they are made indestructible. Mainly let the AI roam free and look for nearby cover in a specific area.

For open positions, the AI is not usually left there – backup behaviour is crouch and shoot and isn’t too awesome.

Q. How often do you recompute the destructible and cover?

Recompute around the explosion what cover is destroyed, and let the search algorithm come again in future frames to find new cover. If there is a big explosion you don’t care if they take cover there immediately.

Q. How many AI soldiers do you run?

We have up to 20 AI soldiers running at once, including vehicles. Have considered putting cover data into the objects themselves, but making a rich world the artists place things in odd and unexpected ways. Looking at future titles is to move it away from run time to build time but it is a fairly difficult problem.

Q. How do you do physics tests for cover selection?

Essentially find an edge in pathfinding and do a normal for the physics test and do some ray casts to get an area where you can not be shot at. Need also to calculate if you can stand behind it or need to crouch.

Q. What about the co-op AI?

Fixed some bugs, 5-10, but essentially it is exactly the same as the singleplayer AI.

Q. Multiplatform use?

Essentially the codebase is battlefield 2 PC codebase so don’t take use of SPU’s very much for instance.

Q. Emergency AI for soldiers who’s cover is destroyed?

Usually run to a nearby cover in range instantly. Otherwise nothing special, just stand at you which is a pretty good reaction.

Q. Vehicles AI?

A few specific behaviours for helicopters because they are complicated but tried to avoid it. Specific vehicle driving code and each vehicles define the behaviours which the AI can use on them, but are common across many vehicles.

Q. What cover selection is done? Closest?

Only thing that really matters is it protects them from the enemy. Treat the cover as 2 things; position in the cover where there you can hide, and a space outside the cover to shoot from. Will alternate between hiding and not,

Q. What about the behaviour lists from previous Battlefield games, are they the same?

Essentially BF:BC2 uses just an updated list, it has quite a legacy.

Q. What about the animations? 20 characters is quite a lot.

Animation is involved in the AI code. Updates are done depending on where the player is facing. Fairly heavy amount of modding involved.

Q. What about cheating for squad members? any examples?

Definitely; mainly to stop screwups and getting stuck. They run faster then you can if you turn your back. If they fall really far behind they teleport up to in range.

Q. Do you have any kind of prediction system to guess where the players are?

Has a cover suppression system to shoot around cover the player is/was behind, and attempt to blow it up with explosives. If they can’t see the player, even buildings might get attacked. If it is a long time they go and investigate and see where the player went.

Post a Comment

Your email is never published nor shared. Required fields are marked *