Artificial Intelligence for Games Lecture 1 1 Minor Games Programming.

Slides:



Advertisements
Similar presentations
Heuristic Search techniques
Advertisements

Reactive and Potential Field Planners
7.2. AI E NGINE AND S TEERING B EHAVIOUR I Design of an AI Engine and introduction to steering in game AI.
AI Pathfinding Representing the Search Space
7.3. S TEERING B EHAVIOUR II Steering behaviours in game AI.
Comparing Effectiveness of Bioinspired Approaches to Search and Rescue Scenarios Emily Shaeffer and Shena Cao 4/28/2011Shaeffer and Cao- ESE 313.
Flocking and more.  NPC groups can move in cohesive groups not just independently ◦ Meadow of sheep grazing? ◦ Hunting flock of birds? ◦ Ants? Bees?
Steering Behaviors GAM 376 Robin Burke Winter 2008.
Flocking Behaviors Presented by Jyh-Ming Lien. Flocking System What is flocking system? – A system that simulates behaviors of accumulative objects (e.g.
Better Group Behaviors in Complex Environments using Global Roadmaps O. Burchan Bayazit, Jyh-Ming Lien and Nancy M. Amato Presented by Mohammad Irfan Rafiq.
Flocks, Herds, and Schools: A Distributed Behavioral Model By: Craig Reynolds Presented by: Stephanie Grosvenor.
1 CO Games Development 2 Week 22 Flocking Gareth Bellaby.
Optimizing Flocking Controllers using Gradient Descent
Florian Klein Flocking Cooperation with Limited Communication in Mobile Networks.
Kristen Gardner. Outline Swarm Intelligence Flocking Basic Steering Swarms Applications Animals Vehicles People.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Dynamic Path Planning, Flocking Spring 2012.
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
Artificial Intelligence in Game Design Introduction to Learning.
1 Reactive Pedestrian Path Following from Examples Ronald A. Metoyer Jessica K. Hodgins Presented by Stephen Allen.
1Notes  Assignment 2 is out  Flocking references  Reynolds, “Flocks, Herds, and Schools…”, SIGGRAPH’87  Tu and Terzopoulos, “Artificial Fishes…”, SIGGRAPH’94.
John S Gero Agents – Agent Simulations AGENT-BASED SIMULATIONS.
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Better Group Behaviors in Complex Environments using Global Roadmaps O. Burchan Bayazit, Jyh-Ming Lien and Nancy M. Amato Andreas Edlund.
CS274 Spring 01 Lecture 5 Copyright © Mark Meyer Lecture V Higher Level Motion Control CS274: Computer Animation and Simulation.
1cs426-winter-2008 Notes  Please read: C. Reynolds “Flocks, Herds, and Schools…” SIGGRAPH ‘87
Crowd Simulation Seminar ”Steering Behaviors For Autonomous Characters” By Craig W. Reynolds Rudi Bonfiglioli ( )
Steering Behaviors For Autonomous Characters
Intelligent Pac-Man Ghost AI
DAMN : A Distributed Architecture for Mobile Navigation Julio K. Rosenblatt Presented By: Chris Miles.
Games Programming III (TGP2281) – T1, 2010/2011 Movement AI John See 19, 26 Nov 2010.
Tactical AI in Real Time Supervisor: Aleks Jakulin Crew: Damir Arh, Matija Jekovec, Mitja Luštrek Gregor Leban, Martin Žnidaršič, Uroš Čibej Translation:
Crowd Simulations Guest Instructor - Stephen J. Guy.
Artificial Intelligence in Game Design Camera Control.
Yingcai Xiao Artificial Intelligence in Game Development Yingcai Xiao.
1 Constant Following Distance Simulations CS547 Final Project December 6, 1999 Jeremy Elson.
Artificial Intelligence in Game Design Problems and Goals.
Introduction GAM 376 Robin Burke Winter Outline Introductions Syllabus.
Flow Fields Hao Li and Howard Hamilton. Motivation for Flow Fields Multiple AI algorithms in a computer game can produce conflicting results. The AI must.
Artificial Intelligence in Game Design Lecture 6: Fuzzy Logic and Fuzzy State Machines.
Chapter 1 Introduction to Game AI April 11,
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
Adrian Treuille, Seth Cooper, Zoran Popović 2006 Walter Kerrebijn
Jumping, Climbing, and Tactical Reasoning Section 2.5 Tom Schaible CSE 497 – AI & Game Programming.
1 Game AI Steering Behavior & Group Movement ( 轉向行為 及 群體運動 )
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Controlling the Behavior of Swarm Systems Zachary Kurtz CMSC 601, 5/4/
Basic Steering of Game Agents Featuring Guest professors Stephen Sheneman & Michael Wilkens 1.
AI Evaluation David Nowell CIS 588 2/14/05 Baldur’s Gate.
Behavior Control of Virtual Vehicle
Particle Swarm Optimization † Spencer Vogel † This presentation contains cheesy graphics and animations and they will be awesome.
REFERENCES: FLOCKING.
CSC321 Lecture 5 Applying backpropagation to shape recognition Geoffrey Hinton.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Graph Search II GAM 376 Robin Burke. Outline Homework #3 Graph search review DFS, BFS A* search Iterative beam search IA* search Search in turn-based.
Simulating Crowds Simulating Dynamical Features of Escape Panic & Self-Organization Phenomena in Pedestrian Crowds Papers by Helbing.
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
Path Planning Based on Ant Colony Algorithm and Distributed Local Navigation for Multi-Robot Systems International Conference on Mechatronics and Automation.
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
11/13/03CS679 - Fall Copyright Univ. of Wisconsin Last Time A* Improvements Hierarchical planning Pre-Planning.
4/22/20031/28. 4/22/20031/28 Presentation Outline  Multiple Agents – An Introduction  How to build an ant robot  Self-Organization of Multiple Agents.
Computer Animation Algorithms and Techniques
Modelling and Simulating Social Systems with MATLAB
A theory on autonomous driving algorithms
Sony Computer Entertainment
Steering Behaviors GAM 376 Robin Burke Fall 2006.
CIS 488/588 Bruce R. Maxim UM-Dearborn
Steering behaviours in game AI
Robot Intelligence Kevin Warwick.
Hiroki Sayama NECSI Summer School 2008 Week 2: Complex Systems Modeling and Networks Agent-Based Models Hiroki Sayama
Presentation transcript:

Artificial Intelligence for Games Lecture 1 1 Minor Games Programming

2 Artificial Intelligence for Games Introduction to game AI (self study) Theory: Moving Game Agents Jan Verhoeven

Game AI Game AI is not a subset of AI Game AI ◦ often covers techniques that are not considered “AI-like” AI ◦ uses techniques impractical in a game context AI Game AI

What is Game AI? Analogy ◦ game AI is to "real" AI as ◦ stage design is to architecture The goal of game AI is to give the impression of intelligence ◦ to avoid the impression of stupidity ◦ to provide a reasonable challenge for the player

Challenge It is very possible to make the computer too smart ◦ think: driving game or a chess game The task of AI is to support the experience ◦ many compromises from “optimal” required

Not dumb It is surprisingly hard to make the computer not dumb ◦ “Why are computers so stupid?” ◦ especially with limited computational resources Example ◦ Humans are good at navigating complex 3-D environments ◦ Doing this efficiently is (still) an unsolved problem in AI

But Game AI is the future of games Many designers see AI as a key limitation ◦ the inability to model and use emotion ◦ the inability of games to adapt to user’s abilities ◦ the need for level designers to supply detailed guidance to game characters

8 Study book Literature: Mat Buckland Programming Game AI by Example

What we will cover Finite-state machines (Previous Knowledge !!) ◦ the most basic technique for implementing game AI ◦ fundamental to everything else Steering behaviors ◦ basic behaviors for avoiding stupidity while navigating the world Path planning ◦ the surprisingly tricky problem of getting from point A to point B Action planning ◦ assembling sequences of actions Fuzzy logic ◦ reasoning by degrees

10 Today's Theory: Moving Game Agents, (see study book: chapter 3) What is an Autonomous Agent? Steering Behaviors Group Behaviors Combining Steering Behaviors Spatial Partitioning Smoothing

11 Movement Two types ◦ Reactive movement ◦ Planned movement

Steering behaviors Tendencies of motion ◦ that produce useful (interesting, plausible, etc.) navigation activity ◦ by purely reactive means ◦ without extensive prediction Pioneering paper ◦ Reynolds, 1999

Examples I want the insect monsters to swarm at the player all at once, but not get in each other's way. I want the homing missile to track the ship and close in on it. I want the guards to wander around, but not get too far from the treasure and not too close to each other. I want pedestrians to cross the street, but avoid on- coming cars.

Steering behavior solution Write a mathematical rule ◦ that describes accelerations to be made ◦ in response to the state of the environment Example: "don't hit the wall" ◦ generate a backwards force inversely proportional to the proximity of the wall ◦ the closer you get, the more you will be pushed away ◦ if you're going really fast, you'll get closer to the wall, but you'll slow down smoothly

Combining forces Behaviors can be combined by ◦ summing the forces that they produce Example: follow ◦ I want the spy to follow the general, but not too close ◦ two behaviors  go to general's location  creates a force pointing in his direction  not too close  a counter-force inverse proportion to distance ◦ where the forces balance  is where spy will tend to stay

16 Steering Behaviors: Physics Model Simple Vehicle Model ◦ orientation, mass, position, velocity ◦ max_force, max_speed Forward Euler Integration ◦ steering_force = truncate (steering_dir, max_force) ◦ acceleration = steering_force / mass ◦ velocity = truncate (velocity + acceleration, max_speed) ◦ position = position + velocity Read Only Page

17 Steering Behaviors: Seek and Flee Seek – Steer toward goal Seek Flee – Steer away from goal Flee Steering force is the difference between current velocity and desired velocity ◦ Blue is steering force, magenta is velocity

18 Steering Behaviors: Pursue and Evade Based on underlying Seek and Flee Pursue – Predict future interception position of target and seek that point Pursue Evade – Use future prediction as target to flee from Evade (Another Chase and Evade demo)Chase and Evade

19 Steering Behaviors: Wander Wander Type of random steering with long term order ◦ Steering is related from one frame to another ◦ Maintains state Red dot is wander direction ◦ Constrained to be on black circle ◦ Randomly moves within white circle each frame

20 Steering Behaviors: Arrival Arrival Goal to arrive at target with zero velocity Red circle is maximum distance before slowing down

21 Steering Behaviors: Obstacle Avoidance Obstacle Avoidance Obstacle Avoidance White box is future path Steering force strictly left or right Braking force stronger as collision gets closer

Obstacle avoidance II Basic idea ◦ project a box forward in the direction of motion  think of the box as a "corridor of safety" ◦ as long as there are no obstacles in the box  motion forward is safe To do this ◦ find all of the objects that are nearby  too expensive to check everything ◦ ignore those that are behind you ◦ see if any of the obstacles overlap the box ◦ if none, charge ahead ◦ if several, find the closest one ◦ this is what we have to avoid

Obstacle avoidance III Steering force ◦ we want to turn away from the obstacle  just enough to miss it ◦ we want to slow down  so we have time to correct Need a steering force perpendicular* to the agent's heading ◦ proportional to how far the obstacle protrudes into the detection box Need a braking force anti-parallel to agent's heading ◦ proportional to our proximity to obstacle *

24 Steering Behaviors: Hide Hide attempts to position a vehicle so that an obstacle is always between itself and the agent (“the hunter”) it’s trying to hide from Hide

25 Steering Behaviors: Wall Following Move parallel and offset from gray areas Goal to remain given distance from wall ◦ Predict object’s future position (black dot) ◦ Project future position to wall ◦ Move out from wall set amount from normal ◦ Seek toward new point (red circle)

26 Steering Behaviors: Path Following Path Following Path Following Path is connected line segments with radius Corrective steering only when varying off of path ◦ Red dot future predicted position ◦ Red circle is closest spot on path ◦ Corrective steering toward white circle farther down path

27 Combined Steering Behaviors: Group Path Following Path following with separation steering ◦ Combined with weighted sum ◦ Path following has 3 times weight as separation

28 Combined Steering Behaviors: Leader Following (Group) Combines separation and arrival ◦ Arrival target is a point offset slightly behind the leader ◦ Followers must move out of leader’s future path

29 Combined Steering Behaviors: Leader Following (Queue) Combines separation and arrival ◦ Each object has a different leader

30 Combined Steering Behaviors: Unaligned Collision Avoidance Objects moving in all directions (unaligned) Combines containment and avoidance Future collisions predicted and objects steer away from collision site, or speed-up / slow-down

31 Combined Steering Behaviors: Queuing Seek doorway, Avoid gray walls, Separation from each other, Braking if others nearby or in front

32 Flocking

33 Flocking

34 Flocking

35 Flocking First demonstrated by Craig Reynolds in his 1987 SIGGRAPH paper and movie ◦ “Flocks, Herds, and Schools: A Distributed Behavior Model” ◦ Film (Stanley and Stella in "Breaking the Ice" Used to give flocks of birds and schools of fish eerily realistic movement Won an Oscar in 1997 for his flocking work ◦ (Scientific and Technical Award) Flocking is an example of emergent behavior (a-life) ◦ Simple individual rules result in complex group behavior ◦ Individual creatures often called “boids” PS2 technical demo OpenSteer demo

36 Flocking: Three simple rules Separation Alignment Cohesion

Separation "Don't crowd" Basic idea ◦ generate a force based on the proximity of each other agent ◦ sum all of the vectors Result ◦ Each agent will move in the distance that takes it furthest from others ◦ Neighbors disperse from each other

Alignment "Stay in step" Basic idea ◦ keep an agent's heading aligned with its neighbors ◦ calculate the average heading and go that way Result ◦ the group moves in the same direction

Cohesion "Stay together" Basic idea ◦ opposite of separation ◦ generate a force towards the center of mass of neighbors Result ◦ group stays together

Combining these behaviors We get flocking ◦ different weights and parameters yield different effects animation demo

Implementation issues Combining behaviors ◦ each steering behavior outputs a force ◦ it is possible for the total force to exceed what an agent's acceleration capacity What to do?

Combination methods Simplest: Weighted truncated sum, ◦ weight the behaviors, add up, and truncate at max_force ◦ very tricky to get the weights right ◦ must do all of the calculations Better: Prioritization ◦ Evaluate behaviors in a predefined order  obstacle avoidance first  wander last ◦ Keep evaluating and adding until max_force reached ◦ Problem is getting the fixed priority right Cheaper: Prioritized dithering ◦ Associate a probability with each behavior  probabilities sum to 1 ◦ That behavior will get its force applied a certain percentage of the time

Partitioning We want to calculate the neighbors of each agent ◦ if we look at all agents, n 2 operation ◦ if there are many, many agents, too slow Many techniques for speeding this up ◦ basic idea is to consider only those agents that could be neighbors ◦ carve up space and just look at the relevant bits Very important in other parts of game programming, too ◦ collision detection ◦ view rendering

Cell-space partition Cover space with a grid Maintain a list of agents in each cell ◦ not that expensive since it is just an x,y threshold test Calculate which grid cells could contain neighbors ◦ check only those agents in the effected cells ◦ O(n)

Smoothing Jitter occurs when behaviors switch in and out ◦ obstacle avoidance kicks in when objects is in detection box ◦ but other behaviors push back towards obstacle Solution ◦ average the heading over several updates Read study book for a solution or take notice of:

46 Alternative to Flocking: Simple Swarms Computationally simpler Doesn’t enforce separation or interpenetration Example ◦ Hundreds of spiders crawling around, up walls, and dropping from the ceiling – Tom Scutt, Tomb Raider series

47 Simple Swarms attacking Player Outer zone ◦ If heading toward player: waver heading ◦ If heading away: steer toward player Inner zone ◦ Swirl around player Flee after random amount of time

48 Swarm Intelligence Technique based on collective behavior in decentralized, self-organized systems ◦ Beni & Wang (1989) Simple agents interact locally Global behavior emerges ◦ Ant colonies ◦ Bird flocking ◦ Animal herding Swarm Robotics ◦ Combining swarm intelligence with robotics

49 Formations Mimics military formations How is it similar to flocking? How is it different from flocking?

50 Formations Issues ◦ Is there a leader? ◦ Where do individuals steer towards? ◦ What happens when they turn? ◦ What happens when they change heading by 180 degrees? ◦ What happens when there is a narrow pass? ◦ Formation splitting and reforming?

51 Math and Physics Do you remember your Math and Physics? If needed: Read and recall chapter 1 of the study book

52 Steering Behaviors (see demo programs!) Seek Flee Arrive Pursuit Evade Wander Obstacle Avoidance Wall Avoidance Interpose Hide Path Following Offset Pursuit

53 Group Behaviors (see demo programs!) Separation Alignment Cohesion Flocking

54 Combining Steering Behaviors (see demo programs!) Weighted Truncated Sum.. With Prioritization Prioritized Dithering Ensuring Zero Overlap

55 And finally … (see demo programs!) Spatial Partitioning Smoothing

56 Homeworkpart 1  Homework ◦ Study chapter 3 of your study book. (Study behavior’s description and algorithms; read code, browse math and physics and run demo’s). ◦ Run the demo programs: ◦ Seek, Flee, Arrive, Pursuit, Wander, Obstacle Avoidance, Interpose, Hide, Path Following, Offset Pursuit, Flocking, Non Penetration Constraint and Big Shoal, Another Big Shoal and Another Big Shoal with Smoothing.

57 Homeworkpart 2  Homework (in couples of 2 students) ◦ Run the amazing program SteeringCS (see blackboard) ◦ Modify this program: ◦ Implement LEADER FOLLOWING and EXPLORE (see Blackboard for details) ◦ You need your solution at next AI practice, so be sure to take your files with you.

58 Practice The practice will be: Implement “one or more steering behaviors” using the steering C# project of your homework. Which ones will be told…. In same student couples