Download presentation
Presentation is loading. Please wait.
1
Sports Games: Artificial Intelligence and Physics
2
Topics Sports Game Design and Development ◦Architectures ◦Class Structures Agent Cooperation ◦Team based cooperation and Optimization Physics ◦Object physics ◦Agent physics ◦Dead Reckoning Strategy Development ◦Artificial and Human Elements
3
Challenges Simulating a natural, well-known environment ◦Modeling fields, courts, rinks, etc. ◦Modeling player personalities and animations ◦Physics engine Strategy ◦Sports are a form of Real-Time strategy ◦Strategies while confined to a set of rules and the size of the field, are numerous and constantly changing
4
A Brief History A well known fact: Video game detail has improved over the years From Tecmo Bowl to Madden 2008 ◦Better player models ◦Larger fields, increased atmosphere ◦More intelligent AI ◦More modes, styles of play Arcade versus Simulation Longer play modes Online play
5
Building an Sports AI Architecture
6
Building a Sports AI Architecture A Sports game has many CPU-Intensive tasks ◦Player animation ◦Route planning ◦Physics modeling ◦Strategy development Breaking these down in a high level architecture confined by the rules of the game can help ease the complexity of the development
7
Building a Sports AI Architecture Layering the architecture
8
Building a Sports AI Architecture Plans ◦Offensive Pass Shoot Drive to the basket ◦Defensive Position the defender Double team the ball handler ◦Shared Rebound Set up for a free throw Plans enable the players to move freely and determine their own best routing methods This level of abstraction provides a sense of realism to the game
9
Building a Sports AI Architecture
10
Example planning class Class AgentPlan { float EvaluateInitiation(); float EvaluateContinuation(); void Initiate(); void Update(); } Initiation and continuation are very important concepts because they determine if a plan is working and where to go next ◦Common return values are between -1.0 and 1.0 Update is called for every tick to update the AI
11
Building a Sports AI Architecture High level strategy module sets a goal ◦An opportunity is seen to complete a through pass in front of the goal for a score Plan is created ◦An opportunity is seen to complete a through pass in front of the goal for a score Route finding plots course ◦Each player (opponent and team) is considered, momentum(team and player), and even ball planning Execute plan ◦Not all plans will work out ◦Depending on the skill level of the other team and unforeseen occurrences, this leaves the game interesting
12
Building a Sports AI Architecture States ◦A game can be broken into states with responsibilities and transition points. Moving from an offensive state to a defensive state ◦These states can govern the types of plans that will be used ◦In an offensive state you wouldn’t push all your defenders back Well you might But more often than not you will push defenders up so that they can support an offense and keep momentum moving in the positive direction
13
Building a Sports AI Architecture
14
Agent AI ◦Well thought out collection of utility functions and data used by the plans ◦Determine a player’s chance of success ◦Determine the likelihood of certain actions Dunks, lay-ups, bicycle kicks, etc Based on real-world player abilities and conditions of the game ◦Perform the action and determine the type of action that can be performed by providing a wrapper to the mechanics
15
Building a Sports AI Architecture Agent Mechanics ◦Considered to be low-level AI ◦Manage and select animations to be used ◦Some of these decisions are determined through the use of a random number This gives the effect that the game is more real Humans do not always react to the same situation in the same way ◦This level also takes into consideration the kinds of commands that users would input into the system Run Shoot Pass
16
Dead Reckoning
17
Originally developed as a tool for navigators ◦Determining the position of his ship given parameters such as direction, intended course, and speed Estimating position based on past position and trajectory ◦This becomes more complicated when other factors are taken into consideration Wind or current
18
Dead Reckoning Inertia ◦Dead Reckoning at its most basic level reduces to Newton’s first law of motion Knowing an object’s position and speed, we can assume the object will continue to travel in a straight line. ◦ P t = P 0 + v t ◦ P x,t+1 = P x,t + v x ◦ P y,t+1 = P y,t + v y ◦ P z,t+1 = P z,t + v z ◦These calculations can sometimes prove to be “too good” Incorporating an error calculation might help Even the best quarterbacks have a bad game
19
Dead Reckoning Pseudo- Brownian Motion ◦An extremely maneuverable object is harder to predict velocity vectors over lengths of time In the case of a UFO which can do whatever it pleases (Or so we assume), knowing the velocity magnitude can only help us determine a spherical region of possible positioning ◦In sports games this can be observed as objects in motion which experience seemingly random movement which is an effect of outside forces As a pass is being completed, a strong wind may blow and knock the ball off of its intended course.
20
Dead Reckoning Kinematics ◦If the object’s initial velocity is unknown, it can be computed from observation by plotting the curve of its position for an arbitrary interval and computing speed as the first derivative of the position curve. ◦Adding an estimate of its acceleration vector can help in estimating the object’s future trajectory. ◦P = P 0 + v 0 t + 0.5at 2
21
Dead Reckoning Uses in sports games ◦Shooting a ball or puck ◦Passing a ball or puck Dead reckoning is useful for planning the trajectory of players to determine if a player can make it to an open position to complete the pass. Good examples of this can be found in soccer games ◦Players will often link passes together by passing to a teammate when faced with a defender and running past the defender to accept a return pass up the pitch
22
Dead Reckoning Online play ◦Dead Reckoning can be used in games to minimize the effects of network latency Each player periodically broadcasts a packet containing his avatar’s location, velocity, and acceleration During the intervals between packets, each machine runs a dead reckoning algorithm to compute the approximate positions and orientations of all other players When a new incoming packet from another player is received, the local state of the world is updated accordingly, and the process starts anew
23
Dead Reckoning Inferring goals ◦Dead Reckoning can help to infer another players goals and try to intercept them This can be seen as interceptions in football and soccer
24
Interceptions
25
Interceptions Interceptions occur in many sports The interesting aspect of calculating interceptions is that the same theories apply as in Dead Reckoning, but the system is less planned ◦Meaning that, interceptions are not intentional ◦Games should include interceptions as incidental and unplanned from an AI perspective in order to accurately model a sports game
26
Interceptions
27
Interceptions An object is at a position P b It travels in a straight line with velocity V b Another object is at a Pp and wants to intercept the first object ◦The intercepting object has a set speed it can move at A velocity to intercept, V p, is calculated This is a simplified model
28
Interceptions For instance: ◦A basketball bouncing off of a rim has a path that is parabolic in shape ◦Break the model down into two submodels Altitude of the ball Motion in the ground plane ◦The ground plane motions are orthogonal to the altitude axis These motions can be considered in isolation
29
Interceptions Another simplification occurs in the previously described model ◦No turning radius ◦Infinite Acceleration ◦Indefinite travel at maximum velocity Error isn’t always frowned upon…by developers ◦Passes are missed. It happens. ◦Other methods can be used to calculate for heading changes
30
Interceptions
31
Interceptions For an interception to occur, the position of the ball and the player must be the same at some time t If V p is known prior, then the function can look like ◦P b + V b t = P p + V p t However V p is the variable that needs to be solved for ◦Distance between the player’s initial position and the ball at time t: |(P b – P p ) + V b t| If the player can move a distance equivalent to how distant the ball is, the player can intercept the ball at time t |(P b – P p ) + V b t| = s i t
32
Interceptions |P + Vt| = st (P +Vt)*(P+Vt)=(st) 2 P*P + 2P * Vt + V*Vt 2 = s 2 t 2 (V*V – s 2 )t 2 + (2P*V)t + (P*P) = 0 Now the equation is a second-order polynomial of t Now it’s time to use the quadratic equation
33
Interceptions Category of solution is determined by the expression in the radical ◦b 2 – 4ac A better form to look at our equations from ◦b 2 -4ac = (2P*V) 2 – 4(V*V-s 2 )(P*P) ◦… ◦(P*V) 2 + (s 2 – V*V)(P*P)
34
Interceptions No Real Roots ◦The radicand(quantity with the radical) is negative There are no real roots The ball cannot be intercepted ◦This occurs when the ball travels at a speed greater than the maximum speed of the player ◦S 2 – V*V must be negative ◦S<|V| ◦The player has to be able to move faster than the ball if he hopes to intercept it
35
Interceptions One Real Root ◦Border case between whether or not the player can intercept the ball ◦Only one point in time for interception ◦The radicand must be zero ◦Two Special Cases (P*V)<0 ◦ The ball’s velocity is toward the interceptor and can be caught (P*V)>0 ◦ The ball’s velocity is not toward the receiver This happens because the interception theoretically happened in the past
36
Interceptions Two Real Roots ◦Does not require the speed of the player to be greater ◦Two positive roots The player is close to the line of motion and able to catch the ball anytime ◦Two negative roots Impossible interception. Negative time. ◦One positive and one negative root The player is moving faster than the ball and can meet at any time to meet it in the positive direction
37
Dead Reckoning
38
Error correction ◦The translational error between the real position of an agent and the estimate provided by dead reckoning can become unbounded with time. The agent will compute its own short-term map of its surroundings The short-term map is compared with the a priori map using pattern recognition techniques Small, incremental corrections are applied on the fly
39
Agent Cooperation
40
Coordination and communication are key amongst human teams and the same goes for the PS3, Xbox360, and Commodore 64 The first step is to define behaviors for the agents. In the case of baseball: ◦Baserunning ◦Fielding ◦Hitting ◦Pitching
41
Agent Cooperation Hitting and Pitching ◦Not too complex Very much animation based ◦The pitch is thrown ◦It is hit, or not hit ◦The ball will have a determined path ◦Once the ball is hit, its initial velocity an angle are the only real factors of importance These two factors in addition to existing baserunners directly affect how the ball is fielded ◦Ball hit and ball pitched act more like events Prepare to field Field Prepare to run
42
Agent Cooperation Fielding Behaviors ◦Assignments happen off of two main triggers (events) Ball Hit Ball Fielded ◦Players should react differently to these situations Only one player fields a ball, so the other players watch, or prepare for other strategies
43
Agent Cooperation
44
Class Structure Class BasicBehavior { … void Entry(Cplayer*); void Exit(Cplayer*); void Process(Cplayer*); … } Each derived behavior has a transition table to switch between behaviors and actions ◦Many times this can result in a similar behavior being performed ◦Transition tables do not always lead to a distinctly different behavior
45
Agent Cooperation Initial Behavior Assignments ◦In the case of a ball hit event, once the initial angle and velocity are known, it is easy to determine where the ball will land, and what actions and behaviors to disperse ◦Determining the Hit Type and Hit Zone can be done using physics and trigonometry The Hit Type and Hit Zone values can be used to control values across the entire field
46
Agent Cooperation Hit Types ◦Ground ball ◦Fly ball ◦Line drive ◦Popup ◦Deep drive In the case of a hit type ground ball Zone 7 ◦The first baseman and right fielder should motion to the Behavior Field Ball ◦The rest of the infielders will move to Behavior Cover Base, with exception to the second baseman who will assume Cutoff or Field Ball depending on velocity ◦Left and Center Field are in Behavior Back Up
47
Agent Cooperation Hit Zones
48
Agent Cooperation Initial Behavior Assignments for Runners ◦Hit Types Ground Ball – Behavior Go or Behavior Go Back A runner on second, not forced will assume Behavior Go on any ball hit in a right-hand zone Hit type fly ball will throw Behaviors Go Halfway, or Tag Up ◦The runners evaluate situations exactly like humans do They check proximities of fielders to the ball, evaluate the actions of other runners and make a best decision on what to do
49
Agent Cooperation
50
Throw Determination ◦Fly balls 95 percent of the balls either go to second or home Or throw to the cutoff man and let him decide ◦Rundowns We have enough information to run the player down every time (100 percent success rate) So the better approach to take is to make it interesting and allow the runner to fool with the window
51
Real Time Strategy Development
52
Sports games are confined to sets of rules and the development of strategies both team-wide and personal that confine themselves to the rules of physics and the rules of the game This does not limit however the amount of work and planning that is done by each individual player, who has to model the abilities and limitations of his or her real-life component. Team dynamic is equally important ◦Some teams have characteristically strong defense ◦Some players communicate better than others, and are more intelligent
53
Real Time Strategy Development Soccer Games ◦Real time strategy in the sense of team control ◦Moving offense/defense forward and back ◦Controlling player motions Many of the players use advanced AI techniques to predict good strategies to use with you Games can allow you to change offense and defensive strategies on the fly. Different players have different abilities ◦ This skill set in some ways can become very detailed ◦ Some famous players are known for their speed, shooting, defensive abilities and a knowledgeable player can exploit these to their own advantage
54
Real Time Strategy Development Positions and zones are of extreme importance ◦Players have roles ◦Like in RTS games, some characters cannot perform well on certain terrain ◦The same goes for players playing in muddy conditions or snow Teams have characteristics and players that make them more powerful against other teams ◦Not a division on race and inherent abilities ◦A division based on skill and communication There are optimal configurations
55
Real Time Strategy Development A new trend is also to give you manager control ◦This involves more long term planning regarding player trading, development, and economics ◦Played over a long period of time, your decisions affect your win percentages and offers you receive. This kind of play rewards players who are very tied to the individual sport
56
Real Time Strategy Development Skills Vs. Strategy ◦An interesting development in sports gaming is that of providing you with additional skills ◦Managing a team from the top level, while managing a player’s actions on a lower level are becoming increasingly common ◦FIFA 2008 included a new mode titled “Be a Pro” which allows the user to master skills such as dribbling and tackling at a level that goes beyond simply pressing A or B ◦This type of a game feature can almost be compared to some aspects of RPG gaming, where a player levels up and is rewarded with experience points and abilities
57
Final Notes Sports games have the difficult task of being true to the sport and physics ◦Accurate player modeling ◦Robust physics engines Sports games incorporate features from many different genres ◦Real-time strategy styles ◦RPG-type player development Through the years sports games have advanced significantly to allow a deeper level of play
58
Questions?
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.