Building Hunted’s AI: Some Fundamental Elements

So Jim has been going on about how dynamic AI combat is the heart of Sir, You Are Being Hunted – let’s look at what that means from the perspective of the development work we are actually doing. I’ve illustrated this with a few shots from the AI testscenes build, which shows some of the “scene view” elements of Unity’s editor. Obviously the scenery and so forth is placeholdery and not actually intended to be seen as the sort of scale or density we’re expecting for a final game.

One of the key features we wanted in Hunted, was the ability for enemy AI to behave as autonomously as possible. Rather than groups of AI being introduced at scripted intervals and exisiting only to provide staged skirmishes for the player, we wanted to see them wandering about the landscape with their own objectives. This adds a significant level of complexity to any AI design.

The enemy NPCs in hunted come in several varieties. The main class are the mobile hunters – the red visored chaps you’ve seen in the first few screenshots – these guys patrol from one location in the world to another, and on arrival will rest, interact with one another and perhaps search the local area for tresspassers or loot. To facilitate this I designed a procedural generation system that places detailed areas of interest (hubs) across the world, connected by trails across the intervening terrain. The hunters move in squads of different factions and travel along these pathways between the hubs. Navigation is done via a nodebased a* network, which is created and stored at the same time as the world is generated. Hubs contain a much higher level of detail in terms of obstacles and waypoints. Hubs generally attract both the player and NPCs as they are generally the location of valuable resources and cover/safety. The wandering hunters have several states of behaviour, governed by a simple Finite State Machine manager. The states are:

Wander: NPCs move between hub locations based on various internal reasoning algorithmns, sometimes they will stop for a while and rest, or even loiter on roads outside of the settlements.

Alert/Search: If an NPC hears a nearby sound, or sees either the player or another NPC from a rival faction, they will switch into this state. In this state the hunter approaches locations close to the last heard sound or last sighting, their viewcone detection increases and they will continue exploring nearby areas until they encounter an enemy or eventually get bored and return to wandering.

Combat: If a hunter sees a target and can approach to within combat range (dependent on the range of their weapon etc), they will do so. In this state NPCs will reload and move to keep in range of their target and when losing sight of the target they will attempt to round appropriate corners to track them down.

Cover: Every time an NPC is injured they have a chance of switching to a cover-seeking state (more likely as they become more heavily wounded). When in this state they abandon all combat and run to the nearest cover location (essentially calculated from a list of locations that are out of sight of the enemy that is pursuing them). Once in cover they will constantly look around themselves to spot any chasing enemy. If found and attacked they will run on to another potential safe spot. If safe for long enough they will regain their courage and return to either a combat or search state.

When two opposing squads meet at a hub they react to each other in the same way as they would to the player, a skirmish occurs and one side will usually end up wiped out (though occasionally they may pass safely by each other or a few stragglers may escape to wander onwards). Debugging this sort of AI is a tricky task, as the character models don’t (currently) easily indicate what state they are in. To remedy this I draw a number of helpful indicators in the scene window. Icons above NPCs show their states, their HP and their faction. Viewcones, target lines, shot lines and sound lines are also available. The system is going to require Jim and James to spend a lot of time working on balancing, as we have to deal with situations where other players and NPCs also enter the fray (at the moment hunters that are infighting will only switch to the player if they are significantly closer and not already engaged).

Right now the framework for all this behaviour is in place, and we now need to start making it function as games usually do – with visual feedback that can understood in the context of the game, and the appropriate behaviours for a player to work out what is happening, and successfully interact with the AI. We’re hoping to have a “test village” up soon, and from there we’ll be able to show off some of the behaviour in motion – complete with some more tech bells and whistles that will make the factional battles believable and compelling.

In future we’ll talk in a bit more detail about combat behaviours, and also the way in which we intend to enable to hunters to actually track down the player.

Poachers, TweedPunk, And Clever Materials

Click images for full size!

Sir, You Are Being Hunted is focused on dynamic AI combat across an open world. We want encounters to occur naturally rather than being scripted. The heart of the project is therefore based around our robot enemies hunting you, and each other. That means developing some interesting global and local AI behaviour, which Tom will be talking more about later this week.

What you can see in today’s screenshots is our second AI character, called The Poacher. These are stealthy, ambush-based baddies, who lay in wait for you across the landscape. The Hunters, which we’ve posted a few screenshots of previously, are much more active, and pursue you across the landscape, heading to where there has been player activity, to seek you out and take a scalp.

Of course when robots from different factions meet, there’s likely to be a fight. The Poachers happily take down tresspassing Hunters if they encroach on their territory. Poachers tend to carry and use traps, which can render their opponents wounded and immobile – dangerous for an exposed Hunter, or the unwary player. Cunning Hunted players will be able to re-purpose these traps for their own devices. Some Poachers will even carry dynamite – you know, for fishing and stuff.

You might notice that some of the objects in these new scenes have different levels of shader detail. This is because we’re experimenting with some essential tools for world-creation, such as substance textures. You can see that on the wall that the Poacher is shooting over. Rather than creating a final texture, we are able to play with variables and generate vastly different-looking walls by using a single material. This is a technology we’re hoping to apply to a number of procedural features in our sinister countryside, such as hedgerows and walls.

Finally, we’ve had a few comments on the “Steampunk” nature of our world – we’re not entirely happy with that. It is, perhaps, in some ways steampunky, but certainly not Victoriana. There are elements of high modernity – the laser visors on the Hunters, wind turbines, and so on. If such labels must be applied, we’d like to appeal for you to use “TweedPunk”, “ToffPunk”, or “UncannyChapPunk”. Thanks!

More soon.

Sir, You Are Being Hunted

Sir, You Are Being Hunted is a procedurally-generated first-person game of stealth and survival set in a very British world where robots hunt humans for sport. You must use your wits and possibly a flask of tea to stay alive.

Sir is a sandbox experience, where each playthrough is completely different, thanks to our British Countryside Generator. Choose how you escape from the islands: using violence, or using trickery and stealth. This brutal and unforgiving test of your mettle is now available for Windows, OSX, and Linux.

Buy it here:

Or on Steam.

Here are a couple of videos of the game in action: