How to do it...

This recipe requires a lot of attention due to the number of files that we will need to handle. Overall, we will create a parent class DecisionTreeNode, from which we will derive the other ones. Finally, we will learn how to implement a couple of standard decision nodes:

  1. First, create the DecisionTreeNode parent class, as shown in the following code:
using UnityEngine; 
using System.Collections; 
public class DecisionTreeNode : MonoBehaviour 
{ 
    public virtual DecisionTreeNode MakeDecision() 
    { 
        return null; 
    } 
} 
  1. Next, create the Decision pseudo-abstract class, deriving from the parent class, DecisionTreeNode, as demonstrated in the following code:
using UnityEngine; using System.Collections; public class Decision : DecisionTreeNode ...

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.