building a sports ai architecture
DESCRIPTION
Building a Sports AI Architecture. Ushhan D. Gundevia November 8, 2004. Terry Wellmann. He has been programming since 1983 Responsible for architecting and writing AI for Microsoft’s NBA Inside Drive franchise He was also the lead programmer on All-Star Baseball for N64 - PowerPoint PPT PresentationTRANSCRIPT
Building a Sports AI Architecture
Ushhan D. GundeviaNovember 8, 2004
Terry Wellmann
He has been programming since 1983 Responsible for architecting and writing AI
for Microsoft’s NBA Inside Drive franchise He was also the lead programmer on All-
Star Baseball for N64 Has a Computer Science Degree from
If you would like to know more
http://xbox.ign.com/articles/372/372418p1.html http://www.mobygames.com/developer/sheet/vi
ew/by_genre/developerId,126714/
Challenges
Real teams spend countless hours practicing together – Why?To improve an individuals skills and abilitiesTo train a group of independently thinking
individuals to instinctively react to a situation in a manner predictable by other teammates
To stimulate cohesive group decision making in a game is difficult
Things to keep in mind
Keep it simple Break down decisions into various levels Spend time on planning Don’t be afraid to make mistakes Do not underestimate the power of
Randomness
Agent Plans
Examples of Offensive, Defensive and Shared plansPassShootDrive to basketRun the playRescue a trapped ball handler…
Pseudo code for Agent Plan
Class AgentPlan{
…float EvaluateInitiation();float EvaluateContinuation();void Initiate();void Update();…
}
Why float?
The EvaluateInitiation and Evaluate-Continuation functions return float values Always building complex systems, with several plans
compared to determine which one is used Each plan is a building block in a complex system Each plan individually evaluates the current situation
to determine its feasibility Returns a value between -1.0 and 1.0 Execute plans if value > 0 To strongly encourage a plan, return a value > 1
Team Management
Its implemented using a FSM Each state encapsulates a different goal
and a set of responsibilities Basketball can be assumed to have 3
kinds of statesOffensive StatesDefensive StatesCommon States
Offensive and Defensive States
They mirror each other Responsible for all aspects of the game play that
the user can interact with. They are ?
Inbound Transition Frontcourt Rebound Recover Loose Ball Free Throw
Common States
Neutral situations when the ball is not in play and neither team is in offense or defense
They are ? Pre-game Tip-off Time-out Quarter Break Substitution Post Game
State Transition and Flows
Pseudo Code - Frontcourt Offense StateClass FrontCourtOffense : public TeamStateBase{
protected:enum TBallHandlerPlans{
eBallHandlerShot, eBallHandlerPass,eBallHandlerDrive, eBallHandlerPlayMovement,…
};enum TNonBallHandlerPlans{
eNonBallHandlerRescueBallHandler,eNonBallHandlerGetOpenForPass,eNonBallHandlerSetPickeNonBallHandlerPlayMovement…
}
public:…int Update(int);int ReInit(void);…
};
What’s that?
The key elements are the two enumerated types that define priority order
We might also have 2 different update functions for a BallHandler and a NonBallHandler for simplicity
In some situations priorities might not be enough, me may need some explicit if-then logicAny Idea where?
Pseudo Code for Update Fnfor (each plan to evaluate){
//get the proper evaluation valueif (planToCheck == currentPlan)
evalValue = EvaluateContinuation();else
evalValue = EvaluateInitiation();//is the current plan the best option//simple priority order plan selectionif (evalValue > bestEvalValue){
bestEvalValue = evalValue;bestPlan = currentPlan;
}//handle situations the priority method can’telse if (bestValue > 0.0f && bestPlan == shot)
//is the drive plan a valid optionif (currentPlan == drive && evalValue > 0.0f)
//set the best plan to drive, but leave the bestValue as it is – Why?bestPlan = drive;
//if the best plan is the current plan, update it else initiate itif (bestPlan == currentPlan)
currentPlan->Update();else
currentPlan->Initiate();}
Agent AI
A well thought-out collections of Utility Functions and data used by the plans to evaluate and execute the things they represent
Shot Plan Taking a closer look at the shot plan
Three things to keep in mind Potential success rate
Players skills and abilities – denoted by rating values Penalties – e.g. defensive pressure applied to the player
Type of shot Is Dunk possible?
How far is he from the basket? Does he have a clear path to the basket? Can he dunk?
Is Lay-up possible? Same questions as above, but every professional NBA
player can lay-up Last option is Jump shot
Tell the player how to perform that shot
High-Level Agent AI
Command issuing functions Decisions that require more logic then a
simple random no.Whether to do a flashy 360° dunk or a simple
one Wrapper for Agent Mechanics
Agent Mechanics
Low-Level AI Manage and select the animations Simple decisions that require no more
than Random nos. Like commands given to people who have
no knowledge about basketball, but can follow simple directions. e.g. walk, jog, run
Conclusion
Sports games present a unique set of challengesThe rules are well defined and allow little
room for creativityProfessional athletes have personalities and
styles that are recognized by millions of fansUser should be able to capture the abilities,
personalities and emotions of the athletes being stimulated
References
Building a Sports AI Architecture – AI Game Programming Wisdom 2
Learning Goals in Sports Games – Jack van Rijswijck www.gdconf.com/archives/2003/Van_Ryswyck_Jack.doc A very nice paper dealing with learning in Sports Games, using
Soccer as the base.
Thank You