Emotion Modeling and Interaction of NPCS in Virtual Simulation and Games

- Virtual simulations and games utilizing NPCs, or computer controlled agents, are more predominant now than ever. Many of these simulations suffer from a lack of effective, stimulating, and natural emotion-based behaviours in the interaction among the NPCs, as well as with the human players. This paper presents an easy-to-use, portable, diverging, and adaptive emotion model based on psychological and sociological research, for simulation and game designers to utilize easily in their virtual world. The proposed emotion model allows the player to better relate, understand and believe in characters in the virtual environment.


INTRODUCTION
Computer games are becoming increasingly popular as an entertainment medium around the world. So what makes a good computer game? The answer to this question is immersion. An immersive experience is produced when the game world is so well crafted that the player will lose themselves in the game experience. One key aspect which is important to consider when creating an immersive experience is the realism of the game's Non-Player-Controlled Character (NPCs), i.e., the virtual agents in the game. Everybody experiences emotion; it is the key foundation of our humanity. Therefore to create realistic NPCs in a game they must realistically imitate emotional qualities. If a character acts without any emotion then that character is not possible to be regarded as a real or believable character in a game experience. If the characters are not real then the game world is not real and the game's immersive experience is ruined.
Even though reasonable agent responses in simulations are acknowledged as important, currently agents are still widely perceived as mechanistic automata. This perception introduces anomalies in the interactions between the human user and the agents. A reasonable rationale or drive for the agent's behaviour is often a missing component in many virtual simulations [6] [8].
In a simulation involving virtual humans, the drive behind an agent's reactions and behaviours should be the same as the drive behind all human actions, interactions, as well as the basis of human personality. That is: emotions [3]. If a simulation can implement reasonable emotional res Manuscript Received on 14 November 2009 E-mail: L.Li@curtin.edu.au ponses to various stimuli, and generate social interactions between agents as well as between agents and the human user, the agents will appear less like mechanistic automata and the human users will be able to associate more with the virtual environment they are interacting with [2].
Many researchers have proposed various emotional models [16], as well as the coping strategies for emotions [1]. Some researchers believe that emotions should be modeled with multi-dimentional logic [7]. However, in most of the virtual simulations, emotional drive is rarely implemented to the degree which comes close to being reasonable. The main reason is that programming true human responses into an application is too expensive, too time consuming, and would require a level of psychological understanding that most designers lack [4]. As a result, simulations are often designed with a simple 'bare-bones' approach to agent behaviours. In "bare-bones" approaches, every agent maintains a simple variable containing the agent's opinion of the human user. The human user's behaviour modifies this variable across all agents in the simulation, even if the agent has never had any direct or indirect contact with the human user. This kind of approach prevents reasonable emotional relations between the human user and the simulated agents, rather than developing it.
The aim of this research is to design an emotion model and implement it into a game environment. The model developed should be able to generate appropriate emotion and emotional reaction in relation to the behavior of a player. The rest of the paper is organized as follows. Section 2 provides a detailed description on the design and structure of the proposed emotion model. Section 3 describes the implementation of the emotion model into a game engine. Section 4 concludes the paper and provides suggestions for future research.

II. THE EMOTION MODEL
The emotion model imitates emotions in non-player characters in a game environment. This is achieved by giving every character emotional states and changing them based on what happens to them in the virtual environment, and their perception of those events.

Overview
The model developed in this project consists of a series of interconnected functions arranged in a layered structure. Each of the components controls an aspect of the behaviours of the NPCs and their interaction among themselves and with

Emotion Modeling and Interaction of NPCS in Virtual Simulation and Games
Ling Li and James Campbell Department of Computing, Curtin University, Perth, Western Australia 6845 the player, based on their emotional states and reactions. The components in the model dictate NPCs' behaviour from as low as their base personality (Emotional State layer) to as high as the NPC-to-NPC and NPC-to-Player social interaction (Interaction layer).
All layers in the Emotion model share and generate information that is utilized by other layers in the model. A feedback loop is generated as part of the core processes into the NPC's emotional evolution. This feedback loop is produced when the model generates emotions based on environmental stimuli. The generated emotional change filters though the model and in turn will influence the environment. A feedback loop is one of the most critical components of any system which is designed to evolve over time.
People are always experiencing some type of emotion. Emotions are very complex and come in infinite different forms. This is because an emotion exists within a range. There are an infinite number of emotion levels which can exist between happiness and sadness just like there are infinite different numbers between 0 and 1.
Emotion cannot be realistically imitated through implementation of one range of emotion ranging from negative to positive. A person's emotional state is not a one dimensional process. Emotions come in many different forms, such as anger, fear, companionship, happiness etc. Therefore a person's emotional state is a multidimensional process. All the different emotional factors need to be taken into account when calculating a person's emotional state.
To attempt to simulate emotion in non player game characters four independent levels of emotion are used. This gives the non-player character (NPC) a four dimensional emotional state. Each emotion attribute tries to reflect one of the primal emotional urges of anger, love, fear or happiness. Due to the fact that emotions exist in a range, each emotional level is stored in a floating point number which ranges from -1 to 1. The two ends of the emotion level oppose each other and represent the two extremes of the emotion.
Feelings are manifested in us through our emotion levels. To replicate the effect emotions have on us each emotional level is associated with a particular feeling. Each feeling is associated with a color in Fig. 1 to indicate the strength of the underlying emotion.

Emotional State
The anger level is used to simulate the primal emotion of anger. Anger creates feelings of irritation towards something. The absence of anger creates feelings of calmness. These feelings oppose each other as both cannot exist within an individual at the same time. Each level of the emotion creates a feeling within the NPC. This is shown in Fig. 1(a).
The fear level shows the primal emotion of fear. Fear creates feelings of apprehension towards something. A lack of fear creates feelings confidence and bravery. The range of the feelings created from a NPC's fear level is shown in Fig.  1(b).
The relation level imitates the emotion of love. Love leads to feelings of fondness towards something. A lack of the emotion love leads to feelings of hate. The range of feelings created from a NPC's relation level is shown in Fig. 1(c).
The happiness level simulates the emotion of happiness. Happiness leads to feelings of being happy. A lack of happiness leads to feelings of sadness. The range of feelings created from a NPC's happiness level is shown in Fig. 1(d).
Together the four independent levels of emotion try to cover the full spectrum of emotion, as shown in Fig. 2.

Emotional Change
People's emotional states vary based upon two things: what happens to them and their perception of that event.
There are four different types of events which can take place in the implemented virtual environment. The player can choose to either charm, intimidate, befriend or impress an NPC. Each event has three different levels of intensity. An increase in the intensity of the event will cause an increase in the emotional response. Each event creates different emotional responses.
How a NPC responds to an event is based upon his or her perception of the event. To replicate this, each NPC was given certain likes and dislikes. These likes and dislikes determine the NPC's emotional response to an event. The emotional response to an event is also determined by another aspect of his or her personality: emotional tendencies.
Everyone is different in the way they respond emotionally. Some people are stable and very little affects their emotional states, while others have huge swings between emotions. Some people are easily angered while others will have a calmer reaction. To simulate this each NPC is assigned anger, fear, relation, and happiness tendencies which determine how they respond to certain emotional stimuli. The combination of event stimuli with the character's personality and emotional tendencies is shown in Fig. 3.

Emotional Behaviour
The emotion model imitates the behavior which occurs as a result of an emotional state. The NPC indicate their emotional states through their different behaviors: through their current facial expression, and through the way they interact with the others.

Facial expressions
Each character is assigned a facial expression based upon their current emotional state. This is done by finding the strongest emotion and choosing the display picture which reflects that mood for display in the graphical user interface (GUI). This is achieved by looking at the both the type and the intensity of the emotion which is found to be the strongest emotion in the character. The type of emotion determines what range of display pictures to use. The intensity of the emotion determines which display picture to use within the range.
If the strongest emotion is anger or hate then the anger range of display pictures is used. An example of the display picture range is shown in Fig. 4. If the strongest emotion is relation or happiness then the happy range of display pictures is used. An example of the display picture range is shown in Fig. 5. If the strongest emotion is fear or sadness then the unhappy range of display pictures is used. . An example of the display picture range is shown in Fig. 6. If the strongest emotion is calmness or confidence then the default base image is used as the display picture as under these conditions the NPC does not show their emotions on their facial expression.

Interactions with Player
When a player initiates a conversation with a NPC, the NPC responds with a greeting. This greeting is based upon their current strongest emotional state. If the NPC feels most strongly anger towards the player then the player will receive an abrasive greeting. If the NPC strongly feels companionship towards the player then the player will receive a warm greeting.
The way a NPC responds to a query is also dependant on his or her current emotional state. For example if the player asks a character for their secret, the response is based upon their current emotional level. To get the secret the player must alter the NPC's emotional levels so that the NPC either is too afraid to deny the request, likes the player enough to offer the secret, or is in such a good mood the NPC feels like being generous.

Emotion Interaction
Emotions towards a person are not just affected through direct interaction with that person. An immense amount of emotion comes from indirect sources such as the opinion of others and the information that is given to us. This is achieved through communication of events and feelings. To replicate this NPCs are given the ability to interact and have conversations about their feelings with each other. When a NPC spots another NPC he or she will stop and greet them with a wave. The other NPC will then notice the greeting, stop, and wave back. Both NPCs will then proceed to have a conversation. While this is occurring the player will not be able to speak to the NPC as he or she is busy in conversation. The way one NPC feels towards the player will affect the way the other NPC feels about the player. This is achieved by trans-ferring a small percentage of the NPC's strongest emotion towards the player to the other NPC.

III. IMPLEMENTATION AND RESULTS
For this project the emotional model was implemented into the torque game engine. This was done by writing torque script which is executed by the torque game engine. The torque game engine functions with two distinct areas of operation: the server and the client. The server is responsible for handling information, while the client is responsible for user inputs and display of information. To implement the emotional model effectively, server code needed to be written to handle the emotional responses generated through interactions with the player. The server was also responsible for the handling of the NPC's interactions with each other, and the emotion level update generated through this interaction. The server was also responsible for the spawning of the NPCs. The client was given the responsibility of retrieving and displaying information to the player during interactions with a NPC.
For this project the emotional model was implemented into the torque game engine. This was done by writing torque script which is executed by the torque game engine. The torque game engine functions with two distinct areas of operation: the server and the client. The server is responsible for handling information, while the client is responsible for user inputs and display of information. To implement the emotional model effectively, server code needed to be written to handle the emotional responses generated through interactions with the player. The server was also responsible for the handling of the NPC's interactions with each other, and the emotion level update  generated through this interaction. The server was also responsible for the spawning of the NPCs. The client was given the responsibility of retrieving and displaying information to the player during interactions with a NPC.
To initiate a conversation with an NPC the player must approach the NPC. The NPC will then stop what he or she is Once the player has initiated a conversation with an NPC then the player can choose to say something to the NPC from the list of queries given. Once a query is chosen to say to a NPC then the NPC will respond with a statement and possibly a sound file as well. The NPC's emotional state will change as a result of the interaction. The graphical user interface, named Talk, has six different areas where information is displayed to the player, as shown in Figure 8. Each area has a vital role in creating an easy to use and understand user interface. The six areas are: NPC Name: The NPC's name is displayed to the player in the top-center of the GUI. This way the player knows immediately who he or she is talking to; Profile Button: A the top left corner of the GUI is a profile button. This causes a new window to pop up with information that is known about the NPC. This gives the player a insight into possible likes and dislikes the NPC might have; Emotion Bars: There are four emotion bars spaced evenly under the NPC's name. Each bar is for an emotion attribute of the NPC. Every bar is filled based upon the current level of emotion the NPC is expe NPC Response: Under the emotion bar is the text describing the NPC's greeting to the player or the NPC's response to a player's query; Display Picture: On the bottom-left is the NPC's dis To initiate a conversation with an NPC the player must ap-proach the NPC. The NPC will then stop what he or she is doing and turn around to look at the player. A GUI window will then pop up on the player's screen with a greeting from the NPC and a list of types of things for the player to say to the NPC, as shown in Fig. 7.
play picture. The display picture is dynamically chosen based on the NPC's current emotional state; Query Options: On the bottom-center is the list of queries the player the player can make to the NPC.  CONCLUSIONS AND FUTURE WORK The objective of this project is to design and implement an emotion model into a game environment, so to create non-player characters which would seem more real to the player. If a character does not act with emotion then the game world is no longer feasible as a real place and the immersive experience is ruined, since emotion is the foundation of our humanity. If a character does not act with emotion then the character is not a realistic representation of a real person. The implementation of an emotional model into the torque game engine has given non-player character emotional qualities. Giving characters emotional qualities has made them more feasible and allowed the player to better relate, understand and believe in characters in the game environment. This has helped to create a more immersive and dynamic gaming experience for the player. Future work include more research into more complex emotions and better integration of them into the game engine so that more complex social interaction and behaviours can be generated.