Getting ready

We need to define certain data structures for setting up everything before implementing the main steps:

  1. First, we'll create the data structure for handling data bits in a flexible manner, as shown in the following code:
public struct BlackboardDatum{  public int id;  public string type;  public object value;}
  1. Next, we'll create the class defining the expert, as follows:
public abstract class BlackboardExpert{  public virtual float GetInsistence(Blackboard board)  {    return 0f;  }  public virtual void Run(Blackboard board){}}
  1. Then, we create the data structure for saving actions taken by the experts, as shown in the following code:
public struct BlackboardAction{  public object expert;  public string name; public System.Action action; ...

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.