Exemple #1
0
        public void setup()
        {
            //TextAsset MembershipFunctTextAsset =
            //    Resources.Load("MembershipFunctions") as TextAsset;
            LinguisticVariable = new LinguisticVariable();
            MFs = new List <MembershipFunction>();
            LRs = new List <LinguisticRule>();
            MFs.Add(MembershipFunction.Generate("EasyFight", "Triangle", new double[] { -1, 3, 5 }, 5));
            MFs.Add(MembershipFunction.Generate("NormalFight", "Trapezoid", new double[] { 4, 5, 9, 11 }, 9));
            MFs.Add(MembershipFunction.Generate("HardFight", "Triangle", new double[] { 10, 15, 17 }, 15));
            LRs.Add(new LinguisticRule(
                        "HardFight",
                        "Health High and Power High",
                        FuzzyImplication.Lukasiewicz,
                        FuzzyOperator.Probabilistic));
            LRs.Add(new LinguisticRule(
                        "NormalFight",
                        "Health Low and Power Medium",
                        FuzzyImplication.KleeneDienes,
                        FuzzyOperator.Probabilistic));
            LRs.Add(new LinguisticRule(
                        "EasyFight",
                        "Health Medium and Power Low",
                        FuzzyImplication.Larson,
                        FuzzyOperator.MinMax));
            JsonLingVar =
                @"
{
    ""Version"" : """ + Version + @""",
    ""LinguisticVariable"" : """ + Name + @""",
    ""Type"" : """ + Type + @""",
    ""MinimumValue"" : " + minVal + @",
    ""RangeLength"" : " + RangeLen + @",
    ""LinguisticValues"" : 
    [
    ";
            foreach (MembershipFunction MF in MFs)
            {
                JsonLingVar += MF.encodeLinguisticJson().Print(true);
                if (!MF.Equals(MFs[MFs.Count - 1]))
                {
                    JsonLingVar += ",";
                }
            }
            JsonLingVar +=
                @"
    ],
    ""LinguisticRule"" : 
    [";
            foreach (LinguisticRule LR in LRs)
            {
                JsonLingVar += LR.encodeLinguisticJson().Print(true);
                if (!LR.Equals(LRs[LRs.Count - 1]))
                {
                    JsonLingVar += ",";
                }
            }
            JsonLingVar +=
                @"]
}
";
        }