How to do it...

In this section, we will be creating two base classes and our fuzzy decision maker:

  1. First, we'll create the MembershipFunction parent class, as shown in the following screenshot:
using UnityEngine; 
using System.Collections; 
 
public class MembershipFunction : MonoBehaviour 
{ 
    public int stateId; 
    public virtual float GetDOM(object input) 
    { 
        return 0f; 
    } 
} 
  1. Next, we'll implement the FuzzyRule class, as follows:
using System.Collections; 
using System.Collections.Generic; 
 
public class FuzzyRule 
{ 
    public List<int> stateIds; 
    public int conclusionStateId; 
}
  1. Then we're going to create the FuzzyDecisionMaker class, as shown in the following code:
using UnityEngine; using System.Collections; using System.Collections.Generic; public ...

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.