Unity 2018 Artificial Intelligence Cookbook - Second Edition

Book description

Explore various recipes to build games using popular artificial intelligence techniques and algorithms such as Navmesh navigation A*, DFS, and UCB1

Key Features

  • Explore different algorithms for creating decision-making agents that go beyond simple behaviors and movement
  • Discover the latest features of the NavMesh API for scripting intelligent behaviour in your game characters
  • Create games that are non-predictable and dynamic and have a high replayability factor

Book Description

Interactive and engaging games come with intelligent enemies, and this intellectual behavior is combined with a variety of techniques collectively referred to as Artificial Intelligence. Exploring Unity's API, or its built-in features, allows limitless possibilities when it comes to creating your game's worlds and characters. This cookbook covers both essential and niche techniques to help you take your AI programming to the next level.

To start with, you'll quickly run through the essential building blocks of working with an agent, programming movement, and navigation in a game environment, followed by improving your agent's decision-making and coordination mechanisms – all through hands-on examples using easily customizable techniques. You'll then discover how to emulate the vision and hearing capabilities of your agent for natural and humanlike AI behavior, and later improve the agents with the help of graphs. This book also covers the new navigational mesh with improved AI and pathfinding tools introduced in the Unity 2018 update. You'll empower your AI with decision-making functions by programming simple board games, such as tic-tac-toe and checkers, and orchestrate agent coordination to get your AIs working together as one.

By the end of this book, you'll have gained expertise in AI programming and developed creative and interactive games.

What you will learn

  • Create intelligent pathfinding agents with popular AI techniques such as A* and A*mbush
  • Implement different algorithms for adding coordination between agents and tactical algorithms for different purposes
  • Simulate senses so agents can make better decisions, taking account of the environment
  • Explore different algorithms for creating decision-making agents that go beyond simple behaviors and movement
  • Create coordination between agents and orchestrate tactics when dealing with a graph or terrain
  • Implement waypoints by making a manual selector

Who this book is for

The Unity 2018 Artificial Intelligence Cookbook is for you if you are eager to get more tools under your belt to solve AI- and gameplay-related problems. Basic knowledge of Unity and prior knowledge of C# is an advantage.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Unity 2018 Artificial Intelligence Cookbook Second Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Get in touch
      1. Reviews
  7. Behaviors - Intelligent Movement
    1. Introduction
    2. Creating the behaviors template
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Pursuing and evading
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Adjusting the agent for physics
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Arriving and leaving
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Facing objects
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Wandering around
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Following a path
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    9. Avoiding agents
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    10. Avoiding walls
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    11. Blending behaviors by weight
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    12. Blending behaviors by priority
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    13. Shooting a projectile
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    14. Predicting a projectile's landing spot
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    15. Targeting a projectile
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    16. Creating a jump system
      1. Getting ready
      2. How to do it...
      3. How it works...
  8. Navigation
    1. Introduction
    2. Representing the world with grids
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Representing the world with points of visibility
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Representing the world with a self-made navigation mesh
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Finding your way out of a maze with DFS
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Finding the shortest path in a grid with BFS
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Finding the shortest path with Dijkstra
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    8. Finding the best-promising path with A*
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Improving A* for memory – IDA*
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    10. Planning navigation in several frames – time-sliced search
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    11. Smoothing a path
      1. Getting ready
      2. How to do it...
      3. How it works...
  9. Decision Making
    1. Introduction
    2. Choosing through a decision tree
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Implementing a finite-state machine
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Improving FSMs: hierarchical finite-state machines
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Implementing behavior trees
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Working with fuzzy logic
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Making decisions with goal-oriented behaviors
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Implementing a blackboard architecture
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    9. Experimenting with Unity's animation state machine
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  10. The New NavMesh API
    1. Introduction
    2. Setting up the NavMesh building components
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Creating and managing NavMesh for multiple types of agents
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Creating and updating NavMesh data at runtime
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Controlling the lifetime of the NavMesh instance
      1. Getting started
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Connecting multiple instances of NavMesh
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Creating dynamic NavMeshes with obstacles
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    8. Implementing some behaviors using the NavMesh API
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  11. Coordination and Tactics
    1. Introduction
    2. Handling formations
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Extending A* for coordination – A*mbush
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Analyzing waypoints by height
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Analyzing waypoints by cover and visibility
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating waypoints automatically
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Exemplifying waypoints for decision making
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    8. Implementing influence maps
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Improving influence with map flooding
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    10. Improving influence with convolution filters
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    11. Building a fighting circle
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  12. Agent Awareness
    1. Introduction
    2. The seeing function using a collider-based system
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. The hearing function using a collider-based system
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. The smelling function using a collider-based system
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. The seeing function using a graph-based system
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. The hearing function using a graph-based system
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. The smelling function using a graph-based system
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    8. Creating awareness in a stealth game
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  13. Board Games and Applied Search AI
    1. Introduction
    2. Working with the game-tree class
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. See also
    3. Implementing Minimax
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. See also
    4. Implementing Negamax
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Implementing AB Negamax
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. See also
    6. Implementing NegaScout
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. See also
    7. Implementing a Tic-Tac-Toe rival
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    8. Implementing a Checkers rival
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
    9. Implementing Rock-Paper-Scissors AI with UCB1
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    10. Implementing regret matching
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  14. Learning Techniques
    1. Introduction
    2. Predicting actions with an N-Gram predictor
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Improving the predictor – Hierarchical N-Gram
      1. Getting ready...
      2. How to do it...
      3. How it works...
    4. Learning to use Naïve Bayes classifier
      1. Getting ready...
      2. How to do it...
      3. How it works...
    5. Implementing reinforcement learning
      1. Getting ready...
      2. How to do it...
      3. How it works...
    6. Implementing artificial neural networks
      1. Getting ready...
      2. How to do it...
      3. How it works...
  15. Procedural Content Generation
    1. Introduction
    2. Creating mazes with Depth-First Search
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Implementing the constructive algorithm for dungeons and islands
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Generating landscapes
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Using N-Grams for content generation
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Generating enemies with the evolutionary algorithm
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  16. Miscellaneous
    1. Introduction
    2. Creating and managing Scriptable Objects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Handling random numbers better
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    4. Building an air-hockey rival
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Implementing an architecture for racing games
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Managing race difficulty using a rubber-band system
      1. Getting ready
      2. How to do it...
      3. How it works...
  17. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Unity 2018 Artificial Intelligence Cookbook - Second Edition
  • Author(s): Jorge Palacios
  • Release date: August 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788626170