Sports Games AI

advertisement
Sports Games AI
CSE 348
Daniel Phillips
Dan Ruthrauff
Intro
•
•
Video game AI primarily focuses on RTS and
FPS genres
Sports games offer unique challenges
o
o
o
Meeting player's expectations
Minimizing cheating
Larger scale coordination
Traditional Sports Games
•
Object-oriented architecture
•
Set number of players and a ball
o
•
Create teams and behave within a set of rules
Players have predetermined behaviors
o
Distinct starting and ending points, with clear
transitions between behaviors
Traditional Sports Games
•
Entirely event driven
o
•
No need for complex pathfinding etc.
Every traditional sport has a "starting event"
o Baseball = Ball Hit
o Football = Snap
o Hockey = Puck Dropped
•
For these reasons, AI can be controlled by
Finite-State Machines and Transition Tables
Baseball
•
Good study in AI
o Based on percentages, risks, and expected behavior
•
Divided into three areas:
o
o
o
Fielding
Baserunning
Batting / Pitching
Baserunning
•
Only two basic
behaviors
o Running or not running
•
Mapped into more complex behaviors
Go - head to next base
o Go Back - complement of Go
o Watch - wait for conditions to be met
o Freeze - Stop moving
o Go Halfway - Default assumption for fly ball
o Turn and Go - Round the base and continue to next
o Turn and Look - Round the base but don't Go
o
Fielding
•
Behaviors triggered by one of two events:
o
•
o
On Ball Hit, players are assigned one of four
behaviors based on ball's trajectory
o
o
o
•
Ball Hit
Ball Fielded
o
Field Ball
Cover Base
Cutoff
Backup
Seems simple, but fielding is more
complicated to implement than baserunning
Fielding
•
On Ball Fielded Event
o
o
Players without the ball naturally transition to
other behaviors if needed
Player with the ball decides what to do with it
 ex - Throw Ball or Run With Ball
Initial Behavior Assignment Fielders
•
•
•
•
•
Ball's flight is 100% predetermined
Only need the initial velocity vector
Calculate hit type and zone based on
the flight path
Map a set of behaviors to each hit type
and zone pair
The rules get each teammate working
towards a common goal
How the rules are implemented
determines how "smart" the AI appears
o
Cheating
•
Defined as giving the agents access to
information that would be unavailable to
the player in the same situation
o
•
ex - Madden knowing your plays
Can also apply to when the computer
follows different "rules" than the player
o
o
ex - Unlimited boost in racing games
Does not apply to computer's inherent advantages
Cheating
•
•
Common in older games, but is generally
discouraged now and recent advances in AI
attempt to minimize cheating
Some degree of cheating can be acceptable
if it's not painfully obvious to the player
o
Obvious cheating = bad reviews!
"0/10 WOULD NOT PLAY"
Rubber Band AI
•
•
The more you're winning at a game, the
harder the game gets to maintain a challenge
Accomplished most often in sports AI by
cheating to catch up
o
o
•
Computer controls the outcome of "random" events
 FIFA
Computer violates rules that user must follow
 NBA Jam
Most common in racing games
o
o
Losing cars get a speed boost
Winning cars get a penalty
Rubber Band AI example code
History of AI in Madden
•
•
Original Madden - Madden '93
o
Madden '95
o
•
Play calling overhauled and now mimicked actual
decisions made in the NFL
Madden '96
o
•
Predictable and limited play calling
Introduction of multiple skill levels
Passing and running still highly unbalanced
o
o
Poor defensive AI made it easy to pass
Poor offensive blocking AI made it difficult to run
History of AI in Madden
•
Madden '97
Running issue resolved, but AI still lacking
o Possible to win by only using one or two plays
o
•
Madden '98
o
•
•
Defense now counters the same play if it is called
multiple times in a row
Madden '99
o Huge improvement in defensive AI
o Fans of the series complained the AI was "too good"
Madden '00
o Customizable AI
Cheating in Madden
•
Unexplainable comebacks in 4th quarter
o
o
•
•
•
Fumble when taking a knee to run the clock
Computer opponent breaking five or more tackles for
the game winning touchdown
Bad luck or forced events?
o
No good way to prove either argument
Highly debated until producers of Madden
debunked the claims of "comeback cheating"
o More aggressive play calling
Controversy surrounding this demonstrates
the importance of fair AI to the players
Cheating in Madden
•
One undeniable method of cheating is
Madden's "quick and dirty" difficulty levels
o
Harder difficulties increase the computer player's
physical attributes while decreasing the user's
attributes
Generally players would rather be
defeated by a smarter AI at higher
difficulties than a physically superior
team
Cheating in Madden
•
Official response from EA Sports concerning
Madden's difficulty mechanics
Increases CPU's reaction time, awareness, and
frequency of recalculating factors
o Admit to increasing the CPU team's attributes
o
•
EA claims that "even NFL players feel the
game provides an excellent approximation
of reality"
Innovations
•
Change individual aspects of the game's AI
by adjusting sliders
o
•
•
Design a playing experience that they enjoy
Cheating is easier to detect in sports
games, so developers were forced to build
strong AI with minimal cheating
Put the AI at the center of development
o
Listen to the users' feedback
Artificial Intelligence in Racing
Games
• The first racing game was Gran Trak 10 for the
Atari
• Player races alone against the clock
• No AI
Artificial Intelligence in Racing
Games
• The first racing game with AI was Super Speed
Race
• Scrolling graphics
• The AI was very simplistic
Pole Position
• First realistic racing game
• AI opponents that raced against the player
Spline
• Pole Position used Spline to control computer
racers.
• The opponent follows a preset line and only
deviates from the path to pass
• This preset line is hard coded by developers
• This leads to predictable and formulaic behavior
• Video Example
Super Mario Kart
• First game to implement dynamic AI behavior into
the genre
• AI racers had to navigate complex tracks and pick
up powerups
• Used path following and obstacle avoidance to
create lifelike, competitive opponents
• Video Example
Path Following
• Path following allows the AI to follow a series of
preset nodes
• Path following navigates to each node by using
the steer method “seek” (this will be explained in
a few slides)
• Path following allows for dynamic changes to the
path
• A racer may see a powerup and decide to go out of
their way to get it instead of following the track.
• Creates fluid movement
Obstacle Avoidance
• AI racers alter their direction if an obstacle is
blocking their path
• The first step is finding out if an obstacle will be in
the way if the racer continues on its current
trajectory
• If there are multiple objects in the racers path, the
closest object will take precedence and corrective
steering will be applied
Obstacle Avoidance
• In this figure we see three obstacles: A, B, and C
• We can easily see that the racer will collide with
both B and C if left on its current path
• Because obstacle B is closest, corrective steering
is applied to the left to avoid it
Obstacle Avoidance
• Finding the amount to correctively steer is a multi
step process
• First we must compute the amount of time it is
going to take with the current velocity to reach the
obstacle
• Then we must decide how much we wish to avoid
the obstacle by
• Once we know these two values, we can
determine a point in space to navigate to
• This point can then be navigated using a basic
steering method called “Seek”
How Seek Works
• Seek allows a racer to steer and reach a point
desired_velocity = normalize (position – target) *
speed
steering_amount = desired_velocity –
current_velocity
Colin Macrae Rally
•
• Released in 2001, this Colin Macrae Rally (later
known as “Dirt”) was the first racing game to use
machine learning to develop AI behavior
• Previous racing games implemented sets of rules and
techniques to control racers like the previous
discussed splines, path following, and obstacle
avoidance
Colin Macrae Rally
•
•
Because Dirt featured racing on complex terrain
(such as muddy roads, gravel, and other slippery
surfaces), the AI designer found it difficult to
implement standard car control techniques
Video Example
Colin Macrae Rally
• He decided to try a neural network to model the
behavior of the car
• The final result was a feed forward multilayer
perceptron
Colin Macrae Rally
•
• The inputs were various values that described the
cars movement, direction, position, and track
terrain
• The outputs were various values that determined
how well the car was following the track
Colin Macrae Rally
•
• The Neural Network was successfully able to
design the behavior of the racer despite the
complex terrain
• Video Example
Problems with Machine Learning in
Racing Games
•
• The computer learns too well leading to “perfect”
racing
• Racing maneuvers such as overtaking and
accident recovery are hard to implement with this
strategy
Forza Motorsport
• Took machine learning in the racing genre to the
next level with Drivatar
• Developed by Microsoft’s advanced AI Research
team in Cambridge, England
• AI behavior is trained by humans
• Leads to very realistic racing behavior
Drivatar
• Uses a neural network
• The training sets for the neural network are created
by actual people controlling the cars
• Drivatar allows the AI to learn not only car movement
behavior, but also race strategies
• Drivatar succeeds where Dirt’s neural network failed
• Unfortunately, the nitty gritty details of Drivatar are
kept a secret as the algorithm is still being used in
current versions of Forza
What we do know about Drivatar
• Splits racing behavior into three categories
• Turning Control
• Speed Control
• Racing Strategy
• Each “training lesson” teaches the computer a
different category
• Video of Drivatar Turn Training
Commentary AI in Sports Games
• A sports game should be as realistic as possible
• Commentary helps immerse the player in the
game
• One of the first games to include in game
commentary is Madden Football
Commentary AI in Sports Games
• Segments of dialog are split up into different categories:
• Different combinations of these segments are threaded
together to create coherent sentences that accurately
describe the events of the game
Commentary AI in Sports Games
•
• An event driven algorithm controls dialog
• Each event should have one or more options of
dialog attached to it
• The goal is to give the announcer enough choices
for each event so that the commentary doesn’t
get stale, even after you play the game many
times
Commentary Examples
• Set of all possible events that can happen in a
corner kick during a soccer game
1
2
3
Commentary Examples
Possible Options For 1
<Time on clock> <Formation or Strategy>
1
2
3
Commentary Examples
Possible Options For
<Play by Play>
2
1
2
3
Commentary Examples
Possible Options For 3
<Play by Play> <Player Statistic> <Team Statistic>
1
2
3
AI Cooperation
• In sports games, often times the behavior of
computer controlled teammates can be just as
important as the opponents
• Teammates must cooperate with the player
• Cooperation is a challenge because every player
has a different style of play
Options for Modeling Teammate
Behavior
• Maintain a static behavior, forcing the player to
conform to the style of the computer
• Static behavior leads to static (and boring) game
play
• It can be frustrating if the computer plays a different
way then the player
• Example: NBA Jam
• On defense: CPU plays man to man defense at all
times (never zone defense or any other strategy)
• On offense: CPU goes towards the basket if you are
outside the three point line and vice versa
Options for Modeling Teammate
Behavior
• Allows the player to choose various options that
let them customize how the AI behaves
• Allows the player to feel like a part of the team
• Less frustrating gameplay
• Example: NHL 12
• Players can choose offensive and defensive
formations for the team
• Players can choose various strategies to be used in
different situations
Customizable Teammate Behavior in
NHL 12
• Example Formations
• Umbrella
• Behind the net
Customizable Teammate Behavior in
NHL 12
• Customizable Faceoff Attitudes
• Aggressive – teammates will rush towards the net
after the faceoff looking for a pass or rebound
• Conservative – teammates will stay back after a
faceoff to prevent a rush
Download