Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICT2191 Topic 2 Agents, Animats and Game Platforms What are agents and artificial life? Considerations for game AI Goal orientation, planning and control.

Similar presentations

Presentation on theme: "ICT2191 Topic 2 Agents, Animats and Game Platforms What are agents and artificial life? Considerations for game AI Goal orientation, planning and control."— Presentation transcript:

1 ICT2191 Topic 2 Agents, Animats and Game Platforms What are agents and artificial life? Considerations for game AI Goal orientation, planning and control Reactive techniques for games Reflective vs Reactive behaviour The FEAR platform Creating and running an animat Evaluating the performance of an animat Reading: Champandard Chapter 3; Chapter 4; The FEAR documentation

2 ICT2192 Agents Arguably the most important development in AI of the last decade has been the notion of agents Comes from the philosophical notions of action, and the notion of Rational Economic Man An agent is a self-contained bundle of software with the characteristics of autonomy, action and rationality Related to, but more sophisticated than, the notion of an object in OOL. Higher level of abstraction, in which what counts is the choice of action in response to goals and situation. Newell’s concept of behavioural laws governing action eg An agent will choose the action most likely to lead to an outcome that matches one of its goals. In a multi-agent system complex behaviour emerges as the result of the interactions between many, relatively simple agents according to social principles

3 A-life shares some elements with agent research, especially the multi- agent approach Earliest forms were a class of game called cellular automata eg Conway’s Life A few rules control the birth, survival and death of counters on a rectangular grid, to produce growing, complex patterns over cycles Artificial Life – Cellular automata Cells can be either live (contain counter) or dead (no counter). Each cell has 8 neighbours. To decide what will happen in a cell for each cycle, count the number of live and dead cells 1) A dead cell with exactly 3 live neighbors becomes a live cell (birth). 2) A live cell with 2 or 3 live neighbors stays alive (survival). 3) In all other cases, a cell dies or remains dead (overcrowding or loneliness).

4 ICT2194 Artificial Life - Norns Image: Cyberlife/New Scientist However, A-life today is about making biologically plausible software models Some of this work has resulted in extremely valuable creatures which may be used in game-playing scenarios eg Norns in Cyberlife’s Creatures Norns have a simulated body, with a ‘digestive system’ and ‘biochemistry’

5 ICT2195 Considerations for Game AI Are the AI approaches applicable to the software design of NPCs? ie able to provide: - control of primitive behaviours eg picking things up, pressing switches, using objects, etc. - movement move around the game world, dealing with obstacles and navigating to target destinations - decision-making working out what tasks to perform, and in what order Traditionally, these things were done by laborious, detailed, procedural programming - now becoming more difficult as games evolve From a games point of view, you don’t care if you use as AI or not But we want to learn about AI, so we’ll care

6 Considerations for Game AI In nouvelle game AI, we consider how the needs of game designers work for (and against) AI methods In games, some NPC characters need to behave intelligently to be believable and entertaining – maybe easier to accomplish with AI programs......but only if the program can really perform (very fast response to new situation) - challenging for AI Software control of actions within a game has until recently needed to be explicit – ie scripting For each of a number of situations arising in the game, a standard behaviour response is rigidly encoded More recently, agent and other AI technologies have enabled implicit control – NPC assesses situation, chooses its action with respect to its own goals

7 ICT2197 Considerations for Game AI Basic conflict for game design: Building in intelligence allows NPC characters to behave autonomously, yet human designers need to control them, to make the game work as expected Eg many games follow a script like a movie, so that a certain sequence of events happens to unfold a story line. If NPCs (especially learning ones) can run their own show, they might not stick to the script! What role would intelligent decisions have in a scripted storyline? One idea would be implicit design – no explicit script, just the elements of an interesting world and both player and NPC improvise Another is to alternate sequences of scripted action (in which the NPCs intelligence is switched off) with free form action (in which the intelligence is on). Might be difficult to keep on track though!

8 ICT2198

9 9 Goal-orientation, planning Goals may be defined as a representation of a state of affairs which is marked as somehow desirable, to be achieved Maintenance goals involve making sure some state of affairs is not lost (eg keep breathing) Achieving a goal may involve a number of actions to move the actual state of the world closer to the desired state (eg move toward a source of food or target) It might not be clear what to do next to get closer to a goal – planning is needed to select and order individual actions All this requires collecting and maintaining models of the world- state, comparing them to goal states and then making decisions This can take a lot of design and a lot of computation Planning programs exist, but they tend to be slow and complex

10 ICT21910 The problem of planning Conventional AI planning program requires i) a list of goals represented using a knowlege representation ii) a problem in the form of some data representing opportunities or problems iii) a set of possible actions which the machine can choose from iv) a planning algorithm which organises actions into a optimal plan The program would then do standard information processing: 1) accepts these as data files 2) process the data 3) prints out an optimal plan, ie ordered list of actions

11 Reflective vs Reactive Behaviour This distinction is important to game development, mostly because of the need for fast reactions Early AI tended to be reflective – meaning that a problem- solving algorithm would exhaustively consider all possible courses of action, then choose the optimal (in terms of goal satisfaction) one Humans don’t really do that, though. They satisfice, which means come up with a “good enough” solution, but more quickly, especially when time is an issue. Saves mental effort Reflective programs build representational models from input data, evaluate or reason about them, plan a course of action then output it – expensive in computing power Reactive programs use the world as their model. They interact directly with the world, exploiting simple signals and regularities there, to get behaviour which is not perfect, but fast Now game AI tends to be mostly reactive

12 ICT21912 Image: Mike Williams One does not want to be stuck in high-level planning when there’s an emergency bearing down on you Maybe it’s quicker and easier to sense the world and act directly on it, instead of building and maintaining internal models of the world This is how insects are able to do a lot of clever things without a big brain and lots of memory Image: Benjamin Hobson, The Canal Gallery

13 ICT21913 Reactive Techniques for Games Another advantage of reactive designs is that they tend to be deterministic – fully specified by inputs That means reactive code can very simple, easy to test and be highly optimised for speed eg - lookup tables - scripts - rule-based systems - Finite State Machines Benefits for animats - fits in with the idea of embodiment very well - environment can be enriched which provides more information to the animat - most learning techniques are based on reactive mappings - easy to create, test and maintain

14 Environments, simulations, platforms According to the notion of embodiment, the best place for an AI in immersed in the world, connected to it by many sensors and actuators Eg a robot roams about a house, sensing with cameras, microphones and using motorised limbs to move Game AI modifies this slightly, and says the ‘world’ doesn’t have to be physical – it can be a computer simulation of the real world Advantages - Cheaper and smaller than robots in the real world - Can develop and make changes faster in simulation - Can’t do any harm if it goes wrong Disadvantages - world may be too simple to properly challenge an AI program - world may not be realistic, or even logically consistent - may have to build - or at least configure - an artificial world; extra work In game AI, we are more or less forced use to a simulated world. But this is still better than prepared, cut-and-dried data sets

15 ICT21915 FEAR Platform - Overview To simplify writing of AI code, the environment and integrating the two, we will use a standard development platform, called Flexible Embodied Animat aRchitecture (FEAR) Creates embodied animats ie that have a (simulated) body, are subject to physical constraints in the (simulated) world and do not have full information about the game Just as human game players has an avatar in the game world, so a disembodied AI software controls its own avatar FEAR is designed to work with the engine of Quake II, an old first person shooter The game developer specifies the interfaces, modules and architectures of an animat in a given world, in a domain-specific language called XML

16 ICT21916 –Interfaces - provide a set of functions that can be called, messages that can be passed back, type definitions and constant declarations –Modules - the implementation behind the interfaces. Usually run- time code, but you can store data in these too. To formalise dependencies between modules, each imports and exports interfaces –Architectures – are built up from nested components ie a hierarchy or tree. The root of the hierarchy is usually the brain of an animat These high-level XML specifications are processed into C++ source code - ready for compilation - using customised templates This is called code generation or metaprogramming Think of FEAR as developing toward an “IDE for Games AI” FEAR Platform

17 ICT21917 Compiling an Animat Take a demo animat from the AIGameDev website Or write your own animat by generating your own XLM template and writing C++ code (usually called Brain) Unless you are an expert it is better to modify an existing animat than make a new one completely from scratch Compile the animat using the MS Visual Studio 6.0 Check that it has compiled, debug as necessary

18 ICT21918 animats customise an XML template build using Visual Studio C++ compiler use/modify an existing animat and/or... FEAR/Quake2 modules (FEAR) Server sv add (FEAR) Server

19 ICT21919 Running the Animat Run the FEAR/Quake 2 server with a command line prompt by double clicking (FEAR) Server. Force the animat under test in by typing sv add ====== Quake2 Initialized ====== ==== InitGame ==== ------- Server Initialization ------- 49 entities inhibited 0 teams with 0 entities -------- FEAR Initialisation -------- obituaries disabled acceleration disabled 0 bots requested ------------------------------------- sv add 05-Dr.Spin Dr. Spin connected Dr. Spin entered the game. bots = 1 To observe the animat’s behaviour, enter the game as a human player clicking (FEAR) Player.

20 Evaluating Performance of Animat It will be important to measure the performance of the animat in order to compare brain designs (which is better?) Measuring behaviour can be difficult, as ethologists (scientists studying animal behaviour) or psychologists (scientists studying human behaviour) learned One advantage of a game platform is that it has a built-in measure for animats, which is their score In Quake II, press the F1 key to view the score for yourself (‘The Creator’) and your animat These statistics are crude, but might be enough to begin with To compare the scores of two animats, you need to have exposed them to the same challenges, for the same amount of time (a controlled experiment) We distinguish between single-trial measurements and tournaments (gathering statistics over multiple trials).

21 ICT21921 Summary Agents are an AI development which enables software to choose actions autonomously to achieve one or more goals which it has Artificial life is an attempt to model the more biological aspects of life, such as reproduction (Life) or the digestion of food (eg Norns) Both these technologies can be used to make lifelike, believable and entertaining NPCs for computer games The software control of NPCs can be explicit (eg scripts) or implicit (eg rational agent) Good control of gameplay in interactive games is part of the art In conventional AI, accomplishment of goals required planning, which could be complex and processor-intensive Conventional AI planners were reflective, which means they did not excel in time critical situations (like games) Behavioural control in games tends to be reactive, which means less logical modeling of the world and more reacting directly to stimuli

22 ICT21922 References Newell, A. The Knowledge Level, Artificial Intelligence, 1982, 18, 87-127 Martin Gardner. The fantastic combination of John Conway's new solitaire game of “life”. Scientific American, 1970, 223, 120-123 Cliff D. & Grand S. The Creatures Global Digital Ecosystem. Artificial Life, 1999, 5, 1, 77-93. Available at Champandard, A. FEAR User Guide. Online Manual for FEAR/Quake 2 Platform Available at

Download ppt "ICT2191 Topic 2 Agents, Animats and Game Platforms What are agents and artificial life? Considerations for game AI Goal orientation, planning and control."

Similar presentations

Ads by Google