ebook img

Algorithms and Networking for Computer Games PDF

402 Pages·2017·12.127 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Algorithms and Networking for Computer Games

AlgorithmsandNetworkingfor ComputerGames Algorithms and Networking for Computer Games SecondEdition JouniSmed UniversityofTurku Turku,FI HarriHakonen Turku,FI Thiseditionfirstpublished2017 ©2017JohnWiley&Sons,Ltd Allrightsreserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmitted,inanyform orbyanymeans,electronic,mechanical,photocopying,recordingorotherwise,exceptaspermittedbylaw.Adviceonhow toobtainpermissiontoreusematerialfromthistitleisavailableathttp://www.wiley.com/go/permissions. TherightofJouniSmedandHarriHakonentobeidentifiedastheauthorsofthisworkhasbeenassertedinaccordance withlaw. RegisteredOffices JohnWiley&Sons,Inc.,111RiverStreet,Hoboken,NJ07030,USA JohnWiley&Sons,Ltd.TheAtrium,SouthernGate,Chichester,WestSussex,PO198SQ,UK EditorialOffice TheAtrium,SouthernGate,Chichester,WestSussex,PO198SQ,UK Fordetailsofourglobaleditorialoffices,customerservices,andmoreinformationaboutWileyproductsvisitusat www.wiley.com. Wileyalsopublishesitsbooksinavarietyofelectronicformatsandbyprint-on-demand.Somecontentthatappearsin standardprintversionsofthisbookmaynotbeavailableinotherformats. LimitofLiability/DisclaimerofWarranty Whilethepublisherandauthorshaveusedtheirbesteffortsinpreparingthiswork,theymakenorepresentationsor warrantieswithrespecttotheaccuracyorcompletenessofthecontentsofthisworkandspecificallydisclaimallwarranties, includingwithoutlimitationanyimpliedwarrantiesofmerchantabilityorfitnessforaparticularpurpose.Nowarrantymay becreatedorextendedbysalesrepresentatives,writtensalesmaterialsorpromotionalstatementsforthiswork.Thefact thatanorganization,website,orproductisreferredtointhisworkasacitationand/orpotentialsourceoffurther informationdoesnotmeanthatthepublisherandauthorsendorsetheinformationorservicestheorganization,website,or productmayprovideorrecommendationsitmaymake.Thisworkissoldwiththeunderstandingthatthepublisherisnot engagedinrenderingprofessionalservices.Theadviceandstrategiescontainedhereinmaynotbesuitableforyour situation.Youshouldconsultwithaspecialistwhereappropriate.Further,readersshouldbeawarethatwebsiteslistedin thisworkmayhavechangedordisappearedbetweenwhenthisworkwaswrittenandwhenitisread.Neitherthepublisher norauthorsshallbeliableforanylossofprofitoranyothercommercialdamages,includingbutnotlimitedtospecial, incidental,consequential,orotherdamages. LibraryofCongressCataloging-in-PublicationData Names:Smed,Jouni,author.|Hakonen,Harri,author. Title:Algorithmsandnetworkingforcomputergames/JouniSmed,HarriHakonen. Description:Secondedition.|Hoboken,NJ,USA:JohnWiley&SonsInc.,2017.| Includesbibliographicalreferencesandindex. Identifiers:LCCN2017005948(print)|LCCN2017006972(ebook)|ISBN9781119259763(cloth)| ISBN9781119259824(AdobePDF)|ISBN9781119259831(ePub) Subjects:LCSH:Computergames–Programming.|Computeralgorithms. Classification:LCCQA76.76.C672S622017(print)|LCCQA76.76.C672(ebook)| DDC794.8/1526–dc23 LCrecordavailableathttps://lccn.loc.gov/2017005948 CoverDesign:Wiley CoverImage:©Pobytov/GettyImages Setin10/12ptWarnockProbyAptaraInc.,NewDelhi,India 10 9 8 7 6 5 4 3 2 1 v Contents ListofFigures xi ListofTables xv ListofAlgorithms xvii Preface xix  Introduction 1 1.1 AnatomyofComputerGames 4 1.2 GameDevelopment 5 1.2.1 Phasesofdevelopment 7 1.2.2 Documentation 8 1.2.3 Otherconsiderations 9 1.3 SyntheticPlayers 10 1.3.1 Humanness 11 1.3.2 Stance 12 1.4 Multiplaying 12 1.5 InteractiveStorytelling 13 1.5.1 Approaches 14 1.5.2 Storytellingingames 15 1.6 OutlineoftheBook 17 1.6.1 Algorithms 17 1.6.2 Networking 18 1.7 Summary 18 Exercises 19 PartI Algorithms 23  RandomNumbers 25 2.1 LinearCongruentialMethod 26 2.1.1 Choiceofparameters 29 2.1.2 Testingtherandomness 30 2.1.3 Usingthegenerators 31 2.2 DiscreteFiniteDistributions 33 2.3 RandomShuffling 38 2.4 Summary 41 Exercises 41 vi Contents  Noise 47 3.1 ApplyingNoise 47 3.2 OriginofNoise 49 3.3 Visualization 51 3.4 Interpolation 52 3.4.1 Utilityroutinesforvalueconversions 53 3.4.2 Interpolationinasingleparameter 56 3.4.3 Interpolationintwoparameters 58 3.5 CompositionofNoise 60 3.6 PeriodicNoise 62 3.7 PerlinNoise 63 3.8 WorleyNoise 68 3.9 Summary 76 Exercises 76  ProceduralGeneration 81 4.1 TerrainGeneration 82 4.2 MazeAlgorithms 88 4.2.1 Depth-firstalgorithm 91 4.2.2 RandomizedKruskal’salgorithm 91 4.2.3 RandomizedPrim’salgorithm 93 4.3 L-Systems 93 4.3.1 Examples 95 4.3.2 Citygeneration 96 4.4 HierarchicalUniverseGeneration 99 4.5 Summary 101 Exercises 102  Tournaments 105 5.1 RankAdjustmentTournaments 107 5.2 EliminationTournaments 112 5.3 ScoringTournaments 119 5.4 Summary 122 Exercises 125  GameTrees 129 6.1 Minimax 130 6.1.1 Analysis 132 6.1.2 Partialminimax 134 6.2 Alpha-BetaPruning 137 6.2.1 Analysis 139 6.2.2 Principalvariationsearch 140 6.3 MonteCarloTreeSearch 142 6.4 GamesofChance 149 6.5 Summary 153 Exercises 153 Contents vii  PathFinding 159 7.1 DiscretizationoftheGameWorld 160 7.1.1 Grid 160 7.1.2 Navigationmesh 162 7.2 FindingtheMinimumPath 164 7.2.1 Evaluationfunction 165 7.2.2 Properties 165 7.2.3 AlgorithmA* 167 7.3 RealizingtheMovement 169 7.4 Summary 171 Exercises 171  GroupMovement 175 8.1 Flocking 175 8.2 Formations 180 8.2.1 Coordinatingformations 181 8.2.2 Behaviour-basedsteering 183 8.2.3 Fuzzylogiccontrol 184 8.2.4 Mass–springsystems 186 8.3 Summary 187 Exercises 187  Decision-Making 189 9.1 Background 189 9.1.1 Levelsofdecision-making 190 9.1.2 Modelledknowledge 191 9.1.3 Methods 192 9.2 FiniteStateMachines 196 9.2.1 ComputationalFSM 198 9.2.2 MealyandMooremachines 202 9.2.3 Implementation 203 9.2.4 Discussion 205 9.3 InfluenceMaps 208 9.4 AutomatedPlanning 210 9.5 Summary 214 Exercises 215  ModellingUncertainty 221 10.1 StatisticalReasoning 221 10.1.1 Bayes’theorem 221 10.1.2 Bayesiannetworks 223 10.1.3 Dempster–Shafertheory 224 10.2 FuzzySets 227 10.2.1 Membershipfunction 228 10.2.2 Fuzzyoperations 229 10.2.3 Defuzzification 231 10.3 FuzzyConstraintSatisfactionProblem 231 viii Contents 10.3.1 Modellingthecriteriaasfuzzysets 233 10.3.2 Weightingtheimportanceofcriteria 235 10.3.3 Aggregatingthecriteria 235 10.3.4 Makingadecision 236 10.4 Summary 238 Exercises 238 PartII Networking 241  CommunicationLayers 243 11.1 PhysicalPlatform 244 11.1.1 Resourcelimitations 245 11.1.2 Transmissiontechniquesandprotocols 246 11.2 LogicalPlatform 247 11.2.1 Communicationarchitecture 247 11.2.2 Dataandcontrolarchitecture 249 11.3 NetworkedApplication 250 11.4 Summary 251 Exercises 252  CompensatingResourceLimitations 255 12.1 AspectsofCompensation 256 12.1.1 Consistencyandresponsiveness 256 12.1.2 Scalability 258 12.2 ProtocolOptimization 262 12.2.1 Messagecompression 262 12.2.2 Messageaggregation 263 12.3 DeadReckoning 263 12.3.1 Prediction 264 12.3.2 Convergence 266 12.4 LocalPerceptionFilters 268 12.4.1 Lineartemporalcontour 271 12.4.2 Addingbullettimetothedelays 275 12.5 SynchronizedSimulation 277 12.6 InterestManagement 279 12.6.1 Aura-basedinterestmanagement 279 12.6.2 Zone-basedinterestmanagement 280 12.6.3 Visibility-basedinterestmanagement 280 12.6.4 Class-basedinterestmanagement 281 12.7 CompensationbyGameDesign 282 12.7.1 Shortactiveturns 283 12.7.2 Semi-autonomousavatars 284 12.7.3 Interactionviaproxies 284 12.8 Summary 285 Exercises 286 Contents ix  CheatingPrevention 289 13.1 TechnicalExploitations 290 13.1.1 Packettampering 291 13.1.2 Look-aheadcheating 292 13.1.3 Crackingandotherattacks 297 13.2 Collusion 298 13.2.1 Classification 299 13.2.2 Collusiondetection 301 13.3 RuleViolations 303 13.4 Summary 304 Exercises 304  OnlineMetrics 307 14.1 Players 310 14.2 Monetization 311 14.3 Acquisition 312 14.4 GameSession 313 14.5 Summary 313 Exercises 314 Appendices 315 A PseudocodeConventions 317 A.1 ChangingtheFlowofControl 320 A.1.1 Expressions 320 A.1.2 Controlstructures 322 A.2 DataStructures 325 A.2.1 Valuesandentities 325 A.2.2 Datacollections 326 A.3 FormatofAlgorithms 330 A.4 ConversiontoExistingProgrammingLanguages 332 B PracticalVectorsandMatrices 337 B.1 PointsandVectors 338 B.2 Matrices 347 B.3 Conclusion 353 Bibliography 357 Ludography 375 Index 377 xi ListofFigures 1.1 Components,relationships,andaspectsofagame 2 1.2 Model,ViewandControllerinacomputergame 5 1.3 Basicdesignpartsofagame 6 1.4 Thephasesofagamedevelopmentproject 7 1.5 Gamedocuments 9 1.6 Storystructuresasgraphs 16 2.1 MonteCarlomethod 28 2.2 LasVegasmethod 28 2.3 Spectraltest 32 2.4 Spatialpointprocess 36 2.5 Riffleshuffle 40 2.6 Probabilitydistributionofaphantomdie 43 3.1 Twoperturbedsinefunctions 49 3.2 Visualizationofrandomnoisevalues 51 3.3 Agridofdistortedsquares 55 3.4 Simpleinterpolationfunctions 56 3.5 Simpleinterpolationoveranintegergrid 59 3.6 Twonoisecompositionmethods 61 3.7 Tilingwithaperiodicnoise 63 3.8 PhasesofaPerlinnoisegenerator 67 3.9 VariationsofPerlinnoiseonaplane 69 3.10 BasicWorleynoise 74 3.11 AdvancedWorleynoise 75 4.1 Heightmap 82 4.2 Randomlygeneratedterrains 83 4.3 Particledeposition 84 4.4 Faultline 86 4.5 Midpointdisplacement 88 4.6 Comparisonofalabyrinthandamaze 90 4.7 Asquareandhexagonalgridasagraph 90 4.8 Procedurallycreatedmazes 91 4.9 Fibonacciwordsasfractals 96 4.10 PlantcreatedwithanL-system 97 4.11 Roadpatterns 98 4.12 Creatingbuildingsbyextruding 99 xii ListofFigures 4.13 Enumeratingthepositionsofatwo-dimensionalgalaxy 99 4.14 Creatingthestarsystem 101 4.15 GenerationofnumbersinElite 104 5.1 Tournamentsforthesevenbrothers 106 5.2 Bracketforaneliminationtournament 114 5.3 Roundrobintournamentasacliquegraph 119 5.4 Matchesforaroundinaroundrobintournament 120 6.1 Partialgametreefornoughtsandcrosses 130 6.2 DivisionNimwithmatches 131 6.3 GametreeforDivisionNim 132 6.4 Evaluationfunctioninnoughtsandcrosses 135 6.5 Pruningthegametree 138 6.6 Alpha-betapruning 141 6.7 Gametreeforcoppernoughtsandcrosses 150 6.8 Gametreewiththreepossibleoutcomes 154 6.9 Gametreewithintegervalues 154 6.10 PartialgametreeforOne-Two-ThreeNim 155 6.11 PartialgametreeforNimwithheapsofsize1,2and3 156 6.12 n2-PileFlipflop 158 7.1 Reducingreal-worldpathfindingtoagraphproblem 160 7.2 Usingagridtoproducewaypoints 161 7.3 Squaregrid,triangulargrid,andhexagonalgrid 161 7.4 Connectivityinasquaregrid 162 7.5 Navigationmesh 162 7.6 Hertel–Mehlhornmethodforconvexpartition 163 7.7 Expandingtheverticesintheneighbourhood 164 7.8 Exampleofaheuristicfunction 166 7.9 ExampleofAlgorithmA* 168 7.10 Sharpandunrealisticturnsalongthepath 169 7.11 Improvingpathwithline-of-sighttesting 170 7.12 Avoidingdynamicobstacles 171 7.13 Monkey,boxandbanana 172 7.14 Gameworldasapolygon 173 7.15 Onesolutiontotheeight-queensproblem 173 7.16 Two-dimensionalgameworld 174 8.1 Humangroups 176 8.2 Steeringbehaviourrulesofflocking 177 8.3 Basicformationtypes 180 8.4 Formationsmodels 181 8.5 Strategiesforrealizingthemovementintotheformation 183 8.6 Zonesforcontrollingtheformation 184 8.7 Mass–springsystem 186 8.8 Aboxformationfacingacanyon 188 9.1 Decision-makingandpatternrecognition 190 9.2 Predictionandproduction 192 9.3 Optimization 193 9.4 Adaptation 195

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.