Artificial Intelligence in Video Games Jason Fuller 1














































- Slides: 46
Artificial Intelligence in Video Games Jason Fuller 1
What is Game AI? Ø Imitate intelligence in the actions of non-player characters (NPCs). Ø Make the game “feel” real. Ø Obey laws of the game Ø Show decision making and planning 2
Goals of Game AI Ø Be fun! Ø Be challenging but not overwhelming (unless the hardest difficulty is selected) Ø Do not hog all the resources! (CPU time) Ø Make sure the AI does not cheat! (At least do not get caught) Ø AI often get bonuses when difficulty increases 3
Types of Games 1. Action games Ø Shooters (FPS and Third-Person) Ø Racing, Sports 2. RPG games (Role Playing Game) Ø Often include many action game aspects of AI 3. RTS games (Real Time Strategy) 4
Game AI Types Ø Action and RPG AI tend to work better with Finite State Machine based AI Ø RTS AI used Finite State Machines in the early years of AI development. Ø RTS AI work best with Artificial Neural Networks and Fuzzy Logic Ø Both contain path finding components 5
AI Path Finding Dijkstra’s Algorithm A* Algorithm Ø Most commonly used Ø Finds the shortest path Ø The world or map of the game is represented by a grid of points 6
A* Algorithm Ø Allows for high optimization Ø Either by changing the search algorithm to better suit the game or by changing the data structures. Ø Very similar to how people move between locations in a city. 7
Finite State Machines (FSM) Ø Simplest and most basic AI model. Ø Consists of: Ø States Ø State Transitions Ø Most common for Action games! Ø Not many different actions for NPCs 8
Finite State Machines Ø Among the States and State Transitions there are 4 components: Ø States which define behavior Ø State transitions which are the movement from one state to another Ø Conditions which must be met for state transition Ø Events/Actions which are internally or externally generated which may lead to a state transition 9
FSM Example 10
FSM Disadvantages Ø Very predictable Ø Too many states get tough to organize Ø Since there are such crisp rules between states, NPC does not feel natural 11
FSM within a State Ø States have a FSM within them 12
Modern FSM Example 13
History of Finite State Machines Ø In 1952, the game Nim used AI to play against an opponent. Ø 1960’s & 1970’s Ø Spacewar! Ø Pong Ø Space Invaders Ø 1980’s Ø Simcity 14
History Continued Ø 1990’s Ø Dragon Quest IV Ø Warcraft Ø Half-Life 15
Artificial Neural Networks (ANN) Ø No agreed definition, most common one is “a network of simple processing elements, which can exhibit complex global behavior, determined by the connections between the processing elements and element parameters. ” Ø Mathematical model inspired by biological neural networks. Ø An adaptive structure that can learn. 16
ANN Structure Ø Very similar to the structure of our brain. Ø Input layer, processing (hidden) layer, output layer Ø Learns by example 17
ANN Structure Ø The hidden layer is not just a straight line of nodes Ø Each node in the hidden layer will contain just a small part of the overall calculation Ø The nodes have connections between each other with certain weights 18
ANN Structure Ø The weight of the connections between the nodes determine the outcomes of the calculations Ø If a node is triggered by 2 different nodes it can then determine which one is more important 19
ANN Learning 20
21
22
Black & White Ø Came out in 2001 Ø First to effectively use Artificial Neural Networks 23
Halo Wars Ø Came out in 2009 Ø Featured a “Custom” difficulty level that used Artificial Neural Networks 24
Fuzzy Logic Ø Introduced in 1965 for use in Artificial Intelligence research Ø Present problems to computers in a way similar to how humans solve problems and that everything is a matter of degree (or preference or context). 25
Example Problem A store owner needs to decide how much produce to order. Elements to take in to consideration: Ø Time of year? Ø What is the weather like? Ø Is there a Holiday coming up? 26
Video § Fuzzy Logic: An Introduction 27
Games Now that the major types of AI have been covered, I will go into more detail about what games they are used in. 28
Racing Game AI Ø Large-scale cheating! Ø AI already know the track and optimal path Ø AI already has complete behavior determined before the start of the race 29
Racing AI graphs General Path Optimal Path 30
Racing Game AI Ø In its basic form, it is the most basic of game AI but in some of the racing simulators, the AI are more complicated Ø If the player is using the optimal path, the AI will actively try to push them off of it. Ø The AI will also use tricks such as spinning out opponents by making their back tires lose grip. 31
FPS Game AI Ø Implemented with a layered structure Ø Bottom layers control the path finding tasks and animation selection Ø Higher layers control the tactical reasoning which is where the Finite State Machine would be. 32
A* Graph of FPS or RPG World General path Playable Zone Unplayable Zone 33
FPS Continued Ø F. E. A. R. series has revolutionary AI Ø AIs have knowledge of map elements and will flank the player Ø AI will break through walls and windows to get to the player Ø AI will rush when they heavily outnumber the player 34
RPG Game AI Ø Many encounters with AI are unscripted Ø GTA IV and Far Cry 2 made great leaps in “friendly” AI 35
Elder Scrolls IV: Oblivion Ø Released in 2006 Ø During testing, a story important NPC kept being found dead. Ø A mechanic of the AI was the cause. 36
Bioshock Infinite Ø The player companion, Elizabeth (who is an AI), is almost entirely unscripted. 37
RTS Game AI Ø Started out using Finite State Machines to control AI Ø Too many options to cover Ø AI was “dumb” Ø AI would build up in a strict way Ø Once the player found a strategy that worked against the AI, it would always work. Ø RTS AI switched to a combination of Fuzzy Logic and Artificial Neural Networks 38
RTS Game AI Ø By changing to Fuzzy Logic and Artificial Neural Networks (ANN): Ø Fuzzy Logic led to smarter responses to attacks Ø ANN led to smarter development of base and better long term decisions 39
A* Graph of RTS Map 40
RTS Continued Ø Maxis is again changing the simulation landscape with the new Simcity Ø Every “Sim” is a full AI Ø Have there own agenda Ø Have specific wants and needs 41
Video § Sim. City: Economics AI 42
Future of Game AI Ø Game AI have made great leaps forward since they were first developed. Ø An AI that can learn how you play a game would be a great opponent 43
References § Champandard, Alex. "Top 10 Most Influential AI Games. " Aigamedev. com. N. p. , 12 Sept. 2007. Web. 25 Feb. 2013. <http: //aigamedev. com/open/review/top-ai-games/>. § Grant, Eugene, and Rex Lardner. "The Talk of the Town. " The. New. Yorker. com. The New Yorker, 02 Aug. 1952. Web. 25 Feb. 2013. <http: //www. newyorker. com/archive/1952/08/02/1952_08_02_018_TNY_CARDS_00023 6053>. § Grzyb, Janusz. "Artificial Intelligence in Games. " - Code. Project. Software Developer's Journal, n. d. Web. 25 Feb. 2013. <http: //www. codeproject. com/Articles/14840/Artificial. Intelligence-in-Games>. § "Neural Networks: A Requirement for Intelligent Systems. " N. p. , 2007. Web. 25 Feb. 2013. <http: //www. learnartificialneuralnetworks. com/#training>. § "Short Term Decision Making with Fuzzy Logic And Long Term Decision Making with Neural Networks In Real-Time Strategy Games. " Hevi. info. N. p. , n. d. Web. 25 Feb. 2013. <http: //www. hevi. info/tag/artificial-intelligence-in-real-time-strategy-games/>. 44
Videos § Fuzzy Logic http: //www. youtube. com/watch? feature=player_detailpage&v=P 8 w. Y 6 mi 1 v. V 8 #t=117 s § Sim. City http: //www. youtube. com/watch? feature=player_detailpage&list=UUnje_8 il. XP 7 KB 2 vdssy. AWug&v=Mx. Tcm 1 YFKc. U#t=37 s 45
QUESTIONS? 46