The Use of Fuzzy Logic for Artificial Intelligence in Games
Total Page:16
File Type:pdf, Size:1020Kb
The use of Fuzzy Logic for Artificial Intelligence in Games Michele Pirovano1;2 1Department of Computer Science, University of Milano, Milano, Italy 2Dipartimento di Ingegneria Elettronica e Informazione, Politecnico di Milano, Italy December 7, 2012 Abstract Game AI, like all other aspects of a videogame, exists to pro- pel the higher goal of a videogame: to be fun and entertain. In Game artificial intelligence (game AI) is the branch of other words, the motto of the game AI society is often thought videogame development that is concerned with empowering to be If the player cannot see it, why do it? [21]. The context games with the illusion of intelligence. Game AI borrows is however not so simple nowadays, as partly due to successful many techniques from the broader field of AI, from simple fi- products that have brought forward advanced AI, partly due to nite state machines to state-of-the-art evolutionary algorithms. the ubiquitous online multi-player options that have changed Among these techniques, fuzzy logic is one of the tools that the habits of players, players are now more demanding in re- must be present in the arsenal of a good videogame AI de- gards to AI and more and more game developers have turned veloper, due to the simplicity of its formulation coupled with their attention from scripted and predictable agents to more its expressive power. In this paper, we introduce the field of human-like agents, capable of learning and thus, in the clas- game AI and review the use of fuzzy logic in games, looking sical AI definition, intelligent. Another peculiarity of game both at industry and research. We outline its benefits, address AI lies in the fact that games are, for the most part, subject to its shortcomings and present its practical uses. real-time constraints and thus there is little space for slow, off- line techniques. This fact shares similitudes to the AI used in robotics and control systems [25], and this is the reason why 1 Artificial Intelligence and Games the same techniques, in one form or another, can be found in all these fields. At last, we must remember that video games The field of game artificial intelligence encompasses all are part of the entertainment industry, an industry well-known the techniques and methods for injecting intelligence into for its fast advancements, sudden turns of trends and tight de- video games. To game AI pertain many different aspects velopment schedules. This leaves little room for highly inno- of a videogame: animation control, steering, flocking, path- vative yet not throughly tested AI techniques that may hide finding, planning, procedural generation, tactical and strate- nasty surprises and detour development. Due to these differ- gic thinking, and learning [21, 6]. All these aspects share the ences, the game AI field has been advancing in a different but same basis, they pose problems whose efficient solution re- parallel direction in respect to academic AI, borrowing ideas quires AI algorithms. The purpose of game AI is to bring life and methods from the latter while always keeping a practical to the non-playable characters (NPCs) present in the games, approach in mind [16, 32]. such as the enemy troops in a strategy game or the merchants In this paper, we discuss the application of a specific tech- in a peaceful AI-controlled village. nique to videogame AI: fuzzy logic. In the next section, we Game AI is just one of the branches of the broader field examine the current state of the game AI field in order to pro- of artificial intelligence. Academic AI research always suf- vide a context for the discussion on fuzzy logic. We introduce fered from a difficulty to define artificial intelligence itself, al- the concepts of fuzzy logic and detail its applications for game though it can be typically identified in the study and recreation AI in section 3. In section 5, existing uses of fuzzy logic in the of human-like or human-level cognitive processes and in the industry and in research are reported and analyzed. In section capability of these processes to learn [16]. According to Alan 6, we draw conclusions on the current situation about the use Turing, who is considered the father of artificial intelligence, of fuzzy logic in games. an agent is intelligent if its behavior cannot be distinguished from that of a human [33]. Game AI adds another piece to the puzzle of defining AI, as it is not concerned with the actual 2 The current state of Game AI existence of intelligence, but just with the illusion of it [29]. For a game to be successful, we do not really need highly- Considered as a last-minute addition in the eighties and intelligent, human-like, possibly unbeatable expert opponents, nineties, game AI has instead been gaining attention from both what is required is a compelling adversary, an AI agent that is academics and industry during the last decade. Traditionally, fun to play against and that is at least not obviously stupid. games have been pushing on their visual and audial compo- 1 nents in order to attract more consumers. Most CPU process- implement and, especially, to test. ing power had thus to be taken up by the graphics computa- Nonetheless, more advanced techniques have been spotted tion, often followed by sound processing and, of course, game even in commercial games and the proof of their use is in the logic. This left AI with very little time to perform its compu- wealth of examples that can be found in game AI manuals tations, which resulted in the ubiquitous stupid hordes of en- [21, 6]. Bayesian networks are used in Real-Time Strategy emies of older games. The rush for better, more realistic and games (RTS) for goal planning [21]. Neural networks ap- more gratifying graphics has however slowed down, if it has pear in the Creatures game series1 as well as in several real- not come to an halt, in the recent years, to the point that some time strategy games and in the award-winning game Black & games today are almost indistinguishable from reality. Ded- White2. More recently, the use of evolutionary algorithms has icated graphics processing units (GPUs) now sustain most of been popularized by the Galactic Arms Race videogame [13]. the graphics computation, leaving more room in the CPU for Artificial life is another favorite of game AI developers, of other processor intensive components, such as physics and AI. which Creatures and most Maxis games3 are the biggest ex- In this context, game AI has been earning its fame as a means ponents. Those games are however the exception to the rule to make a game stand out among the competition. Nowadays, and that whenever advanced AI techniques are inserted into a more CPU time is given at each game frame to the AI, more game, they are part of the main focus of the game itself. In than enough for most applications, and some programmers are other words, advanced techniques currently need a game built specifically dedicated in a team to create a challenging, inter- around them. There are three main reasons for this fact. First, esting and (seemingly) intelligent AI [37, 38]. those techniques are often difficult to implement in compar- On the other hand, academics have started to like to meddle ison to FSMs or decision trees. This is enough of a draw- with video games when experimenting with AI techniques, back for developers rushing for their game to ship. Second, due to the fact that games present a low-cost, safe and simple some of the more advanced techniques, for instance genetic environment in respect to reality. Instead of testing AI tech- algorithms, usually bring with them either a high computa- niques on the field, researchers can safely test them in a virtual tional cost or a high memory cost. A last problem arising environment. As an example, researchers have been creating from the use of more advanced techniques lies in their non- controllers for virtual cars in the TORCS Simulated Car Rac- determinism. Developers are reluctant to ship a game that has ing Competition [18] that sees researchers from all around the not been completely tested and the risk of an evolutionary al- world competing to provide cutting-edge controllers for steer- gorithm learning something wrong is too high. ing a car in a realistic racing simulation, with obvious benefits In the large spectrum of game AI techniques, somewhere as a test-suite for automation without crashing a single vehi- between the simple techniques and the more advanced ones, cle. we can find fuzzy logic. 2.1 Game AI techniques 3 Fuzzy Logic As we have seen, game AI is the offspring of two, quite dif- ferent, fields: academics AI and videogame development. On Fuzzy logic is a superset of conventional logic that has been the one hand, it shares the enthusiasm for discovery typical extended to handle the concept of partial-truth values between of AI researchers. On the other hand, as with any other game the boolean dichotomy of true and false. Fuzzy logic usually development aspect, it tends to reuse tried and tested meth- takes the form of a fuzzy reasoning system and its components ods and to stop when something works just enough, due to the are fuzzy variables, fuzzy rules and a fuzzy inference engine. developers’ struggle with tight availability of resources and Using fuzzy set theory, variables are fuzzified by selecting a strict time schedules imposed by the commercially-oriented set of membership functions on their possible range of values.