Implementing robust AI for SecondHand: An Introduction

By January 23, 2017Development Blog

Things have been busy at Rikodu, but I finally decided to bite the bullet and post some technical write-ups about the systems we’re building for SecondHand. And what better place to start than AI, my favorite part of game development?

SecondHand’s Ai philosophy

When it comes to AI, all games have their own special blend of requirements and challenges that make each implementation as unique as the design itself. A good definition of what good AI is is still elusive but this quote is as close as it gets:

“To be enjoyable, an AI must put up a good fight but lose more often than win.
It must make the player feel clever, sly, cunning, and powerful.
It must make the player jump from his seat shouting,
“Take that, you little shit!”

Mat Buckland, Programming Game AI by Example

How does that translate to a fast paced action game, like SecondHand? Here’s a list of things we want the AI to handle:

  • Enemy positioning
  • Dramatic pacing
  • Difficulty scaling
  • World-building through unique behaviors
  • Level specific behaviors

Project history

Our approach was an iterative one. We started out with having a very simple state machine for the enemy agents. After it became apparent that we need the enemy agents to be well coordinated, we built an Ai Director that handled the rate at which they attacked. The spawning was handled by heavy level centric behaviors that included lots of trigger boxes and spawning waves.

At this point it was clear we were having issues in this specific areas. The enemies were unable to consistently pose a threat to the player due to positioning and coordination problems. Level difficulty was close to impossible to control. The pacing of the game was chaotic. Extending enemy behavior became really difficult due to the constraints of the state machine decision making

The current iteration

A new iteration was imminent, that brought us to where we are today, Namely:

  • use an influence map/utility system for enemy agent positioning
  • have an Ai Director to control game pacing (spawning, intensity) similar to what the guys at Valve did with Left 4 Dead (check out Mike Booth’s presentation here)
  • move decision making into Behavior Trees
  • create sufficient debug tools & visualization to be able to tweak & debug everything

Here’s how everything came together at the end of November:

I’m going to aim for a three part discussion: Enemy Positioning, Pacing and Decision MakingStay tuned!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.