OPREP - AI PATH-FOLLOWING IMPROVEMENTS

reported by Krzysztof Bielawski on November 11, 2016

UNIT: Krzysztof Bielawski, Senior Programmer, Programming Dpt.
TO: Arma 3 Users
OPSUM: Introducing the latest AI path-following improvements for wheeled vehicles.

Over the course of many years of development, Artificial Intelligence in the Arma series has grown into a very sophisticated system. For example, computing a route and following it on any terrain - be it a vanilla or a modded one - is, generally, something the AI manages to pull off on a daily basis. They are able to control multiple types of vehicle, be aware of enemies and dangerous areas, and navigate on roads and across bridges - all while avoiding collisions - but not always in the most effective manner.

As the number of options for the AI grew, the number of issues, edge cases, rare configurations and parameters rose as well. Plus, with the Apex expansion and its terrain, Tanoa, having unique bridges, the amount of the tweaks necessary for smooth gameplay increased drastically. Thus, it was finally time to re-address our AI path-finding. In Update 1.64, we introduced a revamped, refactored and vastly improved AI driving overhaul of wheeled vehicles. Below, we take a closer look at where we've ended up, how we planned our route there, and what still lies ahead.

RECON & OBJECTIVES

As part of the research phase, we looked at player's feedback from the forums, internal bug reports, Feedback Tracker Issues and analyses made by our designers. We concluded that not only did the immediate behavior of drivers need some improvement, but also our platform goals (such as being more open, friendly to modding, and clearly configurable for the scenario makers) had to be met, too. Technically speaking, we wanted to make this part of code cleaner and easier to configure, expand, and maintain.

We also wanted an understandable separation of config definitions. Ultimately, some functions and parameters would be editable by scripts; both developers and players would have more options to modify AI behavior. That said, the player experience needed an improvement as well. Making AI the drivers more fluent and confident became a priority. We hoped to succeed by improving the survivability of vehicles, precision of their driving along the selected path, and, ultimately, their behavior in formations.

LOGISTICS & PLANNING

As a first step , we made use of one of the features the Real Virtuality engine provides: components. A component, simply put, is an object wrapping certain functionality, which can be attached to an entity (e.g. vehicle, person, weapon or tree). We moved the whole old driving system into a new AICarSteeringComponent. This approach allows us to set up sophisticated objects from smaller elements, making systems more flexible and configurable. The refactoring itself was painfully long, but resulted in more configuration flexibility. The definition of a vehicle can now include feature-specific parameters, encapsulated in the Component class. This solution is also fully backwards compatible, so creating a vehicle config without the new component means the engine will revert to the AI's old method of driving instead.

Encapsulation of the feature allowed us to refactor some key functions. We started with the act of steering: controlling the steering wheel, acceleration and brake pedals. We used a new controlling method and reconfigured it from scratch using the old vehicle data. We aimed to make the AI more aware of the shape of its path in the front of the car, and use PID controllers for tuning the steering vector and pedals input. The system turned out to be reactive to input parameters and can adapt to different cases, which, in the end, helps with the precision of path-following.

RESEARCH & DEVELOPMENT

We also made another iteration to formation behavior, making cars behave more naturally in convoy situations. The new formation logic uses old routines to determine the formation position for each vehicle, but also makes sure that cars are following each other properly. We made better use of the position of the leading vehicle. In short, the leader now creates a path for the next vehicle based on the historical position of the front one.

Scenario creators can now also use new commands to tweak the behavior (e.g. setConvoySeparation - to set a specific distance between vehicles in convoy). Some of our designers already took advantage of the new features and, based on community reactions, scenario creators are having fun with AI drivers, too. Our next step aims to convert the existing driving component from wheeled to tracked vehicles. We may see some interesting new convoy missions appear soon!

FINDING & FOLLOWING

Perhaps to your surprise, one thing that hasn't changed - at least on a technical level - is the actual 'path-finding' itself. When ordered to move, each AI driver will first calculate the path to a destination point and then follow it. The first part of the algorithm is called 'path-finding' , the second 'path-following'. The scope of our changes was mostly limited to the latter, and we avoided making changes (apart from small tweaks) to the path-finding algorithm. The reason for that is that those methods are shared between all different classes of objects in game. Specific parameters of vehicle types, like information on how costly it is to cross particular piece of terrain by particular class of vehicle, were tweaked only for wheeled vehicles.

Making major changes to such systems produces a large amount of issues. During development, we encountered a large number of bugs. The mix of low-level refactoring, addition of components, and config changes made the feature more difficult to clean and finish. To provide an example of how changing one class affects the other: tweaking values for Ifrits made Tempest trucks drift around or hit every single road sign along the way in a convoy formation. We set up around 30 different test cases: on different roads, with different vehicles, setups, waypoints, parameters of waypoints, and many more. Of course, all of them had to be retested after most iterations.

ACHIEVEMENTS & CREDIT

After a long and bumpy road the new AI driving released in Update 1.64, we definitely feel it improved both engine capabilities and the sandbox gameplay experience. We managed to clean up a long-standing feature and refactor it in a way that makes it still backward-compatible, but also modernized and more configurable. Playing existing scenarios should be more fun, especially those which utilize convoys of wheeled vehicles. Better handling hopefully means that there will be more scenarios using AI-controlled vehicles - we hope to see fresh ideas emerging and to inspire awesome new game modes, too.

A big thank you to all of the users who shared their thoughts and feedback on the forums. Many players joined the effort and reported problems in specific situations or vehicles, and many gave their opinion on the state of the moment. It was both captivating to read and motivating to iterate; sometimes even surprising to discover how many ways you can test the game. You can still come there and post your own experiences; we are constantly monitoring the feedback. You can check the progress there or join in the discussion - tell us how you want to use AI in your latest, greatest custom scenario!

Krzysztof Bielawski
Senior Programmer, Programming Dept.