Vous êtes sur la page 1sur 20

AGameplayArchitecturefor Performance

TerranceCohen InsomniacGames 7/6/2007


Outline
Preface Casestudy:ResistanceGPOptimization CellPerformanceHighLevel AspectsforPerformanceaProposal Summary ModeratedDiscussion

Drones Aspectsexperiment

Preface
Qualifications?
Performanceconsiderationsforgameplay

Notwhatwereusedto
Commentsencouraged

Lookingtothefuture Manyvariationspossiblewithinthe proposedframework*

ResistanceGPOptimization ProblemStatement
AIandMovewereexpensive Profilewasprettyflat,ie.fewhotspots Deferredtargetingcollisioncheckssmall improvement Designercontributions
Limitedeffect Toolaborintensivetobeageneralpurpose solution

MassiveMonolithicUpdatesareBad.

ResistanceGPOptimization theTechnique
DecidedtoimplementDrones Abilities
Verycheap(bycomparison)butConvincing NoAIorMove Selecttarget Shoot Cover(lowormedium,butnotfull) Die Promote

Dronescouldnotrelocate*

ResistanceGPOptimization DronePlanning
WhoisaDroneandwhen Desiredpopulation
3Affinities:No,Medium,High FillfromHighAffinityifpossible IfdesiredpopulationcantbefilledwithHigh Affinitycandidates,useLowAffinityones NeverdemoteNoAffinitycandidates 2distancesfullyspecifyAffinityZones*

ForResistance,A(moby)=f(distance)

ResistanceGPOptimization DronePlanning(contd)
Promotiontriggers
WhenisaDronenotaDrone? Damagedbyplayer Zoomedinon NoAffinity(partofPlanning) Timed,randomizedinterval

Planningupdatedcontinuously Planningdata

2AffinityZoneborderdistances,Desired% Global(level)planning Optionalpersquadplanningoverride

ResistanceGPOptimization Results
Droneswere~10%ofthecost Planningworkedwell Squadplanningdatausedrarely Withplanning,affinity,andpromotion triggers,Dronesarebarelynoticeable Afewscenariosstillneededtobetrimmed AI&Movefitinbudget

Proposal:AspectsforPerformance
IdeaofAspectstakenfromAspectOriented Programming

Helpprogrammersintheseparationofconcerns: Breakingdownaprogramintodistinctpartsthat overlapinfunctionalityaslittleaspossible

ConsiderthehighlevelelementsofCell performance

CellPerformanceHighLevel
Weakness
Highpenaltiesforcachemissandmispredicted branches Parallelism! Separateconcerns,runtheminparallel GoalsmatchAOP!

Strength

Approach:

Thesefactorsarelikelytobemoreprominentin futurehardware

Proposal:AspectsforPerformance
Systemsowntheirdata(insteadofmobys) WhenaSystemupdates,ittearsthroughitsdata Systemscouldworkinparallelwithothersystems Tighterloopswithfewerconditionalsandless branching NoneedtotestifaGameObjecthasaparticular typeofdatatoupdate Contextswitchesarealwaysexpensive! Systemsoperatingonlocaldatacanoperatemore efficiently

Proposal:AspectsforPerformance
InfrastructureforDronesexerciseinAOP
Wevebeenheadinginthatdirection!
Components PhysicsInstances UpdateClasses(toanextent) AnimManager

ToolshavemovedtowardAssets
LendsitselfwelltoAspects

Proposal:AspectsforPerformance
Ultimately,GameObjectisjustacontainer
Thecontainerisnolongernecessary!

GameObjectswouldexistonlyasIDsonAspect instances QueryAPI:

Aspect*GetAspect(AspectType,GameObjectID)

Notallornothing

gradualtransitionisstraightforward

AspectsforPerformance CurrentTechnique
Components
AbstractinterfacetoGameObjects Encouragessynchronousprocessing

AspectsforPerformance LookingForward
Aspects
Dynamicallyadding/removingAspects supportedinaunifiedway Systemsowntheirdata,processingiscache friendly,encouragesasynchprocessing NooverheadqueryingforComponents

AOGD ThoughtExperiments
Howgranularshouldaspectsbe? Shouldtheybehierarchicalorflat? ConsiderformingastatemachineoutofAspects
Statetransitionsreplacethecurrentstateaspectwith another StateinitializedwhenAspectadded Supportforsimultaneousstates StatescommunicateviasharedBlackboard (effectivelymemberdata)(likedynamicpvars)

AOGD ThoughtExperiments
Newwaysofvisualization/analysis CoolAspectAnalysisscreens:
Aspectsbyowner(GameObjectID)
PointatGameObjectandseehisAspects Selectanaspectandseeitsproperties&values
AspectscouldimplementaDebugDumpmethod ToTTYortoViewport

AspectsbySystemw/owner Pivotdata

AspectsforPerformance Misc.Considerations
SharingdatabetweenAspects
crosscuttingconcernsinAOPlingo Implementassystemsseefit

SharedDatauploadedwithmultiplesystems Systemreferstodataownedbyothersystem

Debugging

Effectivelythesameasbefore Debuggerscriptingcouldassistinlocatingobjects withinothersystems


Debuggingtheaffectedsystem

Summary
Droneswereaveryeffectiveoptimization ProvidedalimitedtestofAspects Cellperformancedemandsparallelism Aspectorientedgamedevelopmentplays directlyintothestrengthsandweaknesses oftheCell

ModeratedDiscussion
SpeakUp

Vous aimerez peut-être aussi