Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Practical Game AI Programming
Practical Game AI Programming

Practical Game AI Programming: Unleash the power of Artificial Intelligence to your game

Arrow left icon
Profile Icon DaGraça
Arrow right icon
€8.99 €32.99
eBook Jun 2017 348 pages 1st Edition
eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon DaGraça
Arrow right icon
€8.99 €32.99
eBook Jun 2017 348 pages 1st Edition
eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Practical Game AI Programming

Possibility and Probability Maps

In this chapter, we'll be talking about possibility and probability maps, understanding how and where they are used. We'll also be learning the best practices for creating an AI that reacts to the player and that also chooses the best options, as we look to create a character that can make decisions as a human would.

As we saw previously, video games used to rely heavily on predetermining the behavior of what the AI could do in different scenarios that were either created by the game itself or by the player's actions. This method has been present since day one and is still being used today, making it an extremely valuable method for creating quality AI characters. Before explaining, in detail, what each of the maps do, and before demonstrating how to create them in order to develop good AI behavior, it's always good to have...

Game states

To understand how to create possibility or probability maps we need to first acknowledge the principle aspect necessary to create them, which is called game states, or simply states. We call game states to the actions that are predetermined throughout different occasions in the game, and those actions can be applied to both the player or to the enemy character. Some examples can be simple behavior, such as run, jump, or attack, and those states can be expanded a little more, for example when the character is in the air and cannot attack or if the character has low magical energy and cannot perform a magic attack. In these cases, the character goes from one state to another or can't perform one if it's doing another.

Possibility maps

Now let's take a deeper look at the possibility maps that we encountered in the examples in the first chapter, from the chess machine to the Metal Gear Solid video game. As we can see, it's a technique that is still being used today, and it is almost impossible to create a game AI without it.

As the name suggests, possibility maps allow the programmer to define the possibilities available to the player or the AI character within the game. Everything that is possible inside the game needs to be planned and coded, but what happens when you allow the character to do a lot of things can they do them all at the same time? If played during different stages of the game, can they react in the same way at all of the stages? To allow, and restrain, the possible actions, we also need to think about the possible scenarios that can occur in the game, and when you...

Defining the states

Let's define what triggers each state and how the AI should choose the correct state in different scenarios. The PASSIVE state will be the default state, and the game will start in that position until the player comes across our character. The DEFENSIVE state will be used in two different situations if the player comes from the right side and if he has already confronted the player and has low HP. Finally, the AGGRESSIVE state will be activated if the player comes from the left side or has already arrived at the middle area:

public class Enemy : MonoBehaviour {
private int Health = 100;
private bool statePassive;
private bool stateAggressive;
private bool stateDefensive;
private bool triggerL;
private bool triggerR;
private bool triggerM;
// Use this for initialisation
void Start () {
statePassive = true;
}
// Update is called once per frame
void Update ...

Probability maps

A probability map is a more complex and detailed version of a possibility map because it relies on probabilities in order to change the behavior of the character, rather than a simple on or off trigger. Its similarity with the possibility map is that it's also required for planning ahead the possible states for our character. This time, however, we add to it a percentage, using which the AI will calculate what behavior he will be using. Imagine the next example using the situation that we previously created for the possibility map our enemy AI could be more aggressive in the daytime than at night. For that, we create a statement that explains to our enemy that if it's night time, there is a lesser chance of seeing the player character, and for that reason it will choose a more defensive approach instead of an aggressive one. Or, simply, we could define...

Summary

This chapter has described possibility and probability maps and we have learned how to let the AI take decisions for itself according to the player actions. Possibility and probability maps is the foundation of an AI character and now we can explore this technique to create new and unique artificial intelligence for our games. In the next chapter, we'll learn how the AI should behave according to the different options that it has on that moment instead of using a possibility map. We want the character to analyze the situation and think about what to do, taking in consideration many factors, such as health, distance, weapon, bullets, and any other relevant factors.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Move beyond using libraries to create smart game AI, and create your own AI projects from scratch
  • Implement the latest algorithms for AI development and in-game interaction
  • Customize your existing game AI and make it better and more efficient to improve your overall game performance

Description

The book starts with the basics examples of AI for different game genres and directly jumps into defining the probabilities and possibilities of the AI character to determine character movement. Next, you’ll learn how AI characters should behave within the environment created. Moving on, you’ll explore how to work with animations. You’ll also plan and create pruning strategies, and create Theta algorithms to find short and realistic looking game paths. Next, you’ll learn how the AI should behave when there is a lot of characters in the same scene. You'll explore which methods and algorithms, such as possibility maps, Forward Chaining Plan, Rete Algorithm, Pruning Strategies, Wall Distances, and Map Preprocess Implementation should be used on different occasions. You’ll discover how to overcome some limitations, and how to deliver a better experience to the player. By the end of the book, you think differently about AI.

Who is this book for?

This book is for game developers with a basic knowledge of game development techniques and some basic programming techniques in C# or C++.

What you will learn

  • Get to know the basics of how to create different AI for different type of games
  • Know what to do when something interferes with the AI choices and how the AI should behave if that happens
  • Plan the interaction between the AI character and the environment using Smart Zones or Triggering Events
  • Use animations correctly, blending one animation into another and rather than stopping one animation and starting another
  • Calculate the best options for the AI to move using Pruning Strategies, Wall Distances, Map Preprocess Implementation, and Forced Neighbours
  • Create Theta algorithms to the AI to find short and realistic looking paths
  • Add many characters into the same scene and make them behave like a realistic crowd

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 30, 2017
Length: 348 pages
Edition : 1st
Language : English
ISBN-13 : 9781787129467
Vendor :
Unity Technologies
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jun 30, 2017
Length: 348 pages
Edition : 1st
Language : English
ISBN-13 : 9781787129467
Vendor :
Unity Technologies
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 111.97
Practical Game AI Programming
€41.99
Game Development Patterns and Best Practices
€36.99
Game Physics Cookbook
€32.99
Total 111.97 Stars icon
Banner background image

Table of Contents

10 Chapters
Different Problems Require Different Solutions Chevron down icon Chevron up icon
Possibility and Probability Maps Chevron down icon Chevron up icon
Production System Chevron down icon Chevron up icon
Environment and AI Chevron down icon Chevron up icon
Animation Behaviors Chevron down icon Chevron up icon
Navigation Behavior and Pathfinding Chevron down icon Chevron up icon
Advanced Pathfinding Chevron down icon Chevron up icon
Crowd Interactions Chevron down icon Chevron up icon
AI Planning and Collision Avoidance Chevron down icon Chevron up icon
Awareness Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.