CSE 380 – Computer Game Programming Artificial Intelligence Murloc, Blizzard Entertainment.

Slides:



Advertisements
Similar presentations
Approaches, Tools, and Applications Islam A. El-Shaarawy Shoubra Faculty of Eng.
Advertisements

Chapter 09 AI techniques in different game genres (Puzzle/Card/Shooting)
Artificial Intelligence 12. Two Layer ANNs
Heuristics, and what to do if you dont know what to do Carl Hultquist.
Heuristic Search techniques
AI Pathfinding Representing the Search Space
Artificial Intelligence 13. Multi-Layer ANNs Course V231 Department of Computing Imperial College © Simon Colton.
Sensor Based Planners Bug algorithms.
Flocking and more.  NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees?
CSE 380 – Computer Game Programming Pathfinding AI
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
Artificial Intelligence in Game Design Introduction to Learning.
Artificial Intelligence in Game Design Hierarchical Finite State Machines.
CS 4730 Game AI CS 4730 – Computer Game Design Some slides courtesy Tiffany Barnes, NCSU.
And Just Games etc.. EVOLUTION OF COMPUTER GAMES PongOdyssey Beginning of the use of microprocessors ATARI VCS system bit.
Ant Colony Optimization Optimisation Methods. Overview.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Chapter 3: Methods of Inference Expert Systems: Principles and Programming, Fourth Edition.
CHAPTER 15 Artificial Intelligence © 2008 Cengage Learning EMEA.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Chapter 2: Algorithm Discovery and Design
Neural Networks Slides by Megan Vasta. Neural Networks Biological approach to AI Developed in 1943 Comprised of one or more layers of neurons Several.
CORE MECHANICS. WHAT ARE CORE MECHANICS? Core mechanics are the heart of a game; they generate the gameplay and implement the rules. Formal definition:
CSE 380 – Computer Game Programming AI & Collision Strategy Erin Catto’s Box2D.
CHAPTER 12 ADVANCED INTELLIGENT SYSTEMS © 2005 Prentice Hall, Decision Support Systems and Intelligent Systems, 7th Edition, Turban, Aronson, and Liang.
MAKING COMPLEX DEClSlONS
Artificial Intelligence in Game Design Problems and Goals.
Chapter 14: Artificial Intelligence Invitation to Computer Science, C++ Version, Third Edition.
CSE 380 – Computer Game Programming Sprite Animation
Survey of AI for games. AI vs. AI for games Traditional AI: – Made to handle unseen inputs, large state space – Too many options possible to compute an.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
Au’15 select topics By: Matt Boggus. List o’ stuff Game genres Party minigames Arena first person shooter 3D platformer/puzzler Horror Game technology.
Jorge Munoz, German Gutierrez, Araceli Sanchis Presented by: Itay Bittan.
Fundamentals of Game Design, 2 nd Edition by Ernest Adams Chapter 10: Core Mechanics.
Swarm Intelligence 虞台文.
NEURAL NETWORKS FOR DATA MINING
For games. 1. Control  Controllers for robotic applications.  Robot’s sensory system provides inputs and output sends the responses to the robot’s motor.
Artificial Intelligence in Game Design Lecture 6: Fuzzy Logic and Fuzzy State Machines.
CS 415 – A.I. Slide Set 5. Chapter 3 Structures and Strategies for State Space Search – Predicate Calculus: provides a means of describing objects and.
Chapter 1 Introduction to Game AI April 11,
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
I Robot.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
1 AI and Game Programming CIS 487/587 Bruce R. Maxim UM-Dearborn.
Computational theory techniques in interactive video games.
Tetris Agent Optimization Using Harmony Search Algorithm
AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate.
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
Artificial Intelligence in Game Design Influence Maps and Decision Making.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Minds and Computers Discovering the nature of intelligence by studying intelligence in all its forms: human and machine Artificial intelligence (A.I.)
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
AI Overview Logical and Artificial Intelligence in Games Lecture 1.
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
The Game Development Process: Artificial Intelligence.
Artificial Intelligence
George Yauneridge.  Machine learning basics  Types of learning algorithms  Genetic algorithm basics  Applications and the future of genetic algorithms.
Chapter 3: Methods of Inference
CS 134 Video Game “AI”.
Done Done Course Overview What is AI? What are the Major Challenges?
Enemy and Friendly AIs Richard Gesick.
Chapter 3: Methods of Inference
metaheuristic methods and their applications
CIS 488/588 Bruce R. Maxim UM-Dearborn
Metaheuristic methods and their applications. Optimization Problems Strategies for Solving NP-hard Optimization Problems What is a Metaheuristic Method?
Guest Lecture by David Johnston
For loops Taken from notes by Dr. Neil Moore
Presentation transcript:

CSE 380 – Computer Game Programming Artificial Intelligence Murloc, Blizzard Entertainment

Artificial Intelligence Can a computer “think”? Can it process info in a fashion similar to humans? How do we make creatures “appear” to think? –We only want creatures intelligent enough The ultimate AI game – massively multiplayer The ultimate stupid programmer: –Press Your Luck – beaten by contestant Michael Larson

Remember Our Infrastructure AnimatedSprite CollidableObject AnimatedSpriteTypeSpriteManager GameStateManager PhysicalProperties BoundingVolume * * * 1 1 Bot 1 1

Bot.h class Bot : public AnimatedSprite { public: Bot(){} ~Bot(){} // TO BE DEFINED BY BOT AI CLASSES virtual void think(Game *game)=0; virtual Bot* clone()=0; };

BotRecycler? class BotRecycler {private: map *> recyclableBots; map registeredBotTypes; public: BotRecycler(); ~BotRecycler(); void addMoreBots(list *botsNeededList, wstring botType, unsigned int numToAdd); void initRecyclableBots(wstring botType, unsigned int maxBotsNeeded); bool isRegisteredBotType(wstring botType); void recycleBot(wstring botType, Bot* botToRecycle); void registerBotType(wstring botType, Bot *sampleBot); Bot* retrieveBot(wstring botType); };

Deterministic AI Algorithms Behaviors that are predetermined or preprogrammed –Objects may follow a straight course Asteroids –Random Motion Good for modeling things like insects –Periodically (not every loop iteration), pick random direction & velocity for object(s) –Weight probability in a particular direction for the wind –Tracking Algorithms Takes into consideration the position of object being tracked –Change path directly toward object, OR –More realistically, gradually change path toward object

Direct Tracking Algorithm Direct Tracking – like the terminator Example: if (player.x > monster.x) monster.vX = MAX_V; if (player.x < monster.x) monster.vX = -MAX_V; if (player.y > monster.y) monster.vY = MAX_V; if (player.y < monster.y) monster.vY = -MAX_V; Not very realistic because tracking is so precise

Trajectory Vector Tracking Gradually change the path toward the target 1.Compute the vector from the tracker to the target TV = (target.x-tracker.x, target.y-tracker.y) = (tvx,tvy) Normalize: (tvx,tvy)/Vector_Length(tvx,tvy) Now max length is 1.0 (remember physics?) 2.Adjust the current velocity vector of the tracker by adding TV* scaled by a rate of your choice tracker.vx += rate*tvx; tracker.vy += rate*tvy; 3.If velocity has overflowed a maximum rate, slow it down

Patterns & Basic Control Scripting Creatures perform a series of actions in a particular order Motion Control Patterns –Used in Space Invaders, Galaxian, Phoenix, etc … –Create a pattern instruction set, like: #define GO_FORWARD 1 #define GO_BACKWARD 2 #define TURN_RIGHT_90 3 #define TURN_LEFT_90 4 #define SELECT_RANDOM_DIRECTION 5 #define STOP 6 –Use another operand to keep track of how long to do each action –Use an array to store the order for a pattern

Pattern Example Globals: int num_instructions = 6; int square_stop_spin[1, 30, 3, 1, 1, 30, 3, 1, 1, 30, 3, 1, 1, 30, 6, 60, 4, 8]; During Game Play: int instruction_ptr = 0; int cycles = spare_stop_spin[instruction_ptr+1]; switch(square_stop_spin[instruction_ptr]) { case GO_FORWARD: //move creature forward … } instruction_ptr += 2 if (instruction_ptr > num_instructions*2) // sequence over, perhaps do again

Improving on Patterns Make sure you provide feedback control to your pattern engine so your monster doesn’t do anything illegal –No collisions, going off screen, etc … Patterns with Conditional Logic Processing –You can choose from a number of patterns randomly –To make the AI smarter, choose a pattern based on the current game conditions Test for distance to player, when the player gets closer, change the monster pattern

Behavioral State Systems To create a Finite State Machine (FSM), you need: –A reasonable number of states, each which represents a different goal or motive Example Monster states: –Move forward, move backward, turn, stop, fire weapon, chase player, evade player –A single state may itself have multiple sub-states –Lots of input to the FSM, such as the state of the environment & the other objects within the environment Continually update the monster so they are behaving on the latest state –You can model aggression, curiosity, stupidity, etc …

Elementary State Machines Create a master brain that deals with high level states, which then get translated down to lower states Ex: High-level creature behavior states may be: –Attack, retreat, move randomly, stop, look for something, select a pattern & follow it For last state, a pattern processor selects a pattern of behavior for the creature based on environment

ESM Example switch(creature_state) { case STATE_ATTACK: // attack logic case STATE_RETREAT: // retreat logic … case STATE_PATTERN: Process_Pattern(); } creature_state = rand()%6; We could give more personality to monster by creating a distribution of behavior. Ex: StateGoomba p(x)Koopa p(x) ATTACK50%15% RETREAT20%40% STOP5%45% RANDOM25%5%

Modeling Memory & Learning So far our creatures think on-the-fly Creatures can learn from past experiences (if you want them to) –Don’t fall for the same player moves –Creatures searching for something may remember where they’ve been –Many game programmers like to use bit strings or vectors to memorize data

Planning & Decision Trees Planning is high-level AI –Using a high-level set of actions that are carried out to arrive at a goal –There may be conditionals that must be satisfied before any particular action can be carried out Production rules can be used in decision tree: if x1 op y1 false true if x2 op y2 false true if x3 op y3 false true if x4 op y4 false true if x5 op y5 false true

Decision Tree Example Conditions If the player is close and damage is low –Then fire at player If the player is far and fuel is high –Then search for player If damage is high and player is close –Then evade player If damage is high and ammo is 0 and player is close –Then self destruct You may want to define structures that specifically represent decisions to be made

Pathfinding In our earlier example, there were no obstacles for vectoring If there are obstacles, things get complicated Resolutions –Trial and error – if a collision occurs, back-up the monster, turn it 45 degrees and try again –Contour Tracing – trace the contour of the object that’s blocking the path –Collision Avoidance Tracks – create virtual tracks around objects that trace out a fairly intelligent path The path can be computed algorithmically using a shortest-path algorithm –Waypoint Pathfinding – for complicated world with many obstacles, setup a network of paths Creatures only need to find their way to nodes, which are then connected via paths All sorts of CSE 373 & AMS 301 algorithms could be used for finding shortest paths

Advanced AI Techniques Advanced AI Scripting –Examples: QUAKE C, UNREAL Script Allow you to program game code with a high-level English-like language that is processed by the engine –You may define your own scripting language A model of the human brain –Brain has billion brain cells, on which end are you? Genetic Algorithms –A method of computing that relies on biological models to evolve solutions Fuzzy Logic –Making deductions about fuzzy set theory –Analyzing sets of data such that the elements of the sets have partial inclusion (objects are partially in a set)

Basic Guidelines for AI Objects with simple behaviors (rocks, missiles, etc …) –Use Deterministic AI Objects that are supposed to be smart, but are part of the environment rather than the main action (birds that fly around, a space ship passing by, etc …) –Use deterministic AI coupled with patterns & randomness For important game characters that interact with the player –Use FSM coupled with other supporting techniques like personality distributions Main characters should be very smart –Should be state-driven –Use conditional logic, probability, & memory for controlling state transitions