39,59 €
Build and customize a wide range of powerful Unity AI systems with over 70 hands-on recipes and techniques
This book is intended for those who already have a basic knowledge of Unity and are eager to get more tools under their belt to solve AI and gameplay-related problems.
Unity 5 comes fully packaged with a toolbox of powerful features to help game and app developers create and implement powerful game AI. Leveraging these tools via Unity's API or built-in features allows limitless possibilities when it comes to creating your game's worlds and characters. This practical Cookbook covers both essential and niche techniques to help you be able to do that and more.
This Cookbook is engineered as your one-stop reference to take your game AI programming to the next level. Get to grips with the essential building blocks of working with an agent, programming movement and navigation in a game environment, and improving your agent's decision making and coordination mechanisms - all through hands-on examples using easily customizable techniques. Discover how to emulate vision and hearing capabilities for your agent, for natural and humanlike AI behaviour, and improve them with the help of graphs. Empower your AI with decision-making functions through programming simple board games such as Tic-Tac-Toe and Checkers, and orchestrate agent coordination to get your AIs working together as one.
This recipe-based guide will take you through implementing various AI algorithms. Each topic is explained and placed among other related techniques, sometimes building on the knowledge from previous chapters. There are also references to more technical books and papers, so you can dig deeper if you want to.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 232
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2016
Production reference: 1230316
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78355-357-0
www.packtpub.com
Cover image by Andrés Rodolfo De León Mariola (<[email protected]>)
Author
Jorge Palacios
Reviewers
Jack Donovan
Lauren S. Ferro
Commissioning Editor
Akram Hussain
Acquisition Editors
Mohammad Rizvi
Usha Iyer
Content Development Editor
Kirti Patil
Technical Editor
Deepti Tuscano
Copy Editor
Angad Singh
Project Coordinator
Nidhi Joshi
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
Jorge Palacios is a software developer with seven years of professional experience. He has committed the last four years to game development working in various positions; from tool developer, to lead programmer. His main focus is AI and gameplay programming, and currently he works with Unity and HTML5. He's also a game development instructor, speaker, and game jam organizer.
You can find more about him on http://jorge.palacios.co
I'd like to dedicate this book to my parents; Betty and Elieser. They have given me all of their support for several years, and believed in me every step of the way. Words cannot express how grateful I am for having them in my life. This work is proof that dreams can be achieved when you turn them into goals.
Thanks to my partner in bits and codes, Christian Chomiak. His support and feedback is appreciated on every adventure, and every algorithm. Let's co-author the next book!
"If I have seen further it is by standing on the shoulder of Giants"
--Isaac NewtonI'll always be grateful to Ricardo Monascal and Carlos Pérez. Their support, friendship and guidance allowed be to become a big deal of the developer I am today. I have seen further because of you.
I'm really happy to have Andrés De León's artwork as cover image.
Thanks to Ruchita Bhansali, Usha Iyer, Kirti Patil, Deepti Tuscano, and all the Packt team involved in this project. They are an awesome team to work with, and I cannot express how grateful I am for their patience and support along the way. I learned a lot from you and the whole process of ting and finishing a book. This book is your as much as it is mine.
Jack Donovan is a game developer and software engineer who has been working with the Unity3D engine since its third major release. He studied at Champlain College in Burlington, Vermont, where he received a BS in game programming.
Jack currently works at IrisVR, a virtual reality startup in New York City, where he is developing software that allows architects to generate virtual reality experiences from their CAD models. Before IrisVR, Jack worked on a small independent game team with fellow students, where he wrote the book, OUYA Game Development By Example.
Lauren S. Ferro is a gamification consultant and designer of games and game-like applications. She has worked, designed, consulted, and implemented strategies for a range of different purposes from the fields of professional development, recommendation systems, and educational games. She is an active researcher in the area of gamification, player profiling, and user-centered game design. She runs workshops for both the general public and companies that focus on designing user-centered games and game-like applications. She is also the developer of the game design resource Gamicards, which is a paper-prototyping tool for both games and game-like experiences.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
When we think about artificial intelligence, a lot of topics may come to mind. From simple behaviors such as following or escaping from the player, through the classical Chess-rival AI, to state-of-the-art techniques in Machine Learning or procedural content generation.
Talking about Unity means talking about game development democratization. Thanks to its ease of use, fast-paced technological improvement, an ever-growing community of developers, and the new cloud services offered, Unity has become one of the most important game industry software.
With all that in mind, the main goal in writing this book is to offer you, the reader, both technical insight into Unity, following best practices and conventions, and theoretical knowledge that help you grasp artificial intelligence concepts and techniques, so you could get the best of both worlds for your own personal and professional development.
This cookbook will introduce you to the tools to build great AI; either for creating better enemies, polishing that final boss, or even building your own customized AI engine. It aims to be your one-stop reference for developing artificial intelligence techniques in Unity.
Welcome to an exciting journey that combines a variety of things that means a lot to me as a professional and human being; programming, game development, artificial intelligence, and sharing knowledge with other developers. I cannot stress how humbled and happy I am to be read by you right now, and grateful to the team at Packt for this formidable opportunity. I hope this material helps you not only take your Unity and artificial intelligence skills to new levels, but also deliver that feature that will engage players into your game.
Chapter 1, Behaviors – Intelligent Movement, explores some of the most interesting movement algorithms based on the steering behavior principles developed by Craig Reynolds along with work from Ian Millington. They act as a foundation for most of the AI used in advanced games and other algorithms that rely on movement, such as the family of path-finding algorithms.
Chapter 2, Navigation, explores path-finding algorithms for navigating complex scenarios. It will include some ways to represent the world using different kinds of graph structures, and several algorithms for finding a path, each aimed at different situations.
Chapter 3, Decision Making, shows the different decision-making techniques that are flexible enough to adapt to different types of games, and robust enough to let us build modular decision-making systems.
Chapter 4, Coordination and Tactics, deals with a number of different recipes for coordinating different agents as a whole organism, such as formations and techniques that allow us make tactical decisions based on graphs, such as waypoints and influence maps.
Chapter 5, Agent Awareness, deals with different approaches of simulating sense stimuli on an agent. We will learn how to use tools that we already know to create these simulations, colliders, and graphs.
Chapter 6, Board Games AI, explains a family of algorithms for developing board-game techniques to create artificial intelligence.
Chapter 7, Learning Techniques, explores the field of machine learning. It will give us a great head start in our endeavor to learn and apply machine-learning techniques to our games.
Chapter 8, Miscellaneous, introduces new techniques and uses algorithms that we have learned about in previous chapters in order to create new behaviors that don't quite fit in a definite category.
The examples were tested and are provided using the latest version of Unity by the time of finishing this material, which is Unity 5.3.4f1. However, the book content started its development on Unity 5.1.2, so this is the minimum recommended version to work with.
This book is aimed at those who already have basic knowledge of Unity and are eager to get more tools under their belt in order to solve AI and gameplay-related problems.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/Unity5xGameAIProgrammingCookbook_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we will develop AI algorithms for movement by covering the following recipes:
Unity has been one of the most popular game engines for quite a while now, and it's probably the de facto game development tool for indie developers, not only because of its business model, which has a low entry barrier, but also because of its robust project editor, year-by-year technological improvement, and most importantly, ease of use and an ever-growing community of developers around the globe.
Thanks to Unity's heavy lifting behind the scenes (rendering, physics, integration, and cross-platform deployment, just to name a few) it's possible for us to focus on creating the AI systems that will bring to life our games, creating great real-time experiences in the blink of an eye.
The goal of this book is to give you the tools to build great AI, for creating better enemies, polishing that final boss, or even building your own customized AI engine.
In this chapter, we will start by exploring some of the most interesting movement algorithms based on the steering behavior principles developed by Craig Reynolds, along with work from Ian Millington. These recipes are the stepping stones for most of the AI used in advanced games and other algorithms that rely on movement, such as the family of path-finding algorithms.
Pursuing and evading are great behaviors to start with because they rely on the most basic behaviors and extend their functionality by predicting the target's next step.
