Post-Play'em - Observations on Game AI

Posts Tagged ‘Skyrim’

Skyrim: Points of Interest

Wednesday, January 25th, 2012

Another minor observation. I was hanging out in a small town and, for some reason, there was a Frostbite Spider corpse in the middle of the road. I don’t know why it was there since I wasn’t the one that killed it. However, what I did notice was that various villagers walked up to it while making eye contact (head contact at least) with it, stopped to look at it for a moment, and then moved on. A guard even knelt down and touched it.

This is such a huge point of immersion in games. That is, people noticing things that are out of the ordinary whether those things are objects that shouldn’t be someplace or events that are unexpected. Certainly, we can’t afford the processing power for people to suggest that a chair would be better off in the other corner of the room, but having a large venomous spider corpse the the middle of the road (or even in town at all) is certainly worthy of note.

Sure, we have done this with the monsters when they are alive. (Although there are plenty of examples where NPCs don’t notice this as well.) However, often people ignore things after they are dead. Even the agents that kill things will often simply state change to walk away from something as if it never existed in the first place. This, on the other hand, is very different. To me knowledge, these people didn’t even see the spider get killed. They simply noticed the corpse as an object that was worthy of note.

Well done!

Skyrim AI Weapon Selection

Saturday, January 14th, 2012

Say what you want about Lydia and her lack of pathfinding prowess, she does do some things right. The problem is (as is the case with all good AI), unless you are looking for it, you might not notice.

Early on in my relationship with her, I had noticed that she would switch between her bow and a sword. Later on, as is part of her duty (which she will remind you of in her sarcastic, resigned drawl), I had given her a bunch of stuff to carry for me. That included a few different weapons and 3 different magical staves with varying abilities.  During a combat, I noticed that she was using a paralysis staff to disable a mage we were fighting. After knocking his ass to the ground in such fashion, she joined me in whacking him into oblivion (not to be confused with “into Oblivion”).

I’ve seen her in other situations use the paralysis staff, switch to using two other more offensive damage staffs, and then pull out an axe in place of one of the staffs… all as the situation warrants and all in the same combat sequence. This is something I’ve  been looking for in games for quite some time.

I haven’t been able to completely discern whether she is using a specific rule-based system or if there is some sort of underlying utility model at work. I would tend to say that it would be at least a portion of the later. That is a model that is far more expandable which is necessary when you include the number of potential weapons (and other objects, I’m sure) and potential factors to consider. If I notice more, I will mention it.

Skyrim: It’s a Free-for-All!

Sunday, January 1st, 2012

Just had a battle out on the plains west of Whiterun. It was bad enough that I got jumped by a dragon. Then, the dragon flew a ways away and started chillin’ a nearby mammoth. Lydia and I continued to take potshots at Mr. Dragon (Mrs. Dragon?) while the mammoth ineffectually stared down its assailant. Eventually, the mammoth started running (right past me and Lydia!) and the dragon seemed to give up on it.

Unfortunately, I soon realized that there were a couple of mages wandering around the area who, for some reason, apparently decided that Lydia and I were far more menacing than the circling beast. And then there was the skeleton — who may or may not have been the product of the mages who started attacking me. By the time I dispatched the skeleton, the dragon had gotten bored with whatever it was he (she?) was fighting nearby and came back to visit. This all came to a rather unfortunate end… but that’s not what I came to tell you…

“There seems to be a serious lack of proper prioritization of targets.”

The point of all of this is that there seems to be a serious lack of proper prioritization of targets. For example, despite the fact that a mammoth might look awful tasty to a dragon, said morsel is not going to be able to attack you. Better to dispatch the pair of annoyances that are pumping arrows into you and come back for the hairy buffet later.

The same can be said for the mages. If there is a dragon cruising around, it seems rather silly to attack two relatively harmless bipeds. In fact, the chances of defeating the dragon (and therefore surviving) would go up considerably if it was attacked by a group rather than by a couple of individuals. An additional bonus would be that the dragon might take such a toll on your secondary opponents that it leaves you an advantage you might not otherwise have.

Obviously the target selection algorithm doesn’t take a lot of this into account. It’s really a matter of mathematical modeling. Ironically, it is the same sort of modeling that goes into non-combat games such as The Sims. The good news is that it is relatively simple to put together and can adapt to pretty much any situation that your NPCs find themselves in. It can also be  tied into the entire combat selection system so that the possible actions could include not attacking anyone at all (even running away, if necessary).

For those that are curious as to how such utility-based systems can be built, it is pretty much the entire point of my book, Behavioral Mathematics for Game AI.

Skyrim: Pardon the Interruption

Saturday, December 31st, 2011

This is a quick one. I have seen this numerous times in my few hours of playing, but I haven’t captured as many of them on video as I would like.

“They neglect to take any sort of context into account.”

People in Skyrim obviously have a proximity trigger with your character. If they have something to say, they will say it either when you get in range of them or vice versa. While this makes for some great immersion at times, they neglect to take any sort of context into account. They don’t observe what is going on and decide whether or not they should talk to you.

I don’t recall anyone doing it while I was in an active dialog tree, but there are certainly times when I am listening to something important — and especially if I am obviously part of a group discussion (such as in the two examples in the video). People doing their random walks will pass close enough to me to trip their trigger (so to speak) and say their piece. It’s horribly distracting.

“Real people have an awareness of unwritten social rules.”

The reason that this breaks immersion is that (real) people have an awareness of unwritten social rules. This is notoriously hard to get right in games. Richard Evans has been working on it for years — most notably with his work in The Sims 3. However, we aren’t solving for behaviors such as “don’t walk in on someone where they are taking a leak.” We are simply saying, “if I’m involved in something important, don’t interrupt me.”

If it is, indeed, the case that there is a boolean to not interrupt when a dialog is active, this is a simple fix. Apply the same boolean flag to when something important is going on that the player must listen to. In the case of the street preacher in Whiterun, this isn’t as big of a deal. By definition of his role, he is going to repeat himself. However, in the cases shown in the video, this is a one-time thing with important information… don’t play your random engagements.

“If I’m not
looking at you,
don’t speak to me.”

Another way of solving this is through a slightly more complicated method of simulating “eye contact”. That is, if I’m not looking at you, don’t speak to me. Let’s face it… that’s a common one that we all use in public anyway. In the case of the examples in the video, the 2nd one would have fallen into this category. The guard just happened to be walking by — behind me — and decided based on proximity to say his line. In the first video, at least I looked at the guy.

In effect, many of these rules can be combined together in some form of rule-based system… even an additive one using cumulative values. By assigning values to the various considerations (including a value on the importance of the message itself) you can define a threshold above which you are allowed to say the line. That solution would be much less brittle than the simplistic one that is being used here, and yet it is still lightweight and easily customizable by designers and programmers.

Skyrim: To Headlook or not to Headlook?

Friday, December 30th, 2011

While playing my initial few hours of Skyrim this week, I’ve noticed an interesting disparity in the way headlook is used by characters. While I enjoy headlook in games for the most part, there are times when it can either be overused (“why is everyone in town staring at me all the time?”) or used in such a way that it looks unnatural to the character. Here’s a video with a few examples. Watch it first because the commentary addresses the scenes within.


Look at Me When I’m Petting You!

First, the dog in Riverwood doesn’t seem to care that I’m there. With nothing else going on in the middle of the night, you would think that he would at least be interested in me. Instead, he just sits there staring at nothing. While that is perfectly acceptable for a dog to do (ours do it rather often), the problem arose when I actually “talked” to the dog. He barked in reponse — but wasn’t looking at me at all when he did so. He looked around randomly — but not towards me.

If you are going to make it so that the dog responds to being addressed, at least make him stand up and face you or turn his head to see you (if possible). You do this with enough other agents in the world, it shouldn’t have been hard to include a line or two of code to do it with the dog. (I have yet to test this with other animals in the world.)

Look at Me When You’re Talking To Me!

When I entered some tavern or other in Whiterun, I was immediately spoken to by the owner of the place. She was standing behind the counter. However, I noticed that she was not looking at me — just staring straight ahead. Ironically, she only looked at me when the server lady spoke to me (and mentioned her name). Then, she wouldn’t stop looking at me at all. One thing I forgot to test was to see if it was proximity based. That is, if I went father across the room, would she have stopped looking at me. All in all, with that sort of incessant tracking, I feel like I’m being targeted by and anti-aircraft gun. At least with the bar there, she had a reason to continue facing that one directly.

Move More than Your Head

Now to this clown Heimskr in Whiterun. As seems to be his job, he runs his mouth out in the town square. When I walked up to him, he started tracking me. (Grateful to have an audience, I suppose.) While it looked OK at first, at one point he raised his hands up… right between my face and his. He was still trying to look at me, but his hands were in the way. As I moved back and forth (after stopping to grab some lavender), he kept his body facing forwards and his hands raised — but his head kept tracking me.

It looked horribly unnatural to have his body pinned to one orientation — especially in a gesture that is meant to be for the audience’s benefit — and yet still move his head so much. Unlike the bartender above, he has nothing holding him to that orientation. I would like to see some pivot to the body as he addresses me that way.

Face Me Once in a While

This one is a little rough. While I commend games for not always having the agent face directly at you, my qualifier is constantly. Sure, orient your body differently as you move around! However, you aren’t being clever (or realistic) if you position your body so that it is facing away for some reason, point your head toward the player, and then leave it that way! In the video you will see 3 clips of people who happened to not be facing me directly when I started speaking to them. They didn’t orient towards me at all when they started speaking to me and didn’t fidget at all during the conversation. The result looked rather uncomfortable.

Not shown in the 3rd clip is that the speaker did reorient himself after we were jostled by someone walking rudely between us (more on that subject later). I thought that was interesting in that it triggered some sort of alignment code in the agent. Therefore, it seems that some such code exists, but just wasn’t being used.

How to Fix it

This really isn’t that difficult to fix. Not only would it look less uncomfortable, but it can be leveraged to make for far more engaging characters. All that needs be done is the following:

  1. If the player moves outside of a particular front-facing zone, pivot the body as well as the head. You don’t need to pivot to face him completely, only enough to get the head into a more natural range. For example, if the zone is 60° on either side of center and the player moves out of it, pivot so that the player is now 30° off-center instead. Try it on yourself and see how natural that feels.
  2. As you are talking to the player, reorient yourself once in a while through various shuffling animations. Again, make it so that your body is always somewhere between +/- 30° off of the centerline to the player.
  3. Don’t always stare at the player. People don’t do this in conversation. Randomize headlook more. Look around occasionally — even while you are talking but then glance back at the player directly. The points where you glance back at the player can actually be marked up with the facial animation so that you glance at the same time as important points you are trying to make. Otherwise, look around either randomly (and not all in the horizontal plane, either… up and down are OK, too!) or at other points of interest in the room. For example, people walking by, the performer in the tavern, windows and doors in the room, etc.

Anyway, these are just minor things that have jumped out at me in my initial few hours with the game. While not really bugs, certainly, the headlook issue breaks immersion for many people if it is not done naturally.

There are far more annoying things I have seen that will be addressed later.