Sunday, June 17, 2018

Tabletop FPS AI system

I've been playing around with a system for NPC movement on a hex grid. I'm making the system for use with an FPS, but I imagine it could be used with some alteration in any number of applications.


I've only done the most basic testing at this point and I'm sure the system will change in a few significant ways (at least in terms of visual representation if not logic) but I think its a good starting point so I wanted to share.

The system I've come up with uses 4 subsystems; 3 small decks of cards and marked paths on hex tiles. These 4 systems are used to create 3 basic ai behaviors. The basic behaviors are Patrol, Pursuit, and Search.

Patrol

Hex Tile
The patrol behavior moves characters along a set of colored paths. Occasionally, those paths will split at a node position.
Patrol Card
When a character is on a node position the players draw a patrol card to find out which path they will take from there. Basically, they will take the first color that makes sense from their current location and if there are two of the same color paths leading from their location they will take the path that matches the direction indicated by the arrow. If two or more characters are ever going to move into the same space at the same time, they all reverse direction.

Pursuit

  
If a character sees something that they are supposed to attack, they will begin to pursue it. They stop using the patrol paths and instead draw a Pursuit card. These cards are essentially conditional statements (IF this THEN do this) with a default behavior if the condition is false (ELSE do this). The condition (IF this) is always if the target is greater than X range AND in the cone of fire (i.e. can the character see the target), and the THEN is either move forward or move forward twice. The ELSE is either to rotate towards the target or to strafe towards the target. This basically means that if the character can see their target they will move towards them, if they can't they will adjust their view by either turning or sidestepping in a direction that will likely make them see the target.

Search

  
Since its entirely possible that a character might lose sight of a target, they also need a behavior to reflect the knowledge that something is out there and they can't see it. For that behavior, they use the Search deck. This deck is similar to the Pursuit deck in that it uses conditional statements to determine actions, but it creates different behavior. The IF this part of the conditional doesn't include anything about if the cone of fire because the moment they can see a target they would switch back to Pursuit. Instead, it looks at the distance to an obstacle. And that distance is always directly in front of the character. And the THEN this behavior can be either to move forward or pause (i.e. don't move), while the ELSE result can be to rotate left, rotate, right, or reverse direction. This gets the character to move around the board in a way that kind of looks like they are looking for something.

No comments:

Post a Comment