AI for Game Developers

Book description

Advances in 3D visualization and physics-based simulation technology make it possible for game developers to create compelling, visually immersive gaming environments that were only dreamed of years ago. But today's game players have grown in sophistication along with the games they play. It's no longer enough to wow your players with dazzling graphics; the next step in creating even more immersive games is improved artificial intelligence, or AI.Fortunately, advanced AI game techniques are within the grasp of every game developer--not just those who dedicate their careers to AI. If you're new to game programming or if you're an experienced game programmer who needs to get up to speed quickly on AI techniques, you'll find AI for Game Developers to be the perfect starting point for understanding and applying AI techniques to your games.Written for the novice AI programmer, AI for Game Developers introduces you to techniques such as finite state machines, fuzzy logic, neural networks, and many others, in straightforward, easy-to-understand language, supported with code samples throughout the entire book (written in C/C++). From basic techniques such as chasing and evading, pattern movement, and flocking to genetic algorithms, the book presents a mix of deterministic (traditional) and non-deterministic (newer) AI techniques aimed squarely at beginners AI developers. Other topics covered in the book include:

  • Potential function based movements: a technique that handles chasing, evading swarming, and collision avoidance simultaneously
  • Basic pathfinding and waypoints, including an entire chapter devoted to the A* pathfinding algorithm
  • AI scripting
  • Rule-based AI: learn about variants other than fuzzy logic and finite state machines
  • Basic probability
  • Bayesian techniques
Unlike other books on the subject, AI for Game Developers doesn't attempt to cover every aspect of game AI, but to provide you with usable, advanced techniques you can apply to your games right now. If you've wanted to use AI to extend the play-life of your games, make them more challenging, and most importantly, make them more fun, then this book is for you.

Publisher resources

View/Submit Errata

Table of contents

  1. AI for Game Developers
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Assumptions This Book Makes
    2. About This Book
    3. Conventions Used in This Book
    4. Additional Resources
    5. Using Code Examples
    6. How to Contact Us
    7. Acknowledgments
  4. 1. Introduction to Game AI
    1. Deterministic Versus Nondeterministic AI
    2. Established Game AI
    3. The Future of Game AI
  5. 2. Chasing and Evading
    1. Basic Chasing and Evading
    2. Line-of-Sight Chasing
    3. Line-of-Sight Chasing in Tiled Environments
    4. Line-of-Sight Chasing in Continuous Environments
    5. Intercepting
  6. 3. Pattern Movement
    1. Standard Algorithm
    2. Pattern Movement in Tiled Environments
    3. Pattern Movement in Physically Simulated Environments
      1. Control Structures
      2. Pattern Definition
      3. Executing the Patterns
      4. DoPattern Function
      5. Results
  7. 4. Flocking
    1. Classic Flocking
    2. Flocking Example
      1. Steering Model
      2. Neighbors
      3. Cohesion
      4. Alignment
      5. Separation
    3. Obstacle Avoidance
    4. Follow the Leader
  8. 5. Potential Function-Based Movement
    1. How Can You Use Potential Functions for Game AI?
      1. So, What Is a Potential Function?
    2. Chasing/Evading
    3. Obstacle Avoidance
    4. Swarming
    5. Optimization Suggestions
  9. 6. Basic Pathfinding and Waypoints
    1. Basic Pathfinding
      1. Random Movement Obstacle Avoidance
      2. Tracing Around Obstacles
    2. Breadcrumb Pathfinding
    3. Path Following
    4. Wall Tracing
    5. Waypoint Navigation
  10. 7. A∗ Pathfinding
    1. Defining the Search Area
    2. Starting the Search
    3. Scoring
    4. Finding a Dead End
    5. Terrain Cost
    6. Influence Mapping
    7. Further Information
  11. 8. Scripted AI and Scripting Engines
    1. Scripting Techniques
    2. Scripting Opponent Attributes
    3. Basic Script Parsing
    4. Scripting Opponent Behavior
    5. Scripting Verbal Interaction
    6. Scripting Events
    7. Further Information
  12. 9. Finite State Machines
    1. Basic State Machine Model
    2. Finite State Machine Design
      1. Finite State Machine Structures and Classes
      2. Finite State Machine Behavior and Transition Functions
    3. Ant Example
      1. Finite State Machine Classes and Structures
      2. Defining the Simulation World
      3. Populating the World
      4. Updating the World
        1. Forage
        2. GoHome
        3. Thirsty
        4. The Results
    4. Further Information
  13. 10. Fuzzy Logic
    1. How Can You Use Fuzzy Logic in Games?
      1. Control
      2. Threat Assessment
      3. Classification
    2. Fuzzy Logic Basics
      1. Overview
      2. Fuzzification
        1. Membership Functions
        2. Hedges
      3. Fuzzy Rules
        1. Fuzzy Axioms
        2. Rule Evaluation
      4. Defuzzification
    3. Control Example
    4. Threat Assessment Example
  14. 11. Rule-Based AI
    1. Rule-Based System Basics
      1. Inference in Rule-Based Systems
        1. Forward Chaining
        2. Backward Chaining
    2. Fighting Game Strike Prediction
      1. Working Memory
      2. Rules
      3. Initialization
      4. Strike Prediction
        1. Part 1
        2. Part 2
        3. Part 3
    3. Further Information
  15. 12. Basic Probability
    1. How Do You Use Probability in Games?
      1. Randomness
      2. Hit Probabilities
      3. Character Abilities
      4. State Transitions
      5. Adaptability
    2. What is Probability?
      1. Classical Probability
      2. Frequency Interpretation
      3. Subjective Interpretation
        1. Odds
        2. Expectation
        3. Techniques for Assigning Subjective Probability
    3. Probability Rules
      1. Rule 1
      2. Rule 2
      3. Rule 3
      4. Rule 4
      5. Rule 5
      6. Rule 6
    4. Conditional Probability
  16. 13. Decisions Under Uncertainty—Bayesian Techniques
    1. What is a Bayesian Network?
      1. Structure
      2. Inference
    2. Trapped?
      1. Tree Diagram
      2. Determining Probabilities
      3. Making Inferences
      4. Using Fuzzy Logic
    3. Treasure?
      1. Alternative Model
      2. Making Inferences
      3. Numerical Example
    4. By Air or Land
      1. The Model
      2. Calculating Probabilities
      3. Numerical Example
    5. Kung Fu Fighting
      1. The Model
      2. Calculating Probabilities
      3. Strike Prediction
        1. Bookkeeping
        2. Making the Prediction
    6. Further Information
  17. 14. Neural Networks
      1. Control
      2. Threat Assessment
      3. Attack or Flee
    1. Dissecting Neural Networks
      1. Structure
      2. Input
        1. Input: What and How Many?
        2. Input: What Form?
      3. Weights
      4. Activation Functions
      5. Bias
      6. Output
      7. The Hidden Layer
    2. Training
      1. Back-Propagation Training
        1. Computing Error
        2. Adjusting Weights
        3. Momentum
    3. Neural Network Source Code
      1. The Layer Class
      2. The Neural Network Class
    4. Chasing and Evading with Brains
      1. Initialization and Training
      2. Learning
    5. Further Information
  18. 15. Genetic Algorithms
    1. Evolutionary Process
      1. First Generation
      2. Ranking Fitness
      3. Selection
      4. Evolution
    2. Evolving Plant Life
      1. Encoding the Flower Data
      2. First Flower Generation
      3. Ranking Flower Fitness
      4. Evolving the Flowers
    3. Genetics in Game Development
      1. Role-Playing Example
      2. Encoding the Data
        1. The First Generation
        2. Ranking Fitness
        3. Selection
        4. Evolution
    4. Further Information
  19. A. Vector Operations
    1. Vector Class
    2. Magnitude
      1. Normalize
      2. Reverse
      3. Vector Addition: The += Operator
      4. Vector Subtraction: The −= Operator
      5. Scalar Multiplication: The ∗= Operator
      6. Scalar Division: The /= Operator
      7. Conjugate: The − Operator
    3. Vector Functions and Operators
      1. Vector Addition: The + Operator
      2. Vector Subtraction: The − Operator
      3. Vector Cross Product: The ⁁Operator
      4. Vector Dot Product: The * Operator
      5. Scalar Multiplication: The * Operator
      6. Scalar Division: The / Operator
      7. Triple Scalar Product
  20. About the Authors
  21. Colophon
  22. Copyright

Product information

  • Title: AI for Game Developers
  • Author(s): David M Bourg, Glenn Seemann
  • Release date: July 2004
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491900109