Artificial Intelligence in Game Development Yingcai Xiao Artificial
- Slides: 49
Artificial Intelligence in Game Development Yingcai Xiao
Artificial Intelligence in Game Development Non-player character (NPC) / non-person character / non-playable character: any game character that is not controlled by a player, is usually controlled by AI. AI in games controls NPCs to simulate intelligence behavior.
Examples First AI games created in 1951. NIM and Checker Pac-Man (1980) added personalities to enemies. https: //www. youtube. com/watch? v=x 4 tq. Mv 0 Cv. TQ Garry Kasparov defeated by IBM's Deep Blue computer in 1997 https: //www. youtube. com/watch? v=_Y 9 hri. Lyl. Io
IBM Watson Interaction with Natural Language Jeopardy https: //www. youtube. com/watch? v=WFR 3 l. Om_xh. E API http: //www. ibm. com/smarterplanet/us/en/ibmwatson/? lnk=buwa Cloud http: //www. ibm. com/smarterplanet/us/en/ibmwatson/watsoncloud. html
Examples • Halo: Intelligent aliens will retreat after their leader killed. (Jobs) • Sims: smart objects that can go hungry, bored, tired, . . . • Techno. Sphere: an online digital environment where users from around the globe could create creatures and release them into. • Black & White: belief-desire-intention, god overseeing little people.
AI Algorithms
AI Algorithms • LOS (line of sight): avoid of being shot. • Graph Theory and Routing: maze games. • BF/DF Searching Algorithms: board games. • FSM (Finite State Machine): state of mined games.
AI Algorithms • Genetic Algorithms: evolutionary computing based on adaptation and survival. http: //www. biomanbio. com/Gamesand. Labs/Genegames/genetics. html http: //www. biomanbio. com/Gamesand. Labs/Cellgames/s. Cell. Explorer. Animal. Cell. html (Arrow keys to move, “s” to shoot an object for explanation. )
AI Algorithms • Decision Trees: hierarchical graph to make decisions based on conditions. • Fuzzy Logic: make decisions based on vague information.
John von Neumann (The Martians) Computer Architecture https: //en. wikipedia. org/wiki/Von_Neumann_architecture Game Theory https: //en. wikipedia. org/wiki/Game_theory
AI Algorithms • Cellular Automata: a grid of cells with each cell value being updated constantly by its neighbor’s values. • Game of Life • Stephen Wolfram • Wolfram Alpha
Alpha. Go • Alpha. Go: a game engine that plays the Go game. • Go: a Chinese board game of strategies. 19 x 19, 361!, 10761 (total number of fundamental particles in the observable universe: 1085). • The first computer program to beat a professional Go player (4: 1, March 8 -15, 2016).
Alpha. Go Zero • Alpha. Go: learns from past human games. • Alpha. Go Zero: learns by itself. • Alpha. Go Zero won Alpha. Go 100: 0
Flocking
Flocking • Flocking: crowd behaviors. • Starling murmuration: https: //www. youtube. com/watch? v=eak. Kf. Y 5 a. Hm. Y • Reynolds, Craig W. (1987). "Flocks, herds and schools: A distributed behavioral model. ". ACM SIGGRAPH Computer Graphics 21 (4). pp. 25– 34. • Batman Returns (1992): flocking bats and The Lion King (1994): wildebeest stampede.
Flocking • Craig Reynolds: http: //www. red 3 d. com/cwr/ • Reynolds, Craig W. (1987). "Flocks, herds and schools: A distributed behavioral model. ". ACM SIGGRAPH Computer Graphics 21 (4). pp. 25– 34. • Authored the Open Steer library • Won 1998 Academy Scientific and Technical Award for pioneering contributions to 3 D computer animation for movies. • Uses procedural models to simulate complex natural phenomenon.
The Flocking Algorithm • The algorithm • Implementation in Unity 3 D • Building a Unity package for reuse • Building a flocking library in a game engine
The Flocking Algorithm • Craig Reynolds’ Boids: artificial objects follow natural flocking behavior • Unity Implementation: http: //black-square. github. io/Bird. Flock/ • Java. Script implementation: http: //gpolo. github. io/birdflocking/ • Open. GL implementation: http: //www. navgen. com/3 d_boids/
The Flocking Algorithm • http: //www. vergenet. net/~conrad/boids/pseudocode. html • Unity Code Explanation: http: //wiki. unity 3 d. com/index. php? title=Flocking
The Flocking Algorithm • Craig Reynolds’ Boids: artificial objects flow natural flocking behavior. • 3 Basic Rules: cohesion - to move toward the center of the mass of the flockmates separation - to avoid flockmates alignment – to steer towards the flock direction
Implementing Flocking
The Flocking Algorithm • Craig Reynolds’ Boids: artificial objects flow natural flocking behavior. • 3 Basic Rules: cohesion - to move toward the center of the mass of the flockmates separation - to avoid flockmates alignment – to steer towards the flock direction http: //www. vergenet. net/~conrad/boids/pseudocode. html
EDP Game Development Event Loop Event Mapping & Event Dispatching init_game(); while(!done) { e = get_event() Event switch(e) { case “p”: change_game_parameters( ); break; … Event Handler default: display_game_objects(); compute_next_frame(); } }
EDP Game Development Event Loop Event Mapping & Event Dispatching init_game(); while(!done) { e = get_event() Event switch(e) { case “p”: change_game_parameters( ); break; … Event Handler default: compute_next_frame(); display_game_objects(); } }
EDP Game Development Event Loop Event Mapping & Event Dispatching init_game(); create_boids(); while(!done) { e = get_event() Event switch(e) { case “p”: change_game_parameters( ); break; … Event Handler default: compute_Co. M_AV(); compute_boid_velocity(); display_boids(); }
Flocking Code C# code at http: //wiki. unity 3 d. com/index. php? title=Flocking (1) Create the flock at the Biod. Controller: : Start() boids //all (1) Update animation parameters in Biod. Controller: : Update () //all boids (2) Control the animation in Boid. Flocking: : Boid. Steering () //each
Flocking Code (1) Create the flock at the Start() • Flock Size • Boids Array • Position • Direction
Flocking Code (1) Create the flock at the Start() • Bounding box • Global and local transformation • The Controller
Flocking Code (2) Update animation parameters in Update () • Center of Mass • Average Direction • The Controller
Flocking Code (3) Control the animation in Boid. Flocking: : Boid. Steering () • This is the script for each boid. • Separation is taking care of by rigidbody. • Cohesion is to follow the Co. M. • Alignment is to follow the Average Direction
PA 3 Coding / Flocking http: //www. cs. uakron. edu/~xiao/game/igd 3. htm Theory / Rules: cohesion - to move toward the center of the mass of the flockmates separation - to avoid flockmates alignment – to steer towards the flock direction
PA 3 Coding / Flocking The Example: Holistic Game Development with Unity By: Penny de Byl http: //proquest. safaribooksonline. com/book/programming/ga me-programming/9780240819334 Section 5. 6: a flock of seagulls flying against wind in small groups. http: //proquest. safaribooksonline. com/book/programming/ga me-programming/9780240819334/chapter-5 -charactermechanics/ch 5_6_006_9780240819341_web_ch 05_html
Sorting and Searching in Game Development
Why? Tic Tac Toe 1 2 3 4 5 6 7 8 9 9! = 362880
Sorting & Searching • S&S needed to develop AI games to find optimal strategies, paths, in the game logic. • The main challenge is the huge size of the search tree. The number of branches in the search tree of a 19 x 19 Go board game is larger than the number of atoms in the known universe. • The key of success is to reduce the search space but not the optimal solutions.
Sorting • Sorting the search space can make searches faster. • Sorting can be used to prioritize the search space. • Weights can be added to reflect heuristic information.
Basic Sorting Algorithms • Sorting Algorithm Animations http: //www. sorting-algorithms. com/ https: //www. cs. usfca. edu/~galles/visualization/Comparis on. Sort. html https: //www. youtube. com/watch? v=a. XXWXz 5 r. F 64 • Wiki listing https: //en. wikipedia. org/wiki/Sorting_algorithm
Searching • Basic searching • Statistical searching • Searching for globally optimal solutions
Basic Searching Algorithms Code Listing https: //users. dcc. uchile. cl/~rbaeza/handbook/search_a. html Comparisons http: //bigocheatsheet. com/ http: //research. cs. queensu. ca/home/cisc 121/2006 s/webnotes/search. html Example: How many steps are needed to find the one over-weighted golf ball among the eight of them using just a scale.
Search-based Board Games
Alpha. Go • Alpha. Go: a game engine that plays the Go game. • Go: a Chinese board game of strategies. 19 x 19, 361!, 10761 (total number of fundamental particles in the observable universe: 1085). • The first computer program to beat a professional Go player (4: 1, March 8 -15, 2016).
Statistical Searching Algorithms https: //en. wikipedia. org/wiki/Monte_Carlo_tree_search “The focus of Monte Carlo tree search (MCTS) is on the analysis of the most promising moves, expanding the search tree based on random sampling of the search space. The application of Monte Carlo tree search in games is based on many playouts. In each playout, the game is played-out to the very end by selecting moves at random. The final game result of each playout is then used to weight the nodes in the game tree so that better nodes are more likely to be chosen in future playouts” https: //en. wikipedia. org/wiki/Search_tree https: //en. wikipedia. org/wiki/Monte_Carlo_method#History https: //en. wikipedia. org/wiki/Monte_Carlo_Casino
MCTS https: //commons. wikimedia. org/wiki/File: MCTS_(English). svg#/media/File: MCTS_(English). svg
MCTS “Four steps: • Selection: start from root R and select successive child nodes down to a leaf node L. The section below says more about a way of choosing child nodes that lets the game tree expand towards most promising moves, which is the essence of Monte Carlo tree search. • Expansion: unless L ends the game with a win/loss for either player, either create one or more child nodes or choose from them node C. • Simulation: play a random playout from node C. • Backpropagation: use the result of the playout to update information in the nodes on the path from C to R. ”
Alpha. Go Algorithms • Based on tree searches and neural networks that can learn. • Policy Network: only consider a few promising positions (limit the breadth of the search tree. ) • Value Network: only consider a few steps deep (limit the depth of the search tree).
Alpha. Go Zero • Alpha. Go: learns from past human games. • Alpha. Go Zero: learns by itself. • Alpha. Go Zero won Alpha. Go 100: 0
Globally Optimal Solutions “Simulated annealing (SA) is a probabilistic technique for approximating the global optimum of a given function. Specifically, it is a metaheuristic to approximate global optimization in a large search space” “for problems where finding the precise global optimum is less important than finding an acceptable local optimum in a fixed amount of time, simulated annealing may be preferable to alternatives such as brute-force search or gradient descent. ” https: //en. wikipedia. org/wiki/Simulated_annealing
Globally Optimal Solutions Let s = s 0 For k = 0 through kmax (exclusive): l T ← temperature(k ∕ kmax) l Pick a random neighbor, snew ← neighbor(s) l If P(E(s), E(snew), T) ≥ random(0, 1), move to the new state: – s ← snew Output: the final state s https: //en. wikipedia. org/wiki/Simulated_annealing
Resources http: //AIGame. Dev. com http: //www. Game. AI. com https: //deepmind. com/ https: //www. tensorflow. org/ https: //research. google. com/teams/brain/ https: //en. wikipedia. org/wiki/List_of_artificia l_intelligence_projects https: //www. datamation. com/opensource/slideshows/15 -top-open-sourceartificial-intelligence-tools. html
- Xiao video game
- Xiao game
- Mycin expert system architecture
- Prolog iterative deepening search
- Searching for solutions in artificial intelligence
- 15-780 graduate artificial intelligence
- Knowledge manipulation in ai
- What is meta knowledge in artificial intelligence
- Vandelay art. seinfeld the show about nothing. penguin 1997
- Kecerdasan kepemimpinan
- Artificial intelligence assessment
- Math for artificial intelligence
- Peas for interactive english tutor
- 15-780 graduate artificial intelligence
- Xkcd deep learning
- Number of fuzzy propositions
- Cse 471 asu
- 15 780
- Informed search and uninformed search
- What is artificial intelligence class 6
- Levels of language analysis
- Omniscience in artificial intelligence
- Int 404
- Searching for solutions in artificial intelligence
- Partitioned semantic nets in artificial intelligence
- Ao* algorithm in artificial intelligence
- Artificial intelligence thesis proposals
- Rule based deduction system in artificial intelligence
- Inference by enumeration in artificial intelligence
- Learning in ai
- Ucs
- Pxdes expert system
- Optimal decisions in games in artificial intelligence
- Andrew ng hbr
- Cs 188
- Optimal decisions in games in artificial intelligence
- Athena machine learning
- Artificial intelligence operating system
- Inference in first order logic in artificial intelligence
- Ai is a branch of computer science
- Mobedic
- Conclusion of artificial intelligence
- Artificial intelligence applications institute
- Difference between informed and uninformed search
- 15-780 graduate artificial intelligence
- Ethics of artificial intelligence
- Agent in artificial intelligence
- Fundamentals of artificial intelligence
- Csci-b 551 elements of artificial intelligence
- Inference by enumeration in artificial intelligence