We can create an example membership function to define whether an enemy is in enraged mode, knowing that its life points (ranging from zero to 100) are equal to or less than 30.
The following is the code for the example MFEnraged class:
using UnityEngine; using System; using System.Collections; public class MFEnraged : MembershipFunction { public override float GetDOM(object input) { if ((int)input <= 30) return 1f; return 0f; } }
It's worth noting that it is a common requirement to have a complete set of rules; one for each combination of states from each input. This gives the recipe a lack of scalability, but it works well for a smaller number of input variables and a small number of states per variable.