Mindflock.com
Social Game Artificial Intelligence
Social Game Artificial Intelligence
Sep 8th
If you ask anyone with a passing interest in AI and more specifically in AI in games what is the most important aspect, you will probably be answered with something relating to logic. Logic and decision making seems like the most important aspect because it drives behaviour after all.
But in this post, I want to put the case that actually logic is really not a problem for games.
Of course, we rely on some system of decision making to exist, but what specific flavour it is doesn’t much matter. A good number of games have been created using simple finite state machines, although these days you would expect those to be heirarchical. A lot of more action oriented games use Behaviour Trees, which is the system we have implemented for StoryBricks and you can learn more about them here. Other approaches use goal based systems such as Goal Oriented Action Planning and Heirarchical Task Networks.
But no matter what structural system you choose to represent the problem, it essentially boils down to a simple statement:
if <condition> then <action>
Of course, the number of conditions and actions available can be very high and the conditional tests and the execution of actions can be quite complex. But we have this fundamental architecture of the above statement.
Ultimately, the structure we choose doesn’t matter, we are simply executing a program which controls flow of control. With more or less efficiency and ease of authoring.
So if we accept (any not everyone reading this will, granted) that action selection is not the core problem, then what is?
My assertion is that what is key AI especially for “believable agents” work like StoryBricks is animation and movement.
Imagine, if you will, the following scenario. You are walking across a field and come across another fellow. He is looking intently at the ground. He does nothing except look at the ground. So the question is, what is he thinking? Why is he looking at the ground? Is it:
Which of those statements is true? Unfortunately given so little context, you simply cannot know why he is looking at the ground.
What if I said “he is the queens geologist and has been tasked with finding gold for a new crown”, would that allow you to choose from the list?
What if I said “he is your sworn enemy and has no means of defending himself”?
The point is, that without context, it is impossible to understand the intent of the action. For all the complexity we could put into the <condition> part of a if <condition> then <action> statement, we have to be able to understand the <action> part in context in order to understand the <condition> part.
Thinking about traditional media
Now if you think about cause and effect in other media like books and film, it is pretty easy to understand the cause, because it can be explicitly expressed. Consider the following narrative:
“The gunfighter put the empty whisky glass down on the bar and stepped out of the saloon. He walked down the creaky wooden steps and out onto the hard dirt. Dust kicked up with each step as he walked, his spurs chiming on the ground with each footfall. When he got within pistol range of his opponent he stopped. For long minutes he stood silent and still, his only movement a slow flex of his hand above the gun in its holster. A bead of sweat drifted down the side of his face, he was at a disadvantage he knew, because the sun was in his face. But the wide brim of his hat sheltered his face from the harsh blinding rays of the noon day sun. He waited and watched, coiled like a spring, a deadly serpent ready to pounce at the slightest movement”.
(apologies for any real authors btw).
So, given that narrative, you can picture a scene. You understand there is a gunfighter and he has an opponent. You can start to evoke a sense of the scene and what it might be like using your own knowledge of that context, which has been learnt over time from other examples of this behaviour. What you can’t get from this narrative is exactly why he is having this gunfight.
If we continue:
“He had thought of this moment for a long time. His had played the scene out many times in his mind, ever since he had heard about how his wife and children had been brutally murdered. He had spent many years tracking the band of outlaws that were involved in the killing. One by one he had silenced them, with only this last foe remaining. It wasn’t “justice” he was seeking, even though he wore a badge that legitemised his handiwork. This was pure sweet revenge, the brutal slaying of his innocents met with equally brutal punishment.”
Adding that context to the narrative makes you understand the motives behind the actions. It is one of the most powerful aspects of books, in that it can go into great detail and really involve the reader in understanding the psychology of the actions.
Films have a different vocabulary, with a more visual way of telling the same tale. Consider this set of storyboards:
The placement of camera, use of lighting to set the mood, adding music and all the many different aspects that cinematography bring to the table to express the same notional scene still allow the same story to be told.
Now consider this scene in a game. By this I mean in an actual interactive scene, not in a cutscene. Hard to imagine isn’t it? When the player can look anywhere, you can’t rely on them seeing anything. If you place the player as the protagonist, you will most likely have a hail of gunfire within a few seconds. If you place them as a bystander watching the scene, the player will most likely stand in front of the protagonist or just generally “get in the way” of the scene.
The fundamental problem, is that scenes like this are really evocative in the traditional linear narrative media like books or film, but fail entirely in games unless they are controlled as they are in cutscenes. Interactivity simply breaks down too many notions that are evoked in scenes like this.
The language of interactivity
So if we accept that some forms of dramatic content are simply not useful for interactive storytelling, what do we put in its place? That is where StoryBricks comes in. The conceptual issue that StoryBricks addresses is the interactivity relationships between NPC’s, players and objects.
In the interactive medium, you are not simply watching a narrative unfold, you are the narrative. Your actions and interactions are the fundamental control scheme for the narrative of the world as you experience it.
Consider this. If you were the lawman/gunfighter from the scene above and had been going around the land taking part in pistol duels with the people who killed your family, what would it look like to an observer who was casually watching your actions? What if you actually roleplayed the gunfighter? Would the observer understand the narrative of the world as it unfolded and what kind of experience would they have had?
Going back to the case of the man looking at the ground for a moment. What I am saying is that there is an issue with the players understanding of the intention of the actions of an agent. So my suggestion is that the important part of game AI, especially for believability, is that. The understanding of the intent is the key, not the actual formulation of the intent.
Let me give you an anecdotal example. In this video Wil Wright talks about one bug they had in “The Sims” where NPC’s would randomly set on fire. The players of the game made up different explainations about why it was happening. Was it spontaneous combustion? Was it something they had done?
We joke in the game AI community that the best initial approach is a random one. But this is actually true, in that we can often convince players that actions have considerably more behind them than is actually the case.
I once saw a fantastic presentation by Baylor Wetzel that highlighted this issue. He took a number of different algorithms for choosing patterns of attack behaviour in a wizard duelling prototype he had written and asked his students to identify them. It turned out that we are actually pretty poor at judging the cause of actions when any reasonably complex pattern is used. In this case, random is almost as good as complex pattern because if the pattern is complex enough, players will have trouble discening the pattern to the point where is essentially *is* random to them.
So when we are trying to make players understand the actions we give our NPC’s, we have to be doubly sure that they are capable of understanding the motivations for them.
How do players understand characters?
The player’s reading of any given action is coloured by many things. One of the strongest being the actual visual look of the NPC. We had a team at the University do some work a few years ago where they looked at the interactions between a group of test players with a number of differently designed NPC’s. The theory was that empathy could be induced by character design and behaviour. It turns out that a large part of the empathy players had for characters was based on their appearance.
In traditional animation, this is actually formalized as a concept called “appeal”. The psychology of this is quite well understood. Most appealing characters have open faces with large eyes and round heads. Often animation will use childish or “cute” proportions. But aspects such as clothing,posture and gender will also contribute to the appeal.
The second most obvious and important factor is movement. When I say movement, I am talking about things such as posture, gaze, gesture etc. The fact is, we communicate a vast amount of our character non verbally. We communicate with our facial expressions, with our gestures, our gaze and our posture far more than we communicate with actual words.
The psychologist Albert Mehrabian suggested that we communicate a huge amount of our emotional intent non verbally. He spoke of a 7%-38%-55% split between verbal, vocal and visual language respectively. The suggestion being that we use more than just words to understand the true intent of an interaction. Which is confusing, given that most games rely on textual or verbal dialogue to communicate intent.
Think about RPG’s and how dialogue heavy they are. Think also about how often you simply click away these dialogue items. Simply “hoovering” the options to set some flag for later progress.
If we accept the notion that players understand characters intention through movement, then how can we improve the players understanding of the man looking at the ground?
Let’s consider each case in turn:
He is interested in the composition of the ground
This one is relatively easy. You could have him walk around, looking at different areas of ground. Occasionally stooping to pick up a sample of dirt. You can use a prop that he brings out to look more closely at a sample. You could have him lift up stones on the floor and look under them. You could have him holding a book and comparing the sample to a page in the book.
He is afraid of you and is looking at the ground to avoid your gaze
Again, this one is relatively easy. You would have him use occasional glances up at you and quickly back down again if you are looking in his direction. You could alter his posture to be more wary and frightened. Perhaps supplicating himself with gestures and hand wringing. He would seek to avoid eye contact, but would definitely look up often to make sure you weren’t about to attack.
He is somehow compelled to look at the ground
This is the easiest one of all. You would fix the bug that made him look at the ground.
Conclusion
There is a great deal we don’t know about this whole conceptual area of interactive storytelling and drama. We intuitively feel that traditional media approaches to narrative break down fairly quickly, but as yet we haven’t built up a good enough knowledge of the principles we need to apply to the new medium of interactivity. We can definitely learn a lot from psychology and the principles involved in other media, like film, books and animations. But there is still a lot to explore.
StoryBricks as a concept, is a step towards exploring this new space. Of course the bricks themselves are just a small part of that space. We must investigate new methods of understanding the animation, behaviour and psychology of interaction.
Hopefully some of you reading this will come along with us as we explore this space together. As we develop the toolset, we will learn a lot about our understanding of characters, our ability to create performances that are comprehensible to others and perhaps as importantly we will learn how to create deeper and more meaningful experiences because of what we learn.
Aug 6th
While most of the guys at Namaste are reasonably highbrow (well, ok, I’m talking mainly about Stephane and Brian, who are both pen and paper roleplay geeks) I’m actually a bit of a low brow kind of guy. I’m not quite at the level of enjoying fart jokes, but I do enjoy a bit of comedy and deviant behaviour.
So I wanted to explore with this post, some issues I’ve been wrangling with myself about. Namely, how do we use the storybricks toolset we are working on, to create characters rich enough to be funny? Or to be interestingly flawed and/or deviant?
I started thinking about characters that were both funny and broken. One of the characters that popped into my mind was Talkie Toaster from the brit comedy Red Dwarf. Here’s a clip.
As you can see, he’s a chirpy breakfast companion that is delightfully broken and just a little bit hot bread product obsessed.
There’s something inherently interesting about a character with an obsession for something, but even more so for a character obsessed with something other people wouldn’t be. But how do we go about designing a system that a) actually allows a character like that to function and b) lets the user of the storybricks easily express that type of character?
Making obsessive characters
The (a) part is actually reasonably simple. We employ drives to give characters a purpose. Drives can be things like “do your job” or “protect character x” or “aquire x number of resource units of y”. Drives fight with each other for importance during action selection, which means that we compute how intense the drive is for each occurence and choose the highest value as the priority to pursue. Of course these drives change over time and as events occur, so that characters can react to the world and other characters. But fundamentally we are modelling the self-interest motivation that occurs in human behaviour. Of course there are many different drives, so for instance much like in the sims we might have drives to achieve normal bodily function, like eating, sleeping and going to the bathroom. But it is the more complex drives, like the need to attain social status, or the need to protect another character from harm, that allow for richer meanings to occur.
Getting back to the method of making drives work for this pupose, we can simply make the drive artificially high, indicating an obsession. This would simply select something that would occur naturally, but select it more often and with greater vehemence to keep moving towards achieving the resolution to that particular drive. This brings up an important part of the answer, which is that there is a notion of “expected reward” for fulfilling a drive. All this means is that when you choose to do something, you choose to do it with some future expectation of the gratification involved in that fulfillment. So for instance, I might take on a particularly arduous and complex task, with the expectation that the end result will be gratifying.
One of the interesting things about humans, is that we tend to function not simply from pure logic, but from logic that is altered with emotional experience before we make decisions. This means that instead of simply selecting an action via some logical step, we apply some emotional processing to the selection such that the emotion helps us choose. This is needed, because some choices are unknown and we need a method to still make a choice, so emotion gives us a push in a particular direction. But perhaps more importantly, emotions give us some warning that choices are actually not good for us. A classic example is told by Antonio Damasio in the book “Descartes Error” where he recounts the tale of Phineas Gage. Gage was a rail worker in the US who was helping build a railroad and one day had an accident that damaged his brain. The area of brain damage did not effect his logical function, memory or reason. But it did damage his emotional processing. What happened after the accident is a sad tale, but essentially it ended up that Gage was no longer able to apply emotion to his decision making and as such made poorer and poorer choices for his actions because he had no way to “feel” about the correctness of the choice and its consequences. He couldnt tell when a deal he was entering into was a good one. He had no feeling for the mood of other people or when he was being used.
I point this out, because it is important to understand how emotion colours action. Just as we have drives for our basic needs, we have drives for our pschological ones too. I’m not sure about the definition of clinical obsession, but it seems reasonable that we can express obsession within the system by applying both a hightened drive for the item being obsessed about, plus a more intense emotional reward for the attainment, interaction, or ownership of that obsessive item. Basically, we model in a simplistic way, the human behaviour of obsession.
How do you author obsession?
So getting to point (b) earlier. How do we create storybricks that allow us that level of control?
My first thought, is that we have modifiers on “wants” bricks. So instead of “x wants y” we might have “x wants y *how*” with the *how* being something like “obsessively”. The same could apply to “x likes y” and similar bricks too. Obsessive relationships that are one sided tend to be quite dramatic after all.
But I’m not entirely sure that’s how people express notions such as obsession when they think of authoring. “Jane is obsessed with reading the Harry Potter books” is a simple statement, but how would we express this in terms of bricks? Is she obsessed with reading, or is she obsessed with Harry Potter, or books, or only reading Harry Potter books? Clearly the latter is the intent of the statement. So the brick might be something like “jane wants to” whereis an action she can perform andmodifies the drive of that action.
So it suggests that actions are actually compound. “Read” might be an action, but it only makes sense when applied to one or more books. So maybe the “Read” action part of the “Wants to” brick has a compound that gives the things she wants to read. But also allows for the action to be modified.
There are a lot of things we need to figure out in this way. Both from an execution perspective, so that we can enable the characters to perform the action, but also at an author level, to allow the authors of the story to actually direct it in a way that makes sense. I’m sure that part of our ongoing feedback loop will help us refine the latter, which should help us improve on the former.
So what other types of characters would you find interesting? I’d love to hear the kinds of characters you find interesting so that we can start to form the tools to help build those characters.
Eric Heimberg did a great post about the state of the art for NPC’s that can get us started. But it would be great to hear about more characters you would find interesting. Also, how do you describe those characters and how do you think you would want to describe them in terms of bricks?
Comments welcome as always.