Autonomous Agent Movement Part 1: Introduction

Posted On: 2022-02-07

By Mark

Previously, I mentioned Autonomous Agent Movement as a major missing piece in my project. Since the topic is so important, I thought I'd write up a series of posts about it: what it is, why it's so important, and why it's particularly challenging to implement for my project.

What is it?

To start with, an Autonomous Agent is (roughly) an intelligent agent (something that perceives its environment and makes decisions) which controls an individual character in a game. Technically, an Autonomous Agent can be as simple as the Koopas in a Mario game (walk forward until a ledge is detected, then turn around), but most literature on the subject covers much more complex decisions and behaviors - such as long-term planning or balancing competing needs in an ever-changing environment.

When designing an Autonomous Agent, it's possible to achieve complex behavior by layering decision-making systems on top of one another. For example, if one is designing an agent for a survival game, it may need to be able to accomplish a variety of different kinds of decision-making tasks: determine which resources it should pursue (ie. is it hungry? tired? in danger?), where to fulfill that need (ie. where's the closest food/shelter), and how to get there (ie. using a rope to climb vs walking the mountain trail). Often, such hierarchies have movement-related decisions at their foundation: there's no point in pursuing a resource one can't reach, after all. It is this foundational decision system that I refer to as "Autonomous Agent Movement", and it is the way that the agent solves the problem "how do I get where I want to go?".

Isn't that Pathfinding?

"Pathfinding" is (roughly) the task of determining a series of steps that can take an agent from the current location to a destination, accounting for the details of the terrain (obstacles/steep slopes/etc.) along the way. It is the cornerstone of most decisions about movement, and as such is often used synonymously with agent-based movement. It is not, however, the whole picture: movement requires actually following the path - and it is often responsible for reconciling when the path doesn't quite conform to other systems (ie. when a path tries to cut a corner that the physics won't allow.) When I write about Autonomous Agent Movement, I am referring to the combination of these two systems: pathfinding and path following.

If you've played any game with some kind of physics simulation (ie. a shooter, a village sim, a 3D adventure, etc.), chances are you've seen Autonomous Agent Movement at work. Any time a character runs to cover, walks to visit a neighbor, or chases the player character around, it's very likely an agent-based system made that movement happen. With so many projects all trying to solve the same problem, it should come as no surprise that there's a tremendous amount of information about the subject - and a number of pre-built solutions available. Importantly, however, in many cases these projects are solving similar problems, not "the same" problem. This distinction is important, as there is no universal solution to Autonomous Agent Movement: one must work within some kind of constraint, whether that's fitting the environment to a grid or trying to store a massive map inside a (comparatively) small amount of memory - and what constraint works for one project will often differ from what works for another.

What Other Kinds of Movement Are There?

Perhaps the most common competing kind of movement is pre-scripted movement. Simple effects like "play walk animation wile moving left at 1.3 units per second for 3 seconds" can produce movement that looks convincing to the audience, but without any of the "smarts" that an agent-based approach would have. Such pre-scripted movement is often used to augment narrative elements (ie. cut-scenes or dialogue performances) or to add motion to an otherwise static set-piece. Pre-scripted movement is very brittle, however: if any of the relevant elements can change (ie. actor position, destination, or terrain between them), then the script either needs to account for it or risk breaking immersion/game rules (ie. a pre-scripted enemy might run through a solid wall.) As such, the cost (effort/complexity) of pre-scripted movement is only low when there little dynamism - the more the movement needs to account for changes, the less sustainable hand-authoring that movement becomes.

What's next?

Hopefully this post has served as a decent introduction to Autonomous Agent Movement. Next time, I'll dive deeper into why it's so important - both generally and for my project specifically. I hope you'll join me then.