ai of sports games

48
AI of Sports Games Dylan Evans Matt Kenig

Upload: sitara

Post on 25-Feb-2016

24 views

Category:

Documents


1 download

DESCRIPTION

Dylan Evans Matt Kenig. AI of Sports Games. Overview. Dead reckoning Designing a sports game AI In Baseball games, the main features of the AI involve: Behaviors The Ball Hit Event The Ball Fielded Event. Dead Reckoning. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: AI of Sports Games

AI of Sports Games

Dylan EvansMatt Kenig

Page 2: AI of Sports Games

Overview

Dead reckoning Designing a sports game AI In Baseball games, the main features

of the AI involve: Behaviors The Ball Hit Event The Ball Fielded Event

Page 3: AI of Sports Games

Dead Reckoning

Process of estimating one's current position based upon existing data

Dead reckoning algorithms help with prediction motion Used where the human player and its AI

teammates must exchange the ball or puck frequently

Also helps offset latency in online games

Page 4: AI of Sports Games

Origins of Dead Reckoning Originally developed as a tool for

navigators A sailor used it to estimate position of

ship▪ Given original position, intended course,

speed▪ Did not account for outside factors

Often used to estimate enemy fleets and troops between instances of visual, radar, or spy satellite contact

Page 5: AI of Sports Games

Dead Reckoning in Sports Games When the AI is trying to shoot the

ball or puck past an active human obstacle A soccer goalie, hockey defenseman,

NFL cornerback When the AI is trying to pass the ball

or puck to the human player In both cases, AI computes the most

likely trajectory of the human player’s avatar

Page 6: AI of Sports Games

Dead Reckoning in Sports Games In a hockey game:

AI could look at the dead reckoning parameters for both the human player and the other AIs on the ice

Determines whether the human’s current trajectory is likely to take him to an open spot shortly

If so, then AI can time a pass so that the puck will reach that spot at the same time as the player

http://www.youtube.com/watch?v=Bb4HITdpMWc&feature=related

Page 7: AI of Sports Games

Dead Reckoning in Sports Games In a football game:

The AI calculating how to throw the ball to a human receiver will need to take the third dimension into consideration ▪ So the ball will intercept the receiver’s

trajectory at a point where it is between one meter and three meters from the ground

http://www.youtube.com/watch?v=E_s3TVzPYNU

Page 8: AI of Sports Games

Designing a Sports Game AI Goal of the AI is to provide the user

with an interactive experience that captures the abilities, personalities, and emotions of the athletes being stimulated http://www.youtube.com/watch?v=R337l

NSQizg

Page 9: AI of Sports Games

Designing a Sports Game AI One of the first tasks is to identify

the high-level decisions (called plans) that will be made In basketball:▪ Pass, shoot, drive to the basket, run the play,

position the defender, block a shot, etc. We will focus on how a plan is a vital

component in the whole architecture

Page 10: AI of Sports Games

AgentPlan class Serves as a base class for all plans Each plan has additional functions and variables

unique to the particular high-level decision being managed

class AgentPlan {float EvaluateInitiation(); // how desirable it is for the plan to executefloat EvaluateContinuation(); // how desirable it is for the plan to continue being usedvoid Initiate(); // initialize decision making void Update(); // called for every iteration of the AI’s tick

}

Page 11: AI of Sports Games

AgentPlan class

EvaluateInitiation() and EvaluateContinuation() return floating point values Allows you to build a complex system

where several plans can be compared against each other to determine which one should be used for the current situation

Values are usually between -1.0 and 1.0

Page 12: AI of Sports Games

AgentPlan class i.e. Lay-up vs. jump shot

Player with basketball is a good shooter Just stole ball, has an open breakaway down

the court We don’t want him stopping to take a jump

shot, but rather want him to drive to the basket Plan Evaluation Values:▪ Shot Plan -> 0.3▪ Pass Plan -> -0.1▪ Drive Plan -> 0.5

http://www.youtube.com/watch?v=PCy3KYKmi0E&feature=related

Page 13: AI of Sports Games

Team Management

A way to organize the plans for the situations where they will be used

i.e. Basketball Common states, offensive states,

defensive states ▪ Distinct responsibilities and clear transition

points

Page 14: AI of Sports Games

Team Management

Offensive and defensive states: Inbound: responsible for getting the ball

in play Transition: responsible for getting the

ball into the frontcourt Rebound: responsible for rebounding the

ball after it has been shot Etc.

Page 15: AI of Sports Games

Team Management

Common states: Pregame: Coordinates the team and

player introductions Tip-off: coordinates the tip-off Time-out: coordinates the time-out Quarter break: coordinates the breaks

from quarter to quarter Etc.

Page 16: AI of Sports Games

Agent AI

Allow the actual decisions to be made A well thought-out collection of utility

functions and data used by the plans to evaluate and execute the thing they represent. i.e. Basketball shot plan▪ Determine potential success chance is of the

player making the shot from current location▪ Determine type of shot▪ Tell player to perform selected shot with specified

success chance

Page 17: AI of Sports Games

Determining Success Chance Need to determine the best chance

of success based on the player’s skills and abilities (given by ratings values)

Determine if any penalties need to be applied (i.e. defensive pressure)

Page 18: AI of Sports Games

Choosing Shot Type

First evaluate likelihood that the player will attempt a dunk

If he cannot dunk, check for lay-up If no lay-up, perform a jump shot

Page 19: AI of Sports Games

Command Issuing Functions Two purposes:

Provide a place within the high-level AI to make any decisions that require more thought or logic than a simple random number▪ i.e. Deciding what type of dunk

Provide a wrapper to the agent mechanics

Page 20: AI of Sports Games

Agent Mechanics

Final piece of AI architecture Manage and select the animations

used Interface between high-level and

low-level AI systems i.e. If you were giving someone who

knew nothing about basketball instructions: Walk, jog, run, pass, catch, shoot, etc.

Page 21: AI of Sports Games

Agent Cooperation in FSMs for Baseball

Sports are a classic example of object-oriented architecture Set number of players and a ball Players create teams▪ Make up a world that is governed by a set of

rules Players have predetermined behaviors▪ Operate within an FSM▪ Distinct starting and ending points▪ Clear transitions into other behaviors

Page 22: AI of Sports Games

Main Topics

In Baseball games, the main features of the AI involve: Behaviors The Ball Hit Event The Ball Fielded Event

Page 23: AI of Sports Games

Behaviors

Enumeration of behaviors Define what actors will be doing Game states will be the basis for game

flow

Page 24: AI of Sports Games

Behaviors

Baseball Behaviors Divide the game into several distinct

categories▪ Fielding▪ Baserunning

Page 25: AI of Sports Games

Behaviors

Baserunning Behaviors At any given time, runners are assuming

one of two behaviors▪ Running▪ Not Running

Baserunners are assigned behaviors based on events in the game such as user input or a ball being caught▪ Some behaviors affect the behaviors of other

baserunners

Page 26: AI of Sports Games

Behaviors

Turn and Go

Go Tag Up

Freeze Slide

Turn and Look

Go Back Go Halfway

Possible transitions and flow for baserunning behaviors

Page 27: AI of Sports Games

Behaviors

Video example of baserunning behaviors from the game MLB 09 The Show http://www.youtube.com/watch?

v=hEJ4ie6KW5I

Page 28: AI of Sports Games

Behaviors

Fielding Behaviors Slightly more complicated than

baserunning Two main triggers▪ Both lead to assignments for fielding

behaviors▪ Ball Hit Event▪ Ball Fielded Event

Page 29: AI of Sports Games

Behaviors

At some point during every play, a fielder picks up the ball Causes some behaviors to transition to

others For a non-fielder▪ Behavior Field Ball -> Behavior Watch▪ Behavior Back Up -> Behavior Watch

Page 30: AI of Sports Games

Behaviors

What to do with the ball Every player without the ball assumes

the Behavior Watch Actor/Player with the ball becomes

primary focus▪ Transitions to a new behavior▪ Throw Ball▪ Run With Ball▪ Run to Dugout

Page 31: AI of Sports Games

The Ball Hit Event

Sports are entirely event driven In Baseball, the event that causes

any action is the Ball Hit Event All other sports have something similar▪ Football – Snap▪ Hockey – Dropping the Puck▪ Basketball – Jump Ball

Page 32: AI of Sports Games

The Ball Hit Event

Two main concerns when the Ball Hit Event occurs Behavior of the fielders Behavior of the baserunners

Page 33: AI of Sports Games

The Ball Hit Event

Basic behaviors assigned on a Ball Hit Event Field Ball Cover Base Cutoff Back Up

Assigned based specifically on where the ball is hit and the velocity at which it leaves the bat

Page 34: AI of Sports Games

The Ball Hit Event

Ball Hit Event

Cover Base Field Ball Back Up Cutoff

Run With Ball

Throw Ball Watch

Run To Dugout

Possible Transitions and Flow for Fielder Behaviors

Page 35: AI of Sports Games

The Ball Hit Event

An Example of Run to Dugout behavior▪ http://www.youtube.com/watch?

v=CJ79FKUgleg(6:30)

Page 36: AI of Sports Games

The Ball Hit Event

Initial Behavior Assignments – Fielders Ball’s initial velocity provides enough

information to assign behaviors to every member on either team▪ Can use it to calculate the ball’s entire path▪ The ball’s flight is completely pre-determined

from the time of impact

Page 37: AI of Sports Games

The Ball Hit Event

Each hit is categorized according to physical properties Hit Type▪ Based on how the baseball was hit▪ Described as an application of the rule set

Hit Zone▪ Field is divided into 10 regions as well as two

regions with negative values designated to be foul areas▪ Calculated using trigonometry

Page 38: AI of Sports Games

The Ball Hit Event

Page 39: AI of Sports Games

The Ball Hit Event Once the hit type and hit zone are

determined, they are used to properly determine a set of behaviors for fielders

Example Ground ball in Zone 7▪ 1st baseman and right fielder given Behavior Field Ball▪ 3rd baseman, shortstop, catcher, and pitcher are all

given the Behavior Cover Base▪ 2nd baseman will receive either Behavior cutoff or

Behavior Field Ball depending on the ball’s velocity▪ Other outfielders will be given Behavior Back Up

Page 40: AI of Sports Games

The Ball Hit Event

Behavior Assignments on Foul Balls Hit types are more important with only

two zones Hit Type Grounder▪ Only have Behavior Type Watch

Hit Type Popup▪ Corner Infielders, Catcher -> Behavior Field

Ball Hit Type Line Drive / Hit Type Fly Ball▪ Corner Outfielders -> Behavior Field Ball▪ http://www.youtube.com/watch?v=CJ79FKUgleg

(3:45)

Page 41: AI of Sports Games

The Ball Hit Event

An Example of Defense from the game MLB The Show 09:▪ http://www.youtube.com/watch?

v=CJ79FKUgleg(1:27)

Page 42: AI of Sports Games

The Ball Hit Event

Initial Behavior Assignments – Runners Goal of baserunners is less complicated

than fielders▪ Advance safely around the bases and score a

run Again use Hit Type and Hit Zone to

determine behavior assignment

Page 43: AI of Sports Games

The Ball Hit Event

Baserunner Cooperation Anytime a runner enters an area

approximately 20 feet in front of every base, he’ll evaluate his behavior▪ The runner’s process function will check:▪ The proximity of the closest fielder to the ball▪ If the ball has been fielded or thrown▪ Which base the ball has been thrown to

▪ The result of this process will prompt a transition of state to either:▪ Turn and Go, Turn and Look, or Slide

Page 44: AI of Sports Games

The Ball Fielded Event

Throw Determination Know where the runners were at the

start of the play▪ Use this to determine where and how to

throw the ball▪ Need to consider what would be realistic too▪ Don’t want to force a throw to 2nd base when there

would be an easy out at 3rd

Page 45: AI of Sports Games

The Ball Fielded Event

Throw Determination Fly Balls▪ 95% of the time the throw goes to 2nd base or

Home▪ http://www.youtube.com/watch?v=-DH5am6-sGE

▪ Easier to throw to the cutoff man though and then reconsider where to throw from there▪ Don’t have to consider the time it will take for the

ball to get to the cutoff man or the base from the outfield

Page 46: AI of Sports Games

The Ball Fielded Event

Throw Determination Rundowns▪ The AI always has enough information to

throw out a runner with one throw in this situation▪ Often, the AI will allow the user to play

“pickle” to make it more realistic

▪ http://www.youtube.com/watch?v=aLXb6L6IowQ

Page 47: AI of Sports Games

The Ball Hit Event

Even though all of these events result in each agent acting separately, they all have a very common, obvious goal Step towards intelligence

Page 48: AI of Sports Games

Questions?