
Modelling and Transformation of Non-Player Characters’ Behaviour in Modern Computer Games Gino Wuytjens Supervisor: Prof. Dr. Hans Vangheluwe Faculty of Science University of Antwerp Antwerp, Belgium May 1st, 2012 A thesis submitted to University of Antwerp in fulfilment of the requirements of the degree of Master of Science in Information Technology Copyright ©2012 Gino Wuytjens. All rights reserved. Abstract During this thesis, a formal architecture for developing NPC behaviour through the use of the Stat- echarts formalism is developed. Creating NPC behaviour has so far been done using textual pro- gramming languages, often times using a state-based architecture. This lends itself to new research in using the Statecharts modelling formalism to improve several aspects of NPC behaviour and its development, including but not limited to re-usability of code, readability, automatic generation and variability. This thesis develops a testing platform in which such an architecture can be extensively studied and analysed, through the use of a Tank Wars style game. Furthermore, a Transformation platform is developed with the aim of generating NPC behaviour from a collection of components. This generation is done based on a provided heuristic, which determines what kind of behaviour is desired by the developer. The transformation platform further introduces variability into the generated behaviour by allowing parameter transformation, component structure transformation and Statecharts model transformation to be carried out following rules defined by the user. The designs and technolo- gies developed throughout this thesis are kept as general as possible, with the aim of making this work applicable in a wide array of contexts, such as time-based and event-based game engines. This thesis is a first foray into this kind of behaviour development and lends itself well as the basis for even more advanced and expansive strategies for developing NPC behaviour based on the proposed architecture using the Statecharts formalism. i Contents 1 Introduction 1 1.1 Problem Statement . .1 1.2 Objectives . .2 1.3 Considerations . .3 1.4 Personal Motivation . .4 1.5 Thesis Outline . .4 2 Statecharts Formalism 6 2.1 Introduction . .6 2.2 States . .8 2.3 Depth: Compound States . .9 2.4 Parallelism: Orthogonal States . 10 2.5 Formal Semantics . 12 3 Model Transformation 13 3.1 Introduction . 13 3.2 Features . 13 3.2.1 Transformation Rules . 13 3.2.2 Rule Application Scoping . 15 3.2.3 Source-Target Relationship . 15 3.2.4 Rule Application Strategy . 15 3.2.5 Rule Scheduling . 16 3.2.6 Rule Organisation . 17 3.2.7 Tracing . 17 ii 3.2.8 Directionality . 17 3.3 Categories . 17 3.3.1 Model-to-Code Transformation . 18 3.3.2 Model-to-Model Transformation . 18 3.4 In This Thesis . 19 4 Related Work 20 4.1 Modelling Artificial Intelligence . 20 4.1.1 Statecharts . 21 4.1.2 Decision Trees . 27 4.1.3 Visual Scripting . 27 4.1.4 Advanced Toolsets . 28 4.2 AI Model Transformation . 29 4.2.1 Procedural AI Generation . 30 4.2.2 Determining Good Transformations . 33 5 Statecharts as NPC AI 35 5.1 General Design for a Layered Architecture of Components . 35 5.1.1 Components . 36 5.1.2 Layers . 36 5.1.3 Communication . 39 5.1.4 Connection to a Player . 43 5.2 A Test Platform for Statechart AI . 43 5.2.1 Game Type: Tank Wars . 43 5.2.2 Creating the Test Platform . 44 5.2.3 Usage . 71 5.3 Creating NPC Behaviour Using Statecharts . 73 5.3.1 Determining the layers and their function . 73 5.3.2 Sensor components . 75 5.3.3 Analyser Components . 79 5.3.4 Memoriser Components . 81 iii 5.3.5 Strategic Decider Components . 83 5.3.6 Tactical Decider Components . 84 5.3.7 Executor Components . 90 5.3.8 Coordinator Components . 93 5.3.9 Actuator Components . 96 6 Transformation of Statechart AI 99 6.1 Parameter Transformation . 99 6.1.1 Implementation . 100 6.2 Component Structure Transformation . 101 6.2.1 Implementation . 102 6.3 Statecharts Model Transformation . 103 6.3.1 Implementation . 103 6.3.2 Example Transformation Rules . 104 6.4 Transformation Platform . 107 6.4.1 Goals . 107 6.4.2 Design . 107 6.4.3 Required Data . 109 6.4.4 Heuristics . 112 6.4.5 Usage . 113 7 Results 115 7.1 Platform Configurations . 115 7.1.1 Test Platform . 115 7.1.2 Transformation Platform . 116 7.2 Test Platform Results . 118 7.3 Transformation Platform Results . 124 7.4 Testing Generated NPC Behaviour Descriptions . 126 7.4.1 Interpreting These Results . 127 8 Conclusion 129 iv 8.1 Real World Applicability . 129 8.2 Behaviour Modelling Advantages . 129 8.3 Future Work . 130 Bibliography 132 v 1 Introduction This introductory chapter serves to provide the reader with the required context to understand the problem addressed by this Master’s Thesis. Furthermore, a summary of various considerations that had to be made before work on the thesis could be started is provided, such as the choice of program- ming language, modelling formalism and modelling tools. The chapter ends with an outline of the thesis as a whole. 1.1 Problem Statement In previous work, it has been shown that modelling the "Artificial Intelligence" (i.e. behaviour) of game characters is feasible. In [KDV07], a layered approach is formulated, which is expanded upon in [Bla08] to show that the Statecharts formalism is a natural fit for this purpose and that the (generic parts of) developed AI model can be easily re-used in various application domains, from a computer game to a real-life robot. Non-Player Characters (NPCs) in virtual environments or computer games exhibit autonomous and reactive behaviour that may seem intelligent and is hence often called Artificial Intelligence (AI). A popular and widespread technique is to have the NPCs be stateful. For example, an AI controlled tank in a Tank Wars type of game might have three possible states: idle, attacking and fleeing. The actual state of the tank will determine the actions the tank can take. This technique has been in use for a long time and has shown to be exceptionally useful to quickly develop interesting AI for games. However, the technique has not really evolved over the years. While computer graphics and gameplay have gone through big changes the last several decades, AI development for NPCs has not seen the same kind of change. This thesis proposes to leverage the findings of [KDV07] and [Bla08] to model the AI of NPCs completely in the Statecharts formalism, making use of all the features provided by the language to create a new paradigm for the modelling of timed, autonomous and reactive behaviour in NPCs. These models can then be used to analyse, simulate and ultimately synthesize code for NPC behaviour. Computer games that involve any kind of Non-Player Characters make use of AI to create a re- alistic and/or interesting game play experiences. Particularly in Massively Multiplayer Online Role Playing Games, players often encounter large groups of similar NPCs, usually powered by the exact same AI, but with different parameters. This causes players to lose their immersion in the interac- 1.2 Objectives 2 tive experience and start seeing it as a series of encounters that must be completed to continue the experience. It should be possible then, to create some AI for a particular type of NPC and have this AI transformed into several variants. Such variants would cause groups of NPCs to show different emergent behaviour, which differs on more than simply the amount of health, speed or other simple attributes. This heterogenity in NPC groups of the same type can be used to increase player immer- sion and simulation realism. It could potentially be used to tailor the game experience to the player, by transforming the original AI according to parameters retrieved from the player’s performance in previous phases of the game. 1.2 Objectives The problem statement above highlights the current situation in AI development for NPCs and shows the areas which can be improved. To achieve the proposed functionality, several objectives were for- mulated that need to be fulfilled in order to achieve our goal. Research Related Work First and foremost, related work in the fields of AI modelling, model transformation and NPC AI practices should be explored. Being aware of the current state of these fields is important to ensure the validity of this thesis, since it will build upon the previous work to tackle the previously mentioned problems. Test Platform As the first actual implementation task, a.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages140 Page
-
File Size-