215
Chapter 10
Modular Reuse of
AI Behaviors for
Digital Games
Christopher Dragert, Jörg Kienzle,
and Clark Verbrugge
CONTENTS
10.1 Introduction 216
10.2 Background and Related Work 218
10.2.1 Layered Statechart-Based AI 219
10.2.1.1 Sample AI for a Squirrel NPC 220
10.3 AI Module 222
10.3.1 AI Module Interaction 223
10.3.1.1 Event-Based Interaction 223
10.3.1.2 Synchronous Communication 223
10.3.1.3 Miscellaneous AI Module Properties 224
10.3.2 AI Module Interface 225
10.4 Reuse and Component Integration 226
10.4.1 Event Renaming 227
10.4.2 Associated-Class Connection 228
10.4.3 Functional Groups 229
10.4.3.1 Group-Private Events 230
10.5 Case Study: Squirrel to Trash Collector 231
10.5.1 Trash Collector Specication 231
10.5.1.1 Exploring 232
10.5.1.2 Collecting Trash 232
10.5.1.3 Using Trash Receptacles 233
216 Computer Games and Software Engineering
10.1 INTRODUCTION
Complex and ubiquitous articial intelligence (AI) has become a staple of
modern computer games; players expect nonplayer characters (NPCs) to
intelligently react to player actions while exhibiting appropriate behaviors
depending on their role within the game context. Developing a good AI
for a real-time game environment, however, is a dicult task. Although a
variety of formalisms are employed, practical AI designs typically resort
to strongly customized approaches closely connected to the underlying
game architecture and the NPC type. is results in a relative lack of reuse
in game AI, increasing development costs and requiring the repetitive
development of oen quite similar AI behaviors.
e narrow game-by-game focus is a source of consternation for game
developers. At GDC 2011, Kevin Dill raised this issue, arguing that the
lack of behavioral modularity was stymieing the development of high-
quality AI [1]. Previous work has argued that the fundamental cause for
this lies within the formalisms employed [2]. e applicability of soware
engineering practices becomes limited due to the use of nonmodular cus-
tom approaches. As an alternative, the layered statechart-based approach
[3] provides inherent modularity with nesting capabilities.
Our approach to AI reuse builds from layered statechart-based AI.
Here, we provide a formalism and structure that encapsulates behaviors;
we are able to dene a development strategy that allows the extensive reuse
of dierent AI components, including both high- and low-level elements.
Partial behavioral composition is enabled by the introduction of functional
groups, providing an ecient way to reuse groups of related behaviors.
Clear identication of code dependencies further permits analysis and
the tool-based presentation required to ensure proper integration into the
actual game code. is yields a faster development process with the ability
10.5.2 Building the NPC 233
10.5.3 Case Study Summary 234
10.6 Scythe AI Tool 235
10.6.1 Workow and Key Features 235
10.6.1.1 Importing Modules 235
10.6.1.2 AI Construction 236
10.6.1.3 Outputting the AI 237
10.7 Conclusions and Future Work 237
References 238

Get Computer Games and Software Engineering now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.