Download presentation
Presentation is loading. Please wait.
Published byRandolph Powell Modified over 9 years ago
1
5/18/20151 Team Sport AI CIS 479/579 Bruce R. Maxim UM-Dearborn
2
5/18/20152 Game Objects Soccer pitch Two goals One ball Two teams Eight field players Two goalkeepers
3
5/18/20153 SoccerPitch.h Rectangular playing area enclosed by walls Contains pointers to ball, two teams, and two goals Pitch is divided into 18 regions (3 by 6) numbered 0 to 17 Each player assigned to a home region at start of play and after each goal Player regions change during play to implement team strategy (e.g. push forward on attack)
4
5/18/20154 SoccerPitch.cpp The main game loop calls Update and Render each iteration The corresponding Update methods for the team and ball objects are called The appropriate Render methods are called to draw new images of the pitch, ball, and team formations are call
5
5/18/20155 Goal.h Goals are defined by a left goal post, a right goal post, and a scoring direction Basically used to check for ball crossing between goal posts Resets player positions and indicates a scoring change to be processed elsewhere
6
5/18/20156 SoccerBall.h Derived from MovingEntity Contains data members for updated ball position, player possessing the ball, and local wall boundaries Contains additional methods for –Kicking the ball –Testing for collisions with objects (not players) –Calculating future ball positions
7
5/18/20157 SoccerBall.cpp FuturePosition –Calculates future ball position applying a frictional constant using the usual formula TimeToCoverDistance –Time to travel from point A to point B given the amount of force applied to ball
8
5/18/20158 AI Design Two player types (goalkeeper, field player) derived from PlayerBase All players make use of reduced version of SteeringBehaviors class The SoccerTeam and players classes make use of the StateMachine class to implement tiered AI (common to RTS games) Players can send messages (telegrams) to each other, but not the entire team
9
5/18/20159 SoccerTeam Contains pointers to pitch, home goal, opponent goal, team players, opponent players, and key players –Receiving player –Closest player to ball –Controlling player –Supporting player (moves to spot determined by calculating the best support spot based on goal scoring potential)
10
5/18/201510 Team States Prepare for kick off –Players sent to home regions, sets key player pointers to NULL, state change to defending Defending –Players move to regions closer to home goal, when ball regained state changes to attacking Attacking –Some players advance to regions closer to opponent goal, best support spot determined, pass or shot, when ball lost state becomes defending
11
5/18/201511 Field Players Derived from same base class Come in two flavors, attackers and defenders Player motion is velocity aligned Motionless players turn to face the ball (as a human player might) Players use the arrive, seek, and pursuit behaviors to help them chase the ball (these behaviors turned on in state Enter method and turned off in Exit method)
12
5/18/201512 Field Player States GlobalPlayerState Wait ReceiveBall KickBall Dribble ChaseBall ReturnToHomeRegion SupportAttacker
13
5/18/201513 Player Messages Msg_SupportAttacker –Sent by controlling player to move pass receiver Msg_GoHome –Return to home region Msg_ReceiveBall –Sent to receiving player when pass is made Msg_PassToMe –Sent to controlling player from potential scoring player Msg_Wait –Player should hold position
14
5/18/201514 ChaseBall State Player will seek ball’s current postion and try to get in kicking range and is able change state to KickBall Remains in this state as long as player is closest team member from ball
15
5/18/201515 Wait Tries to maintain position, even if bumped out of position by another player If upfield from controlling player player will call for a pass, if pass can be made player changes state to receive the ball If waiting player becomes closest to ball, it will change state to chase ball
16
5/18/201516 Receive Ball At most, only one player on a team may be in this state The receiving player sets steering to the target position for pass Both arrive and pursuit can be used to approximate the most believable behavior to intercepting the ball trajectory
17
5/18/201517 Kick Ball Implements the logic for passing or shooting on opponent goal If player cannot pass or shoot, state change to dribble is made Player cannot remain in KickBall state for more that one update cycle State entered when player comes within kicking distance of the ball, steering used to intersect ball position Player moves to wait state after kick
18
5/18/201518 Dribble Teammates notified that controlling player is moving the ball May need to turn ball to move toward opponent goal Player makes small kick and changes state to chase ball Continues until pass or shot is possible
19
5/18/201519 Support Attacker First action by controlling player is to find potential support player and send a message SupportSpotCalculator determines which player to change state On entering the state, the arrive behavior is switched on and steering behavior directed toward location of BSS If a safe pass can be made the state will move to receive pass
20
5/18/201520 Goalkeeper States GlobalKeeperState TendGoal ReturnHome PutBallBackInPlay InterceptBall
21
5/18/201521 Tend Goal Keeper move laterally across goal mouth trying to keep body between goal and ball Relies on the interpose behavior If ball is close to keeper state changes to put ball back in play If ball is in intercept range state changes to intercept ball If keeper to too far from goal after intercept and return to tend goal stay change to return home will be made
22
5/18/201522 Return Home Steers goalkeeper toward home region When home region reached state or opponents gain control of the ball changes to tend goal state
23
5/18/201523 Put Ball In Play When keeper gains possession of ball it enters this state Keeper announces this fact to team and players return to their home regions Once a player is in position to receive a clean pass a message is sent to let the player know that the ball is one the way and state changes to tend goal
24
5/18/201524 Intercept Ball If opponent with ball enters threat range keeper will use pursuit behavior and move toward the ball Monitors distance from its home goal and may change state to return home if “too far” from goal If ball is out of goal range and keeper is closest player keeper continues after the ball
25
5/18/201525 SoccerTeam:: isPassSafeFromAllOpponents Method used to determine if ball trajectory from point A to B can be intercepted by any opponent player for proposed kicking force Assumes ball can be kicked harder than closest player’s maximum speed Opponent’s farther away from target than intended receiver can also be ignored Best interception opportunity will be for player running perpendicularly to ball trajectory using bounding circle (or ellipse) approach
26
5/18/201526 SoccerTeam::CanShoot Player in possession of ball queries CanShoot Selects a number of random positions in front of the goal mouth and tests them for shot without interception by any opponent
27
5/18/201527 SoccerTeam::FindPass Called by player to see if pass to teammate is possible If so pick best teammate and target position by trying each teammate one at a time using GetBestPassToReceiver Parameters: passer, pass target, kicking force, minimum distance for receiver Returns receiver and target location
28
5/18/201528 SoccerTeam:: GetBestPassToReceiver Examines several positions around potential receiver to find safe passing target Returns best target location and a Boolean indication whether location is safe Takes vision range into account as well as distance from passer and receivers lateral range of motion
29
5/18/201529 Estimates and Assumptions Don’t want perfect AI behavior, so using estimates and heuristics is better than using exact physics modeling You could do perfect calculations and dumb down the AI (systematic errors or random noise) You could make some assumptions that prevent perfect play (bounding circles rather ellipses that take turning time into account)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.