Fuzzy Logic for Crowd Behavioural Simulation in Computer Graphics Christos G. Parliaros* National Centre for Computer Animation Bournemouth University
Abstract This paper describes the need of crowd in order to serve the story and how crowd simulation can be the answer. Psychology studies the human behaviour inside the crowd since 1895 (Le Bon). According to Musse and Thlmann (2001), there are three main categories of information that characterize the crowds: knowledge, beliefs and intentions. It can be seen how these information can be translated to numbers and be useful for a computer to analyze and manipulate them. Fuzzy logic has a key role in crowd simulation. Keywords: crowd simulation, fuzzy logic, human behaviour models
1 Introduction From King Vidor's silent masterpiece The Crowd (1928) to The Lord of the Rings trilogy (2001-2003) it can be acknowledged how essential and crucial the role of crowd in order to serve the story can be. The resources it once took to include crowd scenes in film have shifted from people to data, from matter to digital information. As computer generated crowds are becoming common in films, computer games and other virtual world applications and simulations, the production of realistic virtual crowds, in terms of rendering and behaviour is becoming a continuous challenge for special effects. (Thalmann, Hery, Ono, Sutton, Lippman and Regelous 2004). As these applications continue to strive towards higher levels of realism and scene complexity, there is an increasing need for realistic and believable crowd simulations. This paper will focus on the behavioural simulation of a mass and the components that can affect it. Although collective behaviour has been studied since as early as 19th century (LeBon 1895), attempts to simulate it by computer models are quite recent, with the most of the works done only in the mid and late nineties. * i9089303@bournemuth.ac.uk
In past years researchers from a broad range of fields such as architecture, computer graphics, physics, robotics, safety science, training systems and sociology have created simulations involving collections of individuals in small and large groups (Thalmann and Musse 2007). A range of different approaches have been used for the creation of virtual crowds as particle systems with flocking techniques using attraction and repulsion forces, copying and pasting techniques, agent-based methods (Thalmann et al. 2004). This paper's main purpose is the exploration of multi-agent systems (MAS) that possess the ability to generate thousands or millions of agents (simulated characters) that are all act as individual members of a group which can share goals. The implementation of fuzzy logic to multi-agent systems can address a personality both to individual agent and the group itself (Ă–ren and Aghaee 2007). What can be successfully achieved with the use of fuzzy logic is the modeling of a brain which can handle complex stimuli and simulate a realistic behaviour.
2 Crowd Psychology 2.1 Crowd Definition Crowd's definition is very broad, surrounding anything, from a battling army to children in a playground. The crowd is seen as a large group of individuals in the same physical environment, sharing a common goal such as people going to a rock show or a football match (Roloff 1981).
2.2
Crowd Behaviour and its Determinants
Psychologists and sociologists have been particularly focusing their attention on the effects occurring when people with the same goal become one only entity, named crowd or mass. In this case, people can lose their individualities and adopt the behaviour of the crowd entity, behaving in a different way than if they were alone (Benesch 1995). According to Le Bon’s contagion theory (1895), crowds have a great impact on their members. Covered by the anonymity of a crowd, people are setting themselves free from any personal responsibility and surrender to the emotions of the crowd which drives people toward irrational actions. According to Musse and Thlmann (2001), there are three main categories of information that characterize the crowds: knowledge, beliefs and intentions. Knowledge describes the virtual environment's information (e.g. the real position of a door)
CROWD
GROUPS
INDIVIDUALS
Knowledge
Beliefs
Knowledge
Beliefs
Intentions
Beliefs
Intentions
Obstacles to avoid
Crowd parameters
Group memory
Group Perception
Goal and actions to be applied
Relationship with other groups
Follow group or change of group
Status of domination
Be leader
Interest points of the scene
Group Perception
Actions points Table 1: Categories of information distributed among the entities of crowd and dynamically changed during the simulation. Beliefs represents the inner status of groups and individuals (e.g. group A is angry). Lastly, intention illustrates the crowd's and groups of agents goals (e.g. group B goes to the park). Table 1 depicts the information existent in each one of three levels of entity in our model: crowd, groups and individuals.
problems, however, with conventional or boolean logic is that it isn't really capable of handling complex subtleties in logic like the ones we face every day in real life.
2.3
In fuzzy logic the degree of truth of a statement can varies from 0 to 1 and is not limited to the two values of true and false. (Novák, Perfilieva, Močkoř 1999). Fuzzy logic gives you an approach to answering the question in a less absolute way. Every little thing in life is partially true or true to a degree. Someone may considers himself as short, or tall, but the degree to which the statement is true depends on the mathematical weight of your tallness when compared with a group of other people. We represent this sort of grey truth in language all of the time by constructing terms that refer to degrees of truth in classification of various concepts. How far is it? How tired are you?
Crowd Psychology in Numbers
In contradiction to what Van Berger suggested, “we cannot easily reduce human behaviour to a mathematical equation that can be plotted on a graph as a trend line or as a series of variables ”(2002), the idea of using a psychological model is that agents will operate autonomously in perceiving the simulated world and in shaping their reactions to it. In no case will they be pre-scripted or programmed via rules or procedures. What is being modelled are personal value weights on a need hierarchy as well as cultural standards, and individual agents will make their own microdecisions that shows the way to the emergent macro-behaviour (Pelechano, O'Brien, Silverman, Badler 2005) In order psychological elements that influence human behaviour to be taken into account, fuzzy logic is being used, which is a form of mathematically measuring for manipulating logical values derived from the theory of fuzzy sets by Lofti Zadeh (1965)
3 Fuzzy logic 3.1
Fuzzy Logic VS Boolean Logic
Given that the vast amount of the information existing in the real world is more of a shade of grey than black or white, what differentiates fuzzy logic is that it keeps all of the values in between, in contradiction to binary logic that ignores almost all of the information and reduces it to a single bit (Thalmann et al. 2004). Furthermore, in contradiction to boolean (crisp) logic, which is at the heart of the most computer programming languages, the fuzzy logic can deal with reasoning that is approximate rather than precise. Using boolean logic, where binary sets have binary logic with membership value of only 0=false or 1=true, can make logical comparisons, like determining if one or more conditions are true and command through the program's code to perform calculations and functions based on the outcome (Novák 2005). One of the
3.2
Degree of Truth
Using fuzzy logic to create rules for agents to determine what actions they should do makes those agents appear to behave much more like living things do in daily life. In fuzzy logic the degree to which something belongs in a set is measured in membership values between 0.0 and 1.0. Values close to 1 indicate something is almost completely true, and low values close to 0 indicate something is hardly true at all. It's important to also note that fuzzy logic is not random. In fact, on its own fuzzy logic has nothing to do with randomizing numbers. It is simply measuring variable degrees of truth via an assessment of group membership (Zadeh 1965).
3.3
Advantages of Fuzzy Logic
In the environment of the agent, values can change over time and the trueness of certain fuzzy logic statements are changing in a constant way in order to depict that. This sort of fuzzy assessment could be used to regulate the distance between an agent and its enemy. No one is going to break out a tape measure in order to measure the precise distance from themselves to the enemy during a battle, but soldiers would be very aware of an approaching army and would probably react differently based on how 'near' the enemy has come. The nearness of the enemy changes with every step. By estimating approximately the degree to which the enemy is near, your agent will be able to take varied actions, even
reactions of varied intensity based on the threat the approaching enemy poses. Other conditions may be partially true as well, such as whether the agent is 'tired' or not. Each of those inputs can be assigned to a rule and eventually an output, so a character who is somewhat 'tired' fighting an enemy who is 'near' will do a nearrange axe swing, but slower than usual. The character is able to combine reactions even without specifically programming or animating the end result.
3.4
Z
Fuzzy Rules
There are several types of rules such as AND, OR, NAND and NOR that combine fuzzy values together to assert a fuzzy output value (Lee 1990) •
AND rules are true in as much as all of the inputs are true.
•
OR rules are true in as much as any one of the inputs is true.
•
NAND is an inverted AND. It's true in as much as all of the inputs are not true.
•
NOR is an inverted OR. It's true in as much as any of the inputs are not true.
According to Lee (1990) Most of the time AND is all that's required, OR is handy when any one of several factors can influence an output and lastly NAND is useful for when something needs to have more effect when it's not true. In contradiction to the Boolean logic, AND, OR and NOT operators work differently in fuzzy logic having fuzzy results as well (anywhere in the range of 0 to 1), and not strictly true or false (1 or 0). One additional difference between fuzzy logic rules and Boolean logic is that there is generally no 'ELSE' in fuzzy logic. In general, fuzzy logic does not use the else or switch format because all rules must be evaluated.
3.5
LAM BDA
Fuzzy Values and Membership Functions
PI
S
Table 2: Standard membership function types.
4.6
Deffuzzification
Defuzzification is the process of turning fuzzy output values into 'crisp' output values (Jantzen 1998). In most cases this means combining several fuzzy output values (such as zero slow medium fast) in order an output value to be determined (eg: speed in meters per second). The actual output value depends on the strengths of the rules which are activating the fuzzy output values (Leekwijck 1999).
4.7
Structure
In general terms, a fuzzy logic system consists of inputs (speed, turning) which are going to be split in fuzzy inputs (fast, slow, left, right, straight), each one of them has a degree of truth in relation to the main inputs and a fuzzy value defined by a membership function. The fuzzy inputs are followed by rules which are going to blend their values (if fast AND left then lean left, if fast AND right then lean right, if slow OR straight then upright) and create the fuzzy outputs. Once the final fuzzy output values come through the process of defuzzification, it converts them into crisp output values (lean left, lean right, upright) and transfers them to the final output which commands the agent's behaviour.
5 Application Areas of Fuzzy Logic
Fuzzy values are defined by a membership function which is basically a simple curve. By applying the membership function to the input values, a degree of truth between 0 and 1 is generated. Fuzzy values usually correspond to a linguistic symbol such as hot or cold and sometimes they just represent a fuzzy version of a real number. (Godo, Jacas and Valverde 2007)
Robotics is one of the first field that fuzzy logic has been used in the early 90's. Saffiotti (1993) had successfully applied fuzzy logic in a reactive controller for an autonomous mobile robot. Flakey, the mobile robot, was possible for a behaviour selection through a trading of conflicting goals (e.g. avoiding collisions, follow a pathway). Blending the goals allows smooth transition between behaviours and can lead to more complex emerging behaviours.
There are many different kinds of membership functions. Popular ones are Z, λ, π and S (Altrock 1997). These four standard membership function types, which are depicted below at the table 2 as linear curves, named for the curves which are used to determine membership.
From control theory to artificial intelligence, fuzzy logic has been used extensively in a range of applications such as: air conditioners, auto-mobile, elevators, language filters, video games AI, Massive. Fuzzy logic had been used successfully to generate crowds of
people (street, shopping centres, stadiums, battles, traffic etc.), animals (birds, mammals and fishes), jungle (plants and trees), also has been achieved to simulate traffic on roads and costumer behaviour.
6 Conclusion Taking into consideration the importance of CGI crowd simulation in a wide range of fields, such as feature films, this paper depicted several ways of achieving it. Acknowledging the fact that there is a great need of a system capable of handling complex behaviours, an attempt to make a link between crowd simulation and mass psychology has been made. The term crowd has been defined and sub-categorised in groups and individuals, in order its behaviour to be fully understood. Moreover, it has been observed how individuals' behaviour is determined by an array of factors and how that behaviour affects the subgroups. Lastly, an extensive analysis of fuzzy's structure and how each of its components can be use to generate an artificial intelligent brain, has been endeavoured in order a brogue between mass psychology and computer graphics to be built.
Acknowledgements Dedicated to my father, George C. Parliaros
References Altrock, C.V., 1997. Fuzzy logic and neuro-fuzzy applications in business and finance. Upper Saddle River, NJ: Prentice Hall PTR. Artificial Intelligence Center, 1993. A fuzzy controller for Flakey, an autonomous mobile robot. California: SRI International, A572064. Benesch, H., 1995. Atlas de la Psychologie. France: La pochothèque. Bergen, J.V., 2002. Trading Psychology: consensus indicators, Investopedia. Available from: http://www.investopedia.com/articles/trading/02/111802.asp [Accessed 1 March 2010]. Godo, L., Jacas, L. and Valverde, L., 2007. Fuzzy values in fuzzy logic, International journal of intelligent systems, 6 (2), 199-212. Invictus. 2010 [Film] Directed by Clint Eastwood. USA: Warner Bros. Jantzen, J., 1998. Design of fuzzy controllers, Denmark: Technical university of Denmark, department of Automation, 98-E 864. King Kong. 2005 [DVD] Directed by Peter Jackson. New Zealand, USA, Germany: Universal Studios. La psychologie des foules (1895; English translation The Crowd: A Study of the Popular Mind, 1896), LeBon G (1895)
Psychologie des Foules. Alcan, Paris LeBon, G., 1895. Psychologie des Foules. Paris: The echo library. Lee, C.C., 1990. Fuzzy logic in control systems: fuzzy logic controller, IEEE Trans. on systems, Man, and Cybernetics, 20 (2), 404-435. Leekwijck, W.V., 1999. Defuzzification: criteria classification, Fuzzy sets and systems, 108 (2), 159-178.
and
Novák, V., 2005. On fuzzy type theory, Fuzzy sets and systems, 149 (2), 235–273. Novák, V., Perfilieva, I. and Močkoř, J., 1999. Mathematical principles of fuzzy logic. Massachusetts: Kluwer. Ören, T.I. and Aghaee N.G., 2007. Cognitive complexity and dynamic personality in agent simulation, Computer in human behavior, 23 (6), 2983-2997. Pelechano, N., O’Brien, K., Silverman, B. and Badler, N., 2005. Crowd simulation incorporating agent psychological models, roles and communication. First International Workshop on Crowd Simulation. 24-25 November 2005 Switzrland. Pennsylvania: Center of human modeling and simulation. Thalmann, D. and Musse, S.R., 2007. Crowd Simulation. London: Springer. Thalmann, D., Hery, C., Ono, H., Sutton, D., Lippman, S. and Regelous, S., 2004. Crowd and group and crowd animation. SIGGRAPH, 8-12 August 2004 Los Angeles. Switzerland: Swiss Federal Institute of Technology (EPFL), 152-156. The crowd. 1928 [DVD] Directed by King Vidor. USA: MGM. The dark knight. 2008 [DVD] Directed by Christopher Nolan. USA, UK: Warner Bros. The lord of the rings: The two towers. 2002 [DVD] Directed by Peter Jackson. New Zealand, USA and Germany: New line cinema. The lord of the rings: The return of the king. 2003 [DVD] Directed by Peter Jackson. New Zealand, USA and United Kingdom: New line cinema. Zadeh, L.A., 1965. Information and control, Fuzzy sets, 8 (3), 338–353. Musse, S.R. and Thalmann, 2001. Hierarchical model for real time simulation of virtual human crowd, IEEE thansactions on visulazation and computer graphics, 7 (2), 152-164. Roloff, M.E., 1981. Interpersonal communication – the social exchange approach. London: SAGE