Building a Sports AI Architecture

22
Building a Sports AI Architecture Ushhan D. Gundevia November 8, 2004

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 Presentation

Transcript of Building a Sports AI Architecture

Page 1: Building a Sports AI Architecture

Building a Sports AI Architecture

Ushhan D. GundeviaNovember 8, 2004

Page 2: Building a Sports AI Architecture

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

[email protected]

Page 3: Building a Sports AI Architecture

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/

Page 4: Building a Sports AI Architecture

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

Page 5: Building a Sports AI Architecture

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

Page 6: Building a Sports AI Architecture

Agent Plans

Examples of Offensive, Defensive and Shared plansPassShootDrive to basketRun the playRescue a trapped ball handler…

Page 7: Building a Sports AI Architecture

Pseudo code for Agent Plan

Class AgentPlan{

…float EvaluateInitiation();float EvaluateContinuation();void Initiate();void Update();…

}

Page 8: Building a Sports AI Architecture

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

Page 9: Building a Sports AI Architecture

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

Page 10: Building a Sports AI Architecture

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

Page 11: Building a Sports AI Architecture

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

Page 12: Building a Sports AI Architecture

State Transition and Flows

Page 13: Building a Sports AI Architecture

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);…

};

Page 14: Building a Sports AI Architecture

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?

Page 15: Building a Sports AI Architecture

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();}

Page 16: Building a Sports AI Architecture

Agent AI

A well thought-out collections of Utility Functions and data used by the plans to evaluate and execute the things they represent

Page 17: Building a Sports AI Architecture

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

Page 18: Building a Sports AI Architecture

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

Page 19: Building a Sports AI Architecture

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

Page 20: Building a Sports AI Architecture

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

Page 21: Building a Sports AI Architecture

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.

Page 22: Building a Sports AI Architecture

Thank You