Group Simulation of Three Agents Using Unity3d Vincent Wong Max Turpeinen [email protected] [email protected]
Total Page:16
File Type:pdf, Size:1020Kb
Bachelor’s Project in simulation and virtual design KTH Royal Institute of Technology Group Simulation of Three Agents using Unity3D Vincent Wong Max Turpeinen [email protected] [email protected] KTH Royal Institute of Technology | Supervisor: Christopher Peters Link to our blog: http://www.crowdsimulationkth.blogspot.se/ Figure 1: Screen captures from our scene with the latest implementation of our model. Abstract Crowd simulation refers to simulating a large number of agents trying to replicate collective behavior in 3D computer graphics. For this, we have been using the game engine Unity 3D. In our work we are mainly focusing on group formations consisting of 3 agents. Each group is assigned a leader which keeps track of formations and evading collisions. The groups can take on four different formations, working like a finite state machine. In our general scenario, two groups could face, making it useful to adapt the formations and movement direction to avoid each other. We have been implementing our own model after having looked at different major concept already existing in the world of crowd simulation. You could define our model as a hybrid rule-based one, seeing that we have a smaller group working in a way like a single entity, making its judgment dependent on checks with corresponding rules. Virtual cinematography reflecting for most parts real human behavior in one or several 1. Introduction groups interacting. The major industry lays in Crowd simulation is all about simulating a making films and games using 3D computer large number of entities, also known as agents graphics but is also used for public safety as a greater group, instead of individuals. The planning. During e.g. sporting and general general technique is needed when the number spectator occasions crowd controlling of characters exceeds the given tolerated strategies can be made beforehand using computer performance. The idea is to make crowd simulation. This is done to prevent the software cost efficient which in many accidents during emergencies. Generally, cases requested. The concept is applied in crowd simulations are based off of two Bachelor’s Project in simulation and virtual design KTH Royal Institute of Technology different categories; microscopic models and 2.1. Microscopic macroscopic models (discussed in the section The microscopic [4] approach focuses on the “2. Related work”). There are several software issues on an agent level, not taking the group of crowd simulation, but none (what we could as a whole in to account. Usual implemented find) so far specified on three agents. That is aspects for the pedestrian in such approach is what we have been focusing on with our own psychological and social behavior. The rule-based algorithm (which can be seen in “3. Individual agents thereby make their own Implementation”). We have also been decisions as well as sending information in discussing the different techniques as well as between each other. A distinguishing feature our own implementation (in section “4. Result for a microscopic model is its accuracy and its & Discussion”) to finally reach our conclusion high resolution, since it describes how each (“5. Conclusion”). pedestrian behaves in every single step. However, as a result, the cost in computation complexity is very high. Increasing the scale 2. Related work of the crowd, the approach can no longer Throughout the years several different sustain its efficiency and smoothness. techniques to model agents forming crowds have been proposed. Especially now seeing the There are lots of approaches within this immense growth of interest in areas such as category; Cellular Automata, agent-based, movies and computer games. The concept is to particle system, social force and rule based etc. compute a large number of agent’s paths towards shared or different goals, while 2.1.1. Cellular Automata simultaneously avoiding collision in between Also known as “CA” [5] is one of the earlier each other as well as other obstacles. Not to approaches doing crowd simulations. This forget, replicating the human behavior. The approach can be seen as having a navigation problem in itself can be seen in a broader scale mesh divided into identical cells using a using global planning as well as local discrete function and having a state for each behavior. It all can be traced way back to the cell. The state of each cell is based on a set of works of Reynolds [2] who proposed “Boids” local rules. The state of a grid cell changes which is implementing simple rules commonly between zero and one indicating whether or as forces to avoid collision while preventing not a cell is occupied by an agent or not. The flock cohesion. Methods such as seek flee and agents then move towards its goal only able to pursue were later added. The rule-based move in between adjacent grid cells. approach became very popular and created the 2.1.2. Particle Systems basis of what today is known as crowd Particle systems [6] were initially made to simulation. render fuzzy objects like smoke and fire, The subject has also been looked at from many though the idea was also applicable to the area aspects and viewpoint whereas in general, the of crowd simulation. Here, the pedestrian are different methods can be divided in to two defined in a more vague sense seeing them as groups; microscopic & macroscopic. The two mere objects. Like in other microscopic categories focus on crowd simulation on two models the behavior is rule based, but can be different levels, which results in different based off of various algorithms that define the detail-of-level which also cause different behavior or the necessary path calculation. features. 2.2. Macroscopic On the contrary to the microscopic approach, the macroscopic [4] approach cannot bring the same high-resolution result for every Bachelor’s Project in simulation and virtual design KTH Royal Institute of Technology pedestrian, nor does it use the social and just a plane visualization of agents moving by psychological elements of each pedestrian. In random numbers generated. other words, the approach contains overall less information, which makes it more durable for 2.3. Hybrids large-scale crowds and highly concentrated Hybrids, as well in this case as in many others, populations. This is due to the fact that it takes refer to a combination of two commonly used the crowd as a whole and looks more on how implementations. When talking about crowd the environment may affect the behavior of simulation, the combination is about the crowd. Local interaction in between microscopic- and the macroscopic approach. pedestrians in the crowd is not taken in to Many different combinations of the two account when it comes to macroscopic models have been proposed trying to unite the approach. One of the more known models of advantages of each with various results. this type is the flow-based model as well as the An example of a hybrid technique is the one fluid model. A general way of looking at implemented by Narain R. et al. 2009 [3], crowd in the macroscopic sense is using partial where they use a dual representation of the differential equations to describe the change in microscopic- and the macroscopic model. time for the relationship between density flow Here the idea is to use discrete agents along and velocity of a crowd. with a single continuous system where the 2.2.1. Fluids continuous setting steers the large-scale As mentioned earlier, one of the greater behavior of the crowd as well as avoidance approaches in the macroscopic category is the between the agents in dense scenarios. fluid [7] one. This approach has the idea of assigning the large group into different areas, 2.4. Pedestrian also known as fields. Depending on the In a crowd simulation the pedestrians also play specific approach we can have several fields a part. What is the most common thought is with the corresponding aspect, such as density that the pedestrian should fit your fields, velocity fields, and dynamic fields environment, though what is also worth where e.g. dynamic fields are used to handle mentioning is the detail of it. The cost between obstacles. Since the crowd is seen either as a simulating a group of high resolution 3D fluid or a gas, physical laws of fluids dynamics characters and a group of low resolution 3D are of great value doing the modelling. characters can be of great importance. Important to note is that the group should A solution to this problem is to use imposters share the same goal. [9]. Imposters is a way of rendering a 3D 2.2.2. Chaos Models character in 2D and placing it in front of the The chaos model refers to a crowd with a real 3D one, which takes less time than chaotic behavior known to be implemented by actually rendering the real 3D one. This is Saiwaki et al., 1997 [8]. The agents work on commonly rendering background objects, but their own, but what makes them a uniform can also be used in the case of crowd group is that each agent is share the same set simulation, implementing it on pedestrians of parameters and rules. This might be seen as either meant to be far away or not placed in a microscopic approach but the focus lies in center (not meant to have focus). the group, and not the individual agent. By changing the few existing parameters and rules for all of them, very different and interesting 3. Implementation (model) behavior can be observed. This make the In general, every crowd simulation consists of model and its agents more controllable, and a model of an agent, as well as an implementation of an algorithm.