//float value; // Use this for initialization void Start() { xMax = 100; xMin = 0; good = new RightShoulderGraph(50, 75, 1.0f); neutral = new Peak(25, 50, 75, 1.0f); evil = new LeftShoulderGraph(25, 50, 1.0f); chaotic = new Peak(20, 60, 80, 1.0f); lawful = new Peak(0, 40, 80, 1.0f); cNeutral = new Peak(20, 50, 80, 0.75f); rules = new MoralityRuleset(); }
float DefuzzifyMorality() { float tLP = (neutral.GetMin() + (neutral.GetMid() - neutral.GetMin()) * fuzzyNeutral); float tRP = (neutral.GetMax() + (neutral.GetMid() - neutral.GetMax()) * fuzzyNeutral); float crispDefuz = 0; Trapezoid defuzPeak = new Trapezoid(25, tLP, tRP, 75, fuzzyNeutral); LeftShoulderGraph defuzL = new LeftShoulderGraph(25, 50, fuzzyEvil); RightShoulderGraph defuzR = new RightShoulderGraph(50, 75, fuzzyGood); float eRepValue; float nRepValue; float gRepValue; eRepValue = (defuzL.GetMin() + xMin) / 2; nRepValue = (defuzPeak.GetLMax() + defuzPeak.GetRMin()) / 2; gRepValue = (defuzR.GetMax() + xMax) / 2; float numerator = (eRepValue * fuzzyEvil) + (nRepValue * fuzzyNeutral) + (gRepValue * fuzzyGood); float denominator = (fuzzyEvil + fuzzyGood + fuzzyNeutral); crispDefuz = numerator / denominator; return(crispDefuz); }