Google+

Return of the Wolves

Leave a comment

16 May 2012 by Ian Davis

Early on in my development of the game I added a lone wolf, represented here by a long block:

I took the wolf out some weeks ago because it kept wandering into shot when I was taking my videos. Now the game has moved along to the point where I want to add wolves (and other mobs) back in. As I mentioned back in my introductory post (almost exactly a month ago), moving creatures will be a big part of the game, especially the robotic automatons that I want to you to be able to create and use to defend yourself with. To achieve that I want to enable different combinations of behaviours to be bolted together. For built-in animals like wolves these behaviours will be fixed but for the constructed automatons the player will be able to tweak them in all kinds of ways.

The classic text in this area is Craig Reynolds’ 1999 paper Steering Behaviours For Autonomous Characters which outlines algorithms for several basic steering patterns:

  • Seek and Flee
  • Pursue and Evade
  • Wander
  • Arrival
  • Path following
  • Collision avoidance
  • Flocking (subdivided into Separation, Cohesion and Alignment)

These can be combined to produce some quite realistic behaviours. In my implementation I give each mob type a list of MobBehaviours, each of which looks like this:

type MobBehaviour struct {
    behaviour   uint8
    targetType  uint8
    targetRange uint8
    targetAngle uint8
    weight      uint8
    sunlight    uint8
    last        bool
}

The behaviour field specifies what kind of behaviour pattern to use such as Persue or Wander. targetType, targetRange and targetAngle specify a particular type of thing that will trigger this behaviour if it comes within range and field of view. The weight field enables a particular behaviour to be more dominant than others when triggered. sunlight gives a range of valid light levels for the behaviour (so mobs could sleep at night or hunt at dusk). last simply indicates that no other behaviours should be triggered if this one has been.

I’ve used this to reimplement the Wolf in the game and added random spawning of wolf packs as you move around. The results are quite fun. Their natural behaviour is to wander around as a pack. During the day they will only attack if you get really close to them but at night they will pursue you from a much longer distance. I’ve tried to capture this in these videos but it’s quite hard because I’m constantly thinking about how to get the best shot for the video while trying to keep out of the way of the wolves. Also, I’m rapidly turning the camera and the player which looks jerky on the video. When you’re playing it’s veyr immersive but watching on a video is harder. The wolves are represented by the open squares moving around the landscape. When I recorded these last night I hadn’t implmented upward movement for mobs so they tended to get stuck in depressions in the ground. Since filming them I added auto jumping up blocks and now they can chase you a long way!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: