ebook img

AI for Games PDF

1031 Pages·2019·55.694 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 AI for Games

AI for Games THIRD EDITION AI for Games THIRD EDITION Ian Millington CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2019 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Printed on acid-free paper Version Date: 20190221 International Standard Book Number-13: 978-1-138-48397-2 (Hardback) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www. copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identifica- tion and explanation without intent to infringe. Library of Congress Cataloging-in-Publication Data Names: Millington, Ian, author. Title: AI for games / Ian Millington. Other titles: AI for games Description: Third edition. | Boca Raton : Taylor & Francis, a CRC title, part of the Taylor & Francis imprint, a member of the Taylor & Francis Group, the academic division of T&F Informa, plc, [2019] | Includes bibliographical references. Identifiers: LCCN 2018041305 | ISBN 9781138483972 (hardback : acid-free paper) Subjects: LCSH: Computer games--Programming. | Computer animation. | Artificial intelligence. Classification: LCC QA76.76.C672 M549 2019 | DDC 794.8/1525--dc23 LC record available at https://lccn.loc.gov/2018041305 Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com Daniel for myfavoritegamedesigner CONTENTS PART I AI and Games 1 CHAPTER INTRODUCTION 3 1 1.1 WhatIsAI? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1.1 AcademicAI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1.2 GameAI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.2 ModelofGameAI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2.1 Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.2.2 DecisionMaking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.2.3 Strategy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2.4 Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2.5 Agent-BasedAI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.2.6 IntheBook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.3 AlgorithmsandDataStructures . . . . . . . . . . . . . . . . . . . . . . 14 1.3.1 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 1.3.2 Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.3.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.4 LayoutoftheBook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 CHAPTER GAME AI 21 2 2.1 TheComplexityFallacy . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.1.1 WhenSimpleThingsLookGood . . . . . . . . . . . . . . . . . . . . 21 2.1.2 WhenComplexThingsLookBad . . . . . . . . . . . . . . . . . . . . 22 2.1.3 ThePerceptionWindow . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.1.4 ChangesofBehavior . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.2 TheKindofAIinGames . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.2.1 Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.2.2 Heuristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.2.3 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 vii viii CONTENTS 2.3 SpeedandMemoryConstraints . . . . . . . . . . . . . . . . . . . . . . 28 2.3.1 ProcessorIssues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.3.2 MemoryConcerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.3.3 Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.4 TheAIEngine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.4.1 StructureofanAIEngine . . . . . . . . . . . . . . . . . . . . . . . . 35 2.4.2 ToolConcerns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 2.4.3 PuttingItAllTogether . . . . . . . . . . . . . . . . . . . . . . . . . . 37 PART II Techniques 39 CHAPTER MOVEMENT 41 3 3.1 TheBasicsofMovementAlgorithms . . . . . . . . . . . . . . . . . . . 42 3.1.1 Two-DimensionalMovement . . . . . . . . . . . . . . . . . . . . . . 43 3.1.2 Statics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 3.1.3 Kinematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.2 KinematicMovementAlgorithms . . . . . . . . . . . . . . . . . . . . . 51 3.2.1 Seek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.2.2 Wandering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.3 SteeringBehaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.3.1 SteeringBasics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.3.2 VariableMatching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.3.3 SeekandFlee. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.3.4 Arrive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 3.3.5 Align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.3.6 VelocityMatching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 3.3.7 DelegatedBehaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.3.8 PursueandEvade . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.3.9 Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 3.3.10 LookingWhereYou’reGoing . . . . . . . . . . . . . . . . . . . . . . 72 3.3.11 Wander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 3.3.12 PathFollowing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.3.13 Separation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 3.3.14 CollisionAvoidance . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 3.3.15 ObstacleandWallAvoidance . . . . . . . . . . . . . . . . . . . . . . 90 3.3.16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 CONTENTS ix 3.4 CombiningSteeringBehaviors . . . . . . . . . . . . . . . . . . . . . . 95 3.4.1 BlendingandArbitration . . . . . . . . . . . . . . . . . . . . . . . . 96 3.4.2 WeightedBlending. . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 3.4.3 Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 3.4.4 CooperativeArbitration . . . . . . . . . . . . . . . . . . . . . . . . . 106 3.4.5 SteeringPipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 3.5 PredictingPhysics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 3.5.1 AimingandShooting . . . . . . . . . . . . . . . . . . . . . . . . . . 120 3.5.2 ProjectileTrajectory . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 3.5.3 TheFiringSolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 3.5.4 ProjectileswithDrag. . . . . . . . . . . . . . . . . . . . . . . . . . . 126 3.5.5 IterativeTargeting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 3.6 Jumping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 3.6.1 JumpPoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 3.6.2 LandingPads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.6.3 HoleFillers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 3.7 CoordinatedMovement . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 3.7.1 FixedFormations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 3.7.2 ScalableFormations . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 3.7.3 EmergentFormations . . . . . . . . . . . . . . . . . . . . . . . . . . 146 3.7.4 Two-LevelFormationSteering . . . . . . . . . . . . . . . . . . . . . 147 3.7.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 3.7.6 ExtendingtoMoreThanTwoLevels . . . . . . . . . . . . . . . . . . 156 3.7.7 SlotRolesandBetterAssignment . . . . . . . . . . . . . . . . . . . . 158 3.7.8 SlotAssignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 3.7.9 DynamicSlotsandPlays . . . . . . . . . . . . . . . . . . . . . . . . . 164 3.7.10 TacticalMovement. . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 3.8 MotorControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 3.8.1 OutputFiltering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 3.8.2 Capability-SensitiveSteering . . . . . . . . . . . . . . . . . . . . . . 173 3.8.3 CommonActuationProperties . . . . . . . . . . . . . . . . . . . . . 174 3.9 MovementintheThirdDimension . . . . . . . . . . . . . . . . . . . . 177 3.9.1 RotationinThreeDimensions. . . . . . . . . . . . . . . . . . . . . . 178 3.9.2 ConvertingSteeringBehaviorstoThreeDimensions . . . . . . . . . . 179 3.9.3 Align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 3.9.4 AligntoVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 3.9.5 Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 3.9.6 LookWhereYou’reGoing . . . . . . . . . . . . . . . . . . . . . . . . 185 3.9.7 Wander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 3.9.8 FakingRotationAxes . . . . . . . . . . . . . . . . . . . . . . . . . . 187

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.