390 likes | 520 Views
GAME AI. CS3540 Game Programming. “Real” AI versus Game AI. Trend toward being increasingly more complex Focused on solving more nebulous problems. Efficiency: Games can only spend a fraction of their total time on AI Typically have well-defined requirements or behavior. But….
E N D
GAME AI CS3540 Game Programming
“Real” AI versus Game AI • Trend toward being increasingly more complex • Focused on solving more nebulous problems • Efficiency: Games can only spend a fraction of their total time on AI • Typically have well-defined requirements or behavior But… Game Programming Algorithms and Techniques by Sanjay Madhav
Human-level AI's Killer Application: Interactive Computer Games John E. Laird and Michael van Lent Abstract Although one of the fundamental goals of AI is to understand and develop intelligent systems that have all of the capabilities of humans, there is little active research directly pursuing that goal. We propose that AI for interactive computer games is an emerging application area in which this goal of human-level AI can successfully be pursued. Interactive computer games have increasingly complex and realistic worlds and increasingly complex and intelligent computer-controlled characters. In this paper, we further motivate our proposal of using interactive computer games, review previous research on AI and games, and present the different game genres and the roles that human- level AI could play within these genres. We then describe the research issues and AI techniques that are relevant to each of these roles. Our conclusion is that interactive computer games provide a rich environment for incremental research on human-level AI. Human-level AI's Killer Application: Interactive Computer Games John E. Laird and Michael van Lent AAAI 2001 See http://ai.eecs.umich.edu/people/laird/games_research.html
Human-level AI “[Human-level AI systems] seamlessly integrate all the human-level capabilities: real-time response, robust, autonomous intelligent interaction with their environment, planning, communication with natural language, common sense reasoning, creativity, and learning.” --Laird and van Lent HAL 9000 http://memory-beta.wikia.com/wiki/Data https://en.wikipedia.org/wiki/HAL_9000 https://en.wikipedia.org/wiki/R2-D2
How good were Laird and van Lent at predicting the future? They wrote their paper in 2000. Check out the quotes in the following slides and see how good they were at predicting what games would be like fifteen-plus years later.
Do computer games “need”human-level AI? “The thesis of this paper is that interactive computer games are the killer application for human-level AI. They are the application that will soon need human-level AI, and they can provide the environments for research on the right kinds of problems that lead to the type of the incremental and integrative research needed to achieve human-level AI.” --Laird and van Lent
Has this happened? Computer games need help from academic AI. The current emphasis in computer game AI is on the illusion of human-like behavior for very limited situations. Thus, most, if not all, of the current techniques that are used for controlling game AIs (such as big C functions or finite-state machines) will not scale up. However, just as computer game graphics and physics have moved to more and more realistic modeling of the physical world, we expect that game developers will be forced into more and more realistic modeling of human characters. Moreover, as researchers we can get a step ahead of the game designers by using their environments for research on human-level AI. --Laird and van Lent
Roles of AI in Games • Tactical Enemies • Partners • Support Characters • Strategic Opponents • Units • Commentators Human-level AI's Killer Application: Interactive Computer Games John E. Laird and Michael van Lent AAAI 2001 See http://ai.eecs.umich.edu/people/laird/games_research.html
Tactical Enemies In these early games, the enemies were made more challenging, not with improved intelligence, but with bigger guns, tougher hides, and superior numbers. They also usually “cheated” by being able to see through walls or out of the back of their heads. --Laird and van Lent How well do current games do in this area? What are the tradeoffs between better A.I. and these tricks? (superior numbers, cheating, and so on)
Partners How well do current games do in this area? What is the danger in making partners too good? Elizabeth from Bioshock Infinite by Irrational Games http://bioshock.wikia.com/wiki/Elizabeth
Support Characters Support characters are usually some of the least sophisticated AI characters in computer games, but they have the most promise to improve games and are the most interesting in terms of developing human-level AI. --Laird and van Lent Really? What are examples of support characters? Would anyone care (or notice) if these characters were smarter?
Strategic Opponents When creating strategic opponents for strategy games and team sports games, most game developers have had to resort to “cheating” to make the opponent challenging. Often strategic opponents are given extra units or resources, additional information about the map or the human player's position, or they play the game by a different set of rules. Even with these advantages, most strategic opponents are predictable and easily beaten once their weaknesses are found. --Laird and van Lent Are A.I. strategic opponents important for multiplayer games?
Strategic Opponents • Planning • Common sense reasoning • Spatial reasoning • Plan recognition and counter planning • Scheduling • Temporal reasoning
Strategic Opponents One of the most important aspects of strategy creation is the coordination of multiple types of units into a cohesive strategy. --Laird and van Lent How important are these issues? How can they be addressed? Controlling a large force of units with only a single mouse is a significant part of the challenge for human players. --Laird and van Lent
Units • Path planning and following • Common sense reasoning • Coordination with other units A platoon of marines moving from one position to another should not ignore an enemy tank. Instead they should autonomously choose to attack if appropriate or else find a new path. --Laird and van Lent
Units Since there can be hundreds of units active in a game at one time, the issues of computational and memory overhead are particularly important for unit AI. --Laird and van Lent
Commentator • Sports games (team and individual) • Some action games (Unreal Tournament) • And, of course…
Commentator:Pokemon Stadium • "Taken down on the word go!" • "We might be in for a one-sided affair." • "There's no fighting back while you're frozen." • "DOOOOWWWNNNNN! The level disadvantage is obvious!" • "WAAH! Taken down with one hit!" • "Here it comes...THUNDER!" • "GROOOUUNNNND ZERO!" • "That hit just the right spot!" • "Being ice-bound will make this a one sided fight!" • "The finishing blow?" "OUTTA THERE!" • "Oh, that Pokémon was handled easily!" • "Neither combatant is showing signs of fatigue yet!" • "Hang on, EARTHQUAKE!" https://www.reddit.com/r/pokemon/comments/h50t7/how_many_quotes_do_the_stadium_and_stadium_2/
Story Director "One of the Holy Grails of interactive fiction is to have a computer director who can dynamically adjust the story and plot based on the actions of the human.” --Laird and van Lent
Left 4 Dead director • Use “emotional intensity” to adjust dramatic pacing • Increase intensity value when characters take damage, are incapacitated, etc. https://steamcdn-a.akamaihd.net/apps/valve/2009/ai_systems_of_l4d_mike_booth.pdf
Game AI Techniques • Pathfinding • State-Based Behaviors • Strategy and Planning
Pathfinding Getting from one point to another For an excellent, interactive tutorial on pathfinding and A* see http://www.redblobgames.com/pathfinding/a-star/introduction.html by Amit Patel. Image from http://www.redblobgames.com/pathfinding/a-star/introduction.html by Amit Patel
Beyond Pathfinding “Strategic and Tactical Reasoning with Waypoints” by Lars Liden “An effective technique is to store connectivity and visibility information in a bit string class that consists of a string of bits of arbitrary length with operators for Boolean operations such as <and>, <or> and <not>.” See https://sites.google.com/site/larsliden/publications/Downloads
Using visibility “Furthermore, with a little extra work, the node-graph can be used to generate static visibility information between nodes. Pre-calculating whether one waypoint has line-of- sight to another allows for fast run-time evaluation of map locations.” --Lars Liden, “Strategic and Tactical Reasoning with Waypoints” Safe and danger nodes Figure 1 from “Strategic and Tactical Reasoning with Waypoints” by Lars Liden
Intelligent Attack Positioning “…find a location from which the NPC can attack a particular enemy that also protects it from simultaneous attack by other enemies.” --Lars Liden, “Strategic and Tactical Reasoning with Waypoints” Figure 2 from “Strategic and Tactical Reasoning with Waypoints” by Lars Liden
Unity navigation: NavMesh Window -> Navigation or Window -> AI -> Navigation https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html
NavMesh bake https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html
NavMesh agent https://docs.unity3d.com/Manual/nav-CreateNavMeshAgent.html
State Machines Patrol Killed? Player found? Killed? Death Attack • Set number of possible states • Conditions that cause transitions to other states • Actions that can be executed upon entering/exiting the state Game Programming Algorithms and Techniques: A Platform-Agnostic Approach by Sanjay Madhav
State Machines Patrol Death See player Sound Nothing Killed (from any state) Investigate Alert See player 25% Lost player 75% Attack Alarm Complete Game Programming Algorithms and Techniques: A Platform-Agnostic Approach by Sanjay Madhav
State Machines • Low level and labor intensive • Complex and scale poorly • Not flexible • Limited logic • Not modular 10 Reasons the Age of Finite State Machines is Over by Alex J. Champandard http://aigamedev.com/open/article/fsm-age-is-over/
Planning Planning in Games: An Overview and Lessons Learned Alex J. Champandard-- March 8, 2013 http://aigamedev.com/open/review/planning-in-games/ • STRIPS-based planners • HTN-based planners • Behavior trees • Utility Systems
Goal-Oriented Action Planning (GOAP) FSM Planning • Procedural • Lots of connections between goals and actions • Declarative • Goals and actions are decoupled http://alumni.media.mit.edu/~jorkin/goap.html
GOAP states and actions • States: propositions or predicates • Actions: preconditions and effects Action: Order pizza Precondition: Have phone # Effect: hungry? = NO Action: Bake a pie Precondition: Have recipe Effect: hungry? = NO http://alumni.media.mit.edu/~jorkin/goap.html
ReGoap • GitHub project that implements Goal-oriented Action Planning (GOAP) in C# • Can be used with Unity • https://github.com/luxkun/ReGoap