Sign in to follow this  
  • entries
    4
  • comments
    11
  • views
    17595

Oh god, they're coming!

Sign in to follow this  
lwm

1095 views

I've mostly been working on the AI lately, because without an AI that gives the player at least somewhat of a challenge, a stealth-based game would be rather boring. Behavior trees seem to be very popular these days, so I implemented the basic node types using iterators in C#. "Abusing" iterators for anything other than lazily evaluated collections is a lot of fun, although it certainly takes a moment to wrap your head around the unfamiliar control flow.

In my specific case, I found behavior trees to be awesome for fine-grained behaviors. For example, when one of the enemy avatars hears a suspicious noise, I want it to stop for a few milliseconds, turn around, raise it's weapon and look around for a couple of seconds. Using behavior trees makes that very easy. For higher-lever AI though, like deciding the most probable position of the player and doing a systematic sweep of a room (possibly with the aid of some allies), a simple hierarchical state machine turned out to get me the desired result much quicker and with less code.

I decided to use an influence map to allow the AI to track the player's position. Unfortunately, the enemies would often run around in circles because by the time they had investigated one corner of the room, another, already visited part of the room had filled back up. Tweaking the momentum and decay only got me so far, so I added an additional "channel" to the map to slow down the momentum for areas the AI had already visited. I'm pretty happy with how it turned out, the AI seems considerably less stupid now. smile.png

Here is a screenshot of my avatar being chased by an enemy:
roa_ai.jpg

Better quality: [1]
Sign in to follow this  


1 Comment


Recommended Comments

I'm a big fan of stealth games, and, since I recently found a cool lighting library, I may look into making a fun stealth game, but from a top-down 2d perspective.

Looking forward to it.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now