The 'Hitman' series considers itself to be among the few succesful 'intelligent shooters', 'strategic shooters' or 'stealth games' ("Thief", "Splinter Cell", "Metal Gear [insert ridiculous surtitle]") that are hitting the market nowadays.
When you think about it, the term "Intelligent shooter" could be viewed as rather pretentious, as it implies a certain amount of Intelligence. Sure, you might argue that it is a game that requires intelligence from the player, but no player will think twice if he is not required to. Why plan your sneaky moves if you can get away with tricking a couple of dumb-as-a-doorknob bodyguards, or -even easier- shooting them point blank in the face?
A good stealth game, like Hitman, delivers the illusion of a believable world, with believable characters, and more importantly does this in such a way that the player is stimulated to play the game as if everything was real - What would I do in real life? Sneak passed the gate? What if there are more guards nearby?
Hitman certainly delivers many opportunities for the player to experience such situations. The feeling you get when you outsmart a small army of bodyguards, and get to suffocate the target, in his sleep, unnoticed, is one of the best you can get from any video game. Yet, the 'Hitman' games also have their flaws when it comes to Artificial Intelligence -or sometimes, lack thereof- sometimes guards are too easily fooled, yet at other times, they are too smart to be true.
We had the privilege of discussing the issue of Artificial Intelligence and the 'Hitman' series with Jonas Lind. Jonas works at IOI where he was involved in the development of the different Hitman games, including 'Contracts' and 'Blood Money's AI scripting and programming, and level design.
Jonas, could you please give us a general idea of the way Artificial Intelligence for Non-player characters works in 'Hitman Contracts'?
Well, we lay down a basic behavioral set (which we call the Base Scripts) for the NPCs to use, which covers about 65%-75% of the behavior and then we 'hand-script' the rest.
- Things that the base-scripts usually handle is seeing and acting on; seeing through disguises, seeing people getting killed, seeing a dead body, hearing a gunshot and so forth.
- Hand scripted situations include setting up dialogue between two NPCs or between Hitman and an NPC, reacting to the chimney bomb (in Beldingford Manor) and other less than standard type actions.
Some events are written manually, because they are specific to the situation. Most events, like gunshots are not triggered by the scripts but by engine-code. The scripting language is quite powerful, and has just been receiving a huge overhaul, which makes it even more so.
On a generic basis, AI has vision, hearing and tactile sensors to rely on. They feel when they get hit. They also hear the gunshot and the direction from which it is coming. Last, they also see the bald man shooting at them, unless of course the player was smart and kept out of visual range.
In terms of hearing, NPCs can only 'hear' a certain number of predefined events. Examples of these are Gunshots, footsteps, explosions, calls for aid from other NPCs in distress, a bullet hitting something close by and more. The NPC then has the option to investigate in the area, which the sound emitted from. Depending on what state the NPC is in, he will either go and investigate the sound, or ignore it. In terms of vision, it works the same way. The NPCs can also only "see" what is important to them, gameplay wise.

"Let's find out what goes 'round inside that head of yours..."
All guards on all the levels, react more or less the same to events that happen, unless specifically told otherwise. So, when a guard hears something, and he is not doing something of particular importance, he will seek out the source of the noise. So say a patrolling guard inside a house is walking down a hallway. If he hears a gunshot coming from the living room, he will be instantly alerted. He will draw his gun, and run towards the living room. If he does not find anything there, he will stand around there for a bit, walking a little bit around, looking around suspiciously, and eventually he will return to his patrol route. Now, if the guard actually found a dead body in the living room, this would take top priority and he would immediately run towards the dead body, unless he saw or heard anything life threatening to him. Investigating a dead body has very high priority, since the guards care for their buddies, and since it can relay important information to the other guards. If the dead guard's outfit was taken for instance, the guard investigating would know to look for a person dressed as a guard, and alert the rest of the guards in a jiffy.
Technically, what happens is that the guard is patrolling, in what we call Neutral state. Hearing a gunshot, is equivalent to the guard receiving a "Gunshot" event. This event is processed and evaluated as being very important in neutral state. This provokes a state-change to the Suspicious state, in which the guard will a particular sub-state handling a gunshot heard, event. The first thing this state does, is make the guard draw his gun, and subsequently, the state orders him to run to the source of the gunshot. If the guard then sees Hitman close to the dead body in the living room, he will evaluate the situation, and in all likelihood come the the conclusion that Hitman was the perpetrator. This would cause another state change into Attack state, which would case the guard to shout a challenge, and attack Hitman. If Hitman was smart and dragged the dead body away from the living room, then the guard would arrive there, look suspiciously around for a while, and do what we call a Stand down to Neutral state. This causes the guard to resume whatever it was he was doing prior to the event provoking the first state change (into the Suspicious state), thus making him resume his patrol.
There are four basic 'mind' states. Normal, Suspicious, Attack and Panic. Most guards do not have the Panic state and most civilians do not have the Attack state. For each of these states there anywhere between 5 and 20 sub states (and some of these have sub states as well) that take individual events into account, like hearing gunshots, being fired upon, receiving damage etc. Snipers have more advanced AI than normal Guards, which have more advanced AI (or more states) than civilians, which again are more advanced than animals.
The distance where NPCs perceive interesting things is around 30-40 meters under normal conditions, if they have no reason to be particularly alert. If it is dark, raining, or snowing, this range is reduced. There are some rules as to what sounds travel through doors and walls. Some sounds can travel through a closed door, and some very loud sounds can travel through one or in some cases even two walls.
The reason why things like hearing and vision of the NPCs are limited to certain types of objects and certain parameters (distance, for example) is both performance- and gameplay-related. The NPC has to evaluate all input and thus use processor time doing this. This can become quite consuming, so there is a tradeoff between amount of information and reaction time. The more information we feed the NPCs, and the more they have to evaluate, the slower they are to react. Another issue is complexity. The more NPCs can react to, the more complex their behavior gets, and the complexity rises in some semi-exponential fashion, which is why it is so damn hard to simulate human behavior. It takes time to code it all, so there is a simple management issue as well.
The things you have mentioned so far all have to do with situations where the guards' level of alertness is raised, but what exactly happens inside the guards head when he 'cools' down after a while?
In terms of 'cool down' , the only thing that cools guards down, is keeping a low profile. The trick is, as you mention, that often guards will pursue you, with the intent of checking you out. This is never a good idea, since there is a risk of being discovered, if you are in disguise. Guards can only see through disguises if they are really close to you, so it is never a good idea to let them too close to you, unless you have to. The cool down takes a number of seconds, which is both a bit random and is dependent upon how suspicious the guard was in the first place. Out of sight is always the best thing, but the guards do not distinguish between being out of sight because you walked into a room or because you hid behind a tree.
Sometimes, what happens is that guards receive an event, which makes them "interested" which brings them to a sub-state of the Suspicious state. Then the guard decides that whatever caused his interest is not worth his time, whereupon he returns to Normal state, and begins to resume whatever he was doing. In Normal state, he immediately receives the same event again, causing him to become suspicious yet again. It is a derivative of the fact that the AI does not have long-term memory, which is something we are working on. Sometimes NPCs can become confused because you are right behind them (which also prompts an event, which causes them to turn around, if they notice it). But if there is nothing wrong they will resume, and immediately get the "Hitman-is-right-behind-me" event again. Usually when these things happen, it is because of minor bugs in some specialized behavior that we made.

How does 'teamwork' between the NPCs work in Hitman? By this, we mean 'normal' guards working together, but also the squad-based movement like the SWAT teams in the Asylum or Deadly Cargo, who seem to organize themselves differently.
On Contracts, we had something we called the Arbiter. The Arbiter managed the propagation of information and simple coordination issues. For example if a guard had seen a dead body lying around, and he identifies the body as being that of a chef, but nude (i.e. Hitman has taken the "Chef" dress), this information will spread to the other guards. But not immediately. It takes a bit of time for everybody else to know, which is when the player gets the warning that "Guards are now looking for a suspicious looking Chef". It is also the Arbiter that decides when and how to attack Hitman.
When you get the "warning"-message, this means that "everybody" knows that Hitman is running around dressed as chef or whatever. That is, everybody that we deem should have access to this information. Guards that are in secluded areas would still not know. In Beldingford there where three different guard groups. One in the garden, one in the manor and one around the stables. One group could be looking for a chef while the other group would be unaware that the chef was dangerous. Guards have two ways of delivering this information to each other. Either by radio or by word of mouth. If guards have radio-communication, the information propagates faster than if they do not.
For the SWAT team we used a combination of both the 'Arbiter' and some situation-specific scripting. Efforts have been made to make it more consistent in future releases. Guards are now a lot better coordinated as groups, and make more use of the fact that they can flank Hitman, use cover and call for backup. Hitman's life is definitely not going to get easier in Blood money if you take everything head on.
What about the way in which guards reactor to other NPCs? We have come across some weird situations, for example in Hitman 2: Silent Assassin, playing the 'Invitation to a party' mission. This mission involves an undercover Spetznas agent who, oddly enough, is allowed (by the guards) to do whatever he wants. They ignore him even when he is shooting up the entire embassy! It rather spoils the gameplay experience for some.
Do you think it will be possible for the next Hitman games to expand the AI's notion of the world (base-scripts) to an extent where they react realistically not only towards 47, but also towards each other? This would also open up new possibilities in terms of gameplay because you could, for example turn guards against each other, or frame people for murders, etcetera.
Non-player characters use a simplified set of rules. The AI can perceive Hitman doing many different things (sneaking, lock picking, running etc) and as a result, act against Hitman doing these various actions.
Framing, or setting NPCs up, would definitely be a cool feature. I do not see the cpu-time as being the significant problem here, as much as it would require a lot or work, testing and gameplay balancing. But it would definitely be fun to make it possible for players to be able to frame others for your deeds. Our AI scope is ever expanding, and the above scenario is definitely a possibility. We have already made some quite fun additions to the AI, which you as player can exploit.
Basically, we are trying to create a simulated environment, where everybody reacts more or less as human beings. It is quite important for us, that the player feels that NPCs are reacting with something that resembles human behavior. A lot of the gameplay revolves around cheating the NPCs somehow, and we want the players to think, "What can fool a human guard?" and then apply the methods that answer this question in the game. As made obvious by you, this is far from perfect, but we are continually improving the behavior, based on play testing and gamer feedback. If there is a criteria, it is what is needed to create a game that is fun and rewarding to play, and where they player feels a sense of satisfaction, when he outsmarts the AI.

In relation to the previous question, another example of a flaw in the AI that kind of tends to spoil the illusion of the game: In previous games it was always possible for 47 to transport enormous sniper rifles around a crowded community, just as long a he remembers to drop it onto the floor when people are actually around to see him....because, you know, guards will shoot you if you are seen carrying a rifle, but of course they don't seem to mind the same rifle blatantly lying on the floor as they walk by. Is this something you are looking at?
This is not optimal, and it is something we are well aware of. In the future, you will not see guards and civilians ignoring guns and rifles lying around on the ground.
Great! I'd like to hear you comments on something else which we have discussed among some of the fans, which is the fact that creating believable NPCs is not 'just' about coding their AI, and there are other techniques that could be used, for example: the use of dialogue and their appearance, making them more individual.
I completely agree. And I think you will experience a lot of effort being made, towards making everybody look and behave like individuals. But we also have to stick by some consistency rules, it would be quite confusing if guards behaved vastly different from each other. You would never know what to expect, which in my opinion would be a bad thing. However, in terms of flavor and in some instances for purposes of gameplay variety, I am in complete agreement.
When you compare Contracts to Silent Assassin, it is clear that you added many special, scripted events. Adding many cool moments to the game - impersonating people, poisoning, explosions, tampering with the bathwater, disabling the guards satellite TV, we could go on... I did notice that the overall general AI (Base-scripts, as you mentioned) had improved compared to the previous game, but not spectacularly so. Was it a conscious decision to focus on these scripted events rather than enhancing the general AI? Yes. We actually made efforts to rewrite the entire code-base for the AI, but eventually abandoned it again, since it inserted too much instability and risk into an already busy development schedule. So we opted to stick with the old scripting system, but made patches and improvements to it, here and there, to make it fit with our greater scope in Contracts. And as you say, we added more specially scripted events. The Blood money game, however, takes full advantage of our much faster and much better AI system.
What can we expect for the next game, 'Blood Money', in terms of Artificial Intelligence?
I think I touched a bit upon different areas of improvement throughout the interview, and I have actually just scratched the surface. We are aiming for faster reaction times and just plain "better" AI, apart from everything else. And I think we're succeeding in both departments.
This post has been edited by Dogma: 12 October 2005 - 05:36 PM

Help











