コード例 #1
0
    private void Awake()
    {
        fm = new FuzzyModule();
        FuzzyVariable DistToTarget = fm.CreateFLV("DistToTarget");

        FzSet Target_Close  = DistToTarget.AddLeftShoulderSet("Target_Close", 0, 25, 150);
        FzSet Target_Medium = DistToTarget.AddTriangleSet("Target_Medium", 25, 50, 300);
        FzSet Target_Far    = DistToTarget.AddRightShoulderSet("Target_Far", 150, 300, 500);

        FuzzyVariable AmmoStatus = fm.CreateFLV("AmmoStatus");

        FzSet Ammo_Low   = AmmoStatus.AddLeftShoulderSet("Ammo_Low", 0, 0, 10);
        FzSet Ammo_Okay  = AmmoStatus.AddTriangleSet("Ammo_Okay", 0, 10, 30);
        FzSet Ammo_Loads = AmmoStatus.AddRightShoulderSet("Ammo_Loads", 10, 30, 40);

        FuzzyVariable Desirability = fm.CreateFLV("Desirablility");

        FzSet Undersirable  = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
        FzSet Desirable     = Desirability.AddTriangleSet("Desirable", 25, 50, 75);
        FzSet VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);

        fm.AddRule(new FzAND(Target_Close, Ammo_Low), Undersirable);
        fm.AddRule(new FzAND(Target_Close, Ammo_Okay), Undersirable);
        fm.AddRule(new FzAND(Target_Close, Ammo_Loads), Undersirable);
        fm.AddRule(new FzAND(Target_Medium, Ammo_Low), Desirable);
        fm.AddRule(new FzAND(Target_Medium, Ammo_Okay), VeryDesirable);
        fm.AddRule(new FzAND(Target_Medium, Ammo_Loads), VeryDesirable);
        fm.AddRule(new FzAND(Target_Far, Ammo_Low), Undersirable);
        fm.AddRule(new FzAND(Target_Far, Ammo_Okay), Desirable);
        fm.AddRule(new FzAND(Target_Far, Ammo_Loads), Desirable);
    }
コード例 #2
0
ファイル: GameWorld.cs プロジェクト: poeely/UnityAAI
    private void InitPromisingRegionFM()
    {
        // Promising Region FuzzyModule
        promisingRegionFM = new FuzzyModule();
        FuzzyVariable DistToRegion = promisingRegionFM.CreateFLV("DistToRegion");

        FzSet Dist_Close  = DistToRegion.AddLeftShoulderSet("Dist_Close", 0, 50, 150);
        FzSet Dist_Medium = DistToRegion.AddTriangleSet("Dist_Medium", 50, 150, 200);
        FzSet Dist_Far    = DistToRegion.AddRightShoulderSet("Dist_Far", 150, 250, 300);

        FuzzyVariable RegionWealth = promisingRegionFM.CreateFLV("RegionWealth");

        FzSet Region_Poor   = RegionWealth.AddLeftShoulderSet("Region_Poor", 0, 300, 750);
        FzSet Region_Decent = RegionWealth.AddTriangleSet("Region_Decent", 750, 1500, 2700);
        FzSet Region_Rich   = RegionWealth.AddRightShoulderSet("Region_Rich", 2250, 2700, Region.MAX_RESOURCE_COUNT);

        FuzzyVariable Desirability = promisingRegionFM.CreateFLV("Desirability");

        FzSet Undersirable   = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
        FzSet Desirable      = Desirability.AddTriangleSet("Desirable", 25, 50, 75);
        FzSet Very_Desirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);

        promisingRegionFM.AddRule(new FzAND(Dist_Close, Region_Poor), Undersirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Close, Region_Decent), Desirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Close, Region_Rich), Very_Desirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Medium, Region_Poor), Undersirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Medium, Region_Decent), Undersirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Medium, Region_Rich), Very_Desirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Far, Region_Poor), Undersirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Far, Region_Decent), Undersirable);
        promisingRegionFM.AddRule(new FzAND(Dist_Far, Region_Rich), Very_Desirable);
    }
コード例 #3
0
        public Thirst() : base()
        {
            _module = new FuzzyModule();

            // Antecedents
            FuzzyVariable Thirst      = _module.CreateFLV("Thirst");
            var           Thirst_Low  = Thirst.AddLeftShoulderSet("Thirst_Low", 0, 10, 20);
            var           Thirst_Med  = Thirst.AddTriangularSet("Thirst_Med", 10, 20, 30);
            var           Thirst_High = Thirst.AddRightShoulderSet("Thirst_High", 20, 30, _MAX_THIRST);

            FuzzyVariable Distance        = _module.CreateFLV("Distance");
            var           Distance_Close  = Distance.AddLeftShoulderSet("Distance_Close", 0, 40, 80);
            var           Distance_Medium = Distance.AddTriangularSet("Distance_Medium", 40, 80, 400);
            var           Distance_Far    = Distance.AddRightShoulderSet("Distance_Far", 80, 400, MAX_DISTANCE);

            // Consequence
            FuzzyVariable Desirability  = _module.CreateFLV("Desirability");
            var           Undesirable   = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
            var           Desirable     = Desirability.AddTriangularSet("Desirable", 25, 50, 75);
            var           VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);

            // Rules
            _module.AddRule(new FzAND(Thirst_Low, Distance_Close), Undesirable);
            _module.AddRule(new FzAND(Thirst_Low, Distance_Medium), Undesirable);
            _module.AddRule(new FzAND(Thirst_Low, Distance_Far), Undesirable);
            _module.AddRule(new FzAND(Thirst_Med, Distance_Close), Desirable);
            _module.AddRule(new FzAND(Thirst_Med, Distance_Medium), Undesirable);
            _module.AddRule(new FzAND(Thirst_Med, Distance_Far), Undesirable);
            _module.AddRule(new FzAND(Thirst_High, Distance_Close), VeryDesirable);
            _module.AddRule(new FzAND(Thirst_High, Distance_Medium), VeryDesirable);
            _module.AddRule(new FzAND(Thirst_High, Distance_Far), Desirable);
        }
コード例 #4
0
        public void FuzzyTowerCalcSniper(FuzzyModule towerFuzzyModule)
        {
            // Retrieves the antecedents.
            FuzzyVariable health = towerFuzzyModule.GetVar("Health");
            FzSet         low    = new FzSet(health.GetSet("Low"));
            FzSet         middle = new FzSet(health.GetSet("Middle"));
            FzSet         high   = new FzSet(health.GetSet("High"));


            FuzzyVariable distanceToEnemy = towerFuzzyModule.GetVar("DistanceToEnemy");
            FzSet         close           = new FzSet(distanceToEnemy.GetSet("Close"));
            FzSet         medium          = new FzSet(distanceToEnemy.GetSet("Medium"));
            FzSet         far             = new FzSet(distanceToEnemy.GetSet("Far"));

            // Creates the consequent.
            FuzzyVariable shootDesirability = towerFuzzyModule.CreateFLV("ShootDesirability");

            FzSet undesirable   = shootDesirability.AddLeftShoulderSet("Undesirable", 0, 15, 30);
            FzSet desirable     = shootDesirability.AddTriangularSet("Desirable", 15, 30, 75);
            FzSet veryDesirable = shootDesirability.AddRightShoulderSet("VeryDesirable", 30, 75, 100);

            // Add rules to complete the FAM.
            towerFuzzyModule.AddRule(new FzAND(low, close), desirable);
            towerFuzzyModule.AddRule(new FzAND(low, medium), desirable);
            towerFuzzyModule.AddRule(new FzAND(low, far), veryDesirable);

            towerFuzzyModule.AddRule(new FzAND(middle, close), undesirable);
            towerFuzzyModule.AddRule(new FzAND(middle, medium), undesirable);
            towerFuzzyModule.AddRule(new FzAND(middle, far), desirable);

            towerFuzzyModule.AddRule(new FzAND(high, close), undesirable);
            towerFuzzyModule.AddRule(new FzAND(high, medium), undesirable);
            towerFuzzyModule.AddRule(new FzAND(high, far), desirable);
        }
コード例 #5
0
ファイル: Herde.cs プロジェクト: poeely/UnityAAI
    private void InitSheepDesireFM()
    {
        sheepDesireFM = new FuzzyModule();
        FuzzyVariable DistToTarget = sheepDesireFM.CreateFLV("DistToOgre");

        FzSet Dist_Close  = DistToTarget.AddLeftShoulderSet("Dist_Close", 0, 25, 150);
        FzSet Dist_Medium = DistToTarget.AddTriangleSet("Dist_Medium", 25, 50, 300);
        FzSet Dist_Far    = DistToTarget.AddRightShoulderSet("Dist_Far", 150, 300, 500);

        FuzzyVariable AmmoStatus = sheepDesireFM.CreateFLV("Hunger");

        FzSet Hunger_Low     = AmmoStatus.AddLeftShoulderSet("Hunger_Low", 0, 0, 10);
        FzSet Hunger_Okay    = AmmoStatus.AddTriangleSet("Hunger_Okay", 0, 10, 30);
        FzSet Hunger_Intense = AmmoStatus.AddRightShoulderSet("Hunger_Intense", 10, 30, 40);

        FuzzyVariable Desirability = sheepDesireFM.CreateFLV("Desirability");

        FzSet Undersirable  = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
        FzSet Desirable     = Desirability.AddTriangleSet("Desirable", 25, 50, 75);
        FzSet VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);

        sheepDesireFM.AddRule(new FzAND(Dist_Close, Hunger_Low), Undersirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Close, Hunger_Okay), Undersirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Close, Hunger_Intense), Undersirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Medium, Hunger_Low), Desirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Medium, Hunger_Okay), VeryDesirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Medium, Hunger_Intense), VeryDesirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Far, Hunger_Low), Undersirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Far, Hunger_Okay), Desirable);
        sheepDesireFM.AddRule(new FzAND(Dist_Far, Hunger_Intense), Desirable);
    }
コード例 #6
0
        public static FuzzyTermSet add_term(Sets set, FuzzyVariable fuzzyVar, string name, double min, double peak, double max)
        {
            switch (set)
            {
            case Sets.LEFT_SHOULDER:
                return(fuzzyVar.AddLeftShoulderSet(name, min, peak, max));

            case Sets.TRIANGULAR:
                return(fuzzyVar.AddTriangularSet(name, min, peak, max));

            case Sets.RIGHT_SHOULDER:
                return(fuzzyVar.AddRightShoulderSet(name, min, peak, max));

            default:
                throw new ArgumentException("Cannot find the desired fuzzy set.");
            }
        }
コード例 #7
0
        public FuzzyModule InitFuzzyTowerBaseModule()
        {
            FuzzyModule towerFuzzyModule = new FuzzyModule();

            FuzzyVariable health = towerFuzzyModule.CreateFLV("Health");

            health.AddLeftShoulderSet("Low", 0, 20, 33);
            health.AddTriangularSet("Middle", 20, 33, 60);
            health.AddRightShoulderSet("High", 33, 60, 100);

            FuzzyVariable distanceToEnemy = towerFuzzyModule.CreateFLV("DistanceToEnemy");

            distanceToEnemy.AddLeftShoulderSet("Close", 0, 29, 30);
            distanceToEnemy.AddTriangularSet("Medium", 29, 30, 66);
            distanceToEnemy.AddRightShoulderSet("Far", 30, 66, 100);

            return(towerFuzzyModule);
        }
コード例 #8
0
        public void FuzzyLogic_Test1()
        {
            FuzzyModule fuzzyModule = new FuzzyModule();

            FuzzyVariable distanceToTarget = fuzzyModule.CreateFLV("DistanceToTarget");
            FzSet         Target_Close     = distanceToTarget.AddLeftShoulderSet("Target_Close", 0, 250, 500);
            FzSet         Target_Medium    = distanceToTarget.AddTriangularSet("Target_Medium", 250, 500, 750);
            FzSet         Target_Far       = distanceToTarget.AddRightShoulderSet("Target_Far", 500, 750, 1000);

            FuzzyVariable AmmoStatus = fuzzyModule.CreateFLV("AmmoStatus");
            FzSet         Ammo_Low   = AmmoStatus.AddLeftShoulderSet("Ammo_Low", 0, 250, 500);
            FzSet         Ammo_Okay  = AmmoStatus.AddTriangularSet("Ammo_Okay", 250, 500, 750);
            FzSet         Ammo_Loads = AmmoStatus.AddRightShoulderSet("Ammo_Loads", 500, 750, 1000);

            FuzzyVariable Desirability   = fuzzyModule.CreateFLV("Desirability");
            FzSet         Undesirable    = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
            FzSet         Desirable      = Desirability.AddTriangularSet("Desirable", 25, 50, 75);
            FzSet         Very_Desirable = Desirability.AddRightShoulderSet("Very_Desirable", 50, 75, 100);

            fuzzyModule.AddRule(new FzAND(Target_Close, Ammo_Loads), Undesirable);
            fuzzyModule.AddRule(new FzAND(Target_Close, Ammo_Okay), Undesirable);
            fuzzyModule.AddRule(new FzAND(Target_Close, Ammo_Low), Undesirable);
            fuzzyModule.AddRule(new FzAND(Target_Medium, Ammo_Loads), Very_Desirable);
            fuzzyModule.AddRule(new FzAND(Target_Medium, Ammo_Okay), Very_Desirable);
            fuzzyModule.AddRule(new FzAND(Target_Medium, Ammo_Low), Desirable);
            fuzzyModule.AddRule(new FzAND(Target_Far, Ammo_Loads), Desirable);
            fuzzyModule.AddRule(new FzAND(Target_Far, Ammo_Okay), Desirable);
            fuzzyModule.AddRule(new FzAND(Target_Far, Ammo_Low), Undesirable);

            fuzzyModule.Fuzzify("DistanceToTarget", 200);
            fuzzyModule.Fuzzify("AmmoStatus", 400);

            double value = fuzzyModule.DeFuzzify("Desirability", FuzzyModule.DefuzzifyMethod.MaxAV);

            Assert.Equal(12.5, value);

            fuzzyModule.Fuzzify("DistanceToTarget", 1000);
            fuzzyModule.Fuzzify("AmmoStatus", 600);

            value = fuzzyModule.DeFuzzify("Desirability", FuzzyModule.DefuzzifyMethod.MaxAV);

            Assert.Equal(50, value);
        }
コード例 #9
0
    public double FuzzyGetDesirabilitySeek(int hungerVar, double moneyVar)
    {
        FuzzyModule fuzzyModule = new FuzzyModule();

        FuzzyVariable hunger      = fuzzyModule.CreateFLV("Hunger");
        FzSet         No_Hunger   = hunger.AddLeftShoulderSet("No_Hunger", 0, 5, 10);
        FzSet         Hunger      = hunger.AddTriangularSet("Hunger", 5, 10, 15);
        FzSet         Very_Hunger = hunger.AddRightShoulderSet("Very_Hunger", 10, 15, 20);

        FuzzyVariable AmmoStatus = fuzzyModule.CreateFLV("Money");
        FzSet         Poor       = AmmoStatus.AddLeftShoulderSet("Poor", 0, 5, 10);
        FzSet         Normal     = AmmoStatus.AddTriangularSet("Normal", 5, 10, 100);
        FzSet         Rich       = AmmoStatus.AddRightShoulderSet("Rich", 10, 100, 1000);

        FuzzyVariable Desirability   = fuzzyModule.CreateFLV("Desirability");
        FzSet         Undesirable    = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);
        FzSet         Desirable      = Desirability.AddTriangularSet("Desirable", 25, 50, 75);
        FzSet         Very_Desirable = Desirability.AddRightShoulderSet("Very_Desirable", 50, 75, 100);

        fuzzyModule.AddRule(new FzAND(No_Hunger, Poor), Undesirable);
        fuzzyModule.AddRule(new FzAND(No_Hunger, Normal), Undesirable);
        fuzzyModule.AddRule(new FzAND(No_Hunger, Rich), Undesirable);
        fuzzyModule.AddRule(new FzAND(Very_Hunger, Poor), Very_Desirable);
        fuzzyModule.AddRule(new FzAND(Very_Hunger, Normal), Very_Desirable);
        fuzzyModule.AddRule(new FzAND(Very_Hunger, Rich), Undesirable);
        fuzzyModule.AddRule(new FzAND(Hunger, Poor), Desirable);
        fuzzyModule.AddRule(new FzAND(Hunger, Normal), Desirable);
        fuzzyModule.AddRule(new FzAND(Hunger, Rich), Undesirable);

        fuzzyModule.Fuzzify("Hunger", hungerVar);
        fuzzyModule.Fuzzify("Money", moneyVar);

        double value = fuzzyModule.DeFuzzify("Desirability", FuzzyModule.DefuzzifyMethod.MaxAV);

        return(value);
    }
コード例 #10
0
    protected override void initializeFuzzyModule()
    {
        FuzzyVariable DistToTarget = m_FuzzyModule.CreateFLV("DistToTarget");

        //FzSet is a fuzzy set!!!
        FzSet Target_Close  = DistToTarget.AddLeftShoulderSet("eTarget_Close", 0, 250, 500);
        FzSet Target_Medium = DistToTarget.AddTriangularSet("eTarget_Medium", 250, 500, 750);
        FzSet Target_Far    = DistToTarget.AddRightShoulderSet("eTarget_Far", 500, 750, 1000);

        FuzzyVariable DistToMate  = m_FuzzyModule.CreateFLV("DistToMate");
        FzSet         Mate_Close  = DistToMate.AddLeftShoulderSet("mTarget_Close", 0, 250, 500);
        FzSet         Mate_Medium = DistToMate.AddTriangularSet("mTarget_Medium", 250, 500, 750);
        FzSet         Mate_Far    = DistToMate.AddRightShoulderSet("mTarget_Far", 500, 750, 1000);

        FuzzyVariable Hunger     = m_FuzzyModule.CreateFLV("Hunger");
        FzSet         VeryHungry = Hunger.AddRightShoulderSet("VeryHungry", 50, 75, 100);
        FzSet         Hungry     = Hunger.AddTriangularSet("Hungry", 25, 50, 75);
        FzSet         NotHungry  = Hunger.AddLeftShoulderSet("NotHungry", 0, 25, 50);


        FuzzyVariable Libido       = m_FuzzyModule.CreateFLV("Libido");
        FzSet         HighLibido   = Libido.AddRightShoulderSet("HighLibido", 50, 75, 100);
        FzSet         MediumLibido = Libido.AddTriangularSet("MediumLibido", 25, 50, 75);
        FzSet         NoLibido     = Libido.AddLeftShoulderSet("NoLibido", 0, 25, 50);

        FuzzyVariable Desirability  = m_FuzzyModule.CreateFLV("Desirability");
        FzSet         VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable", 50, 75, 100);
        FzSet         Desirable     = Desirability.AddTriangularSet("Desirable", 25, 50, 75);
        FzSet         Undesirable   = Desirability.AddLeftShoulderSet("Undesirable", 0, 25, 50);


        FuzzyVariable Sex       = m_FuzzyModule.CreateFLV("Sex");
        FzSet         HighSex   = Sex.AddRightShoulderSet("HighSex", 50, 75, 100);
        FzSet         MediumSex = Sex.AddTriangularSet("MediumSex", 25, 50, 75);
        FzSet         NoSex     = Sex.AddLeftShoulderSet("NoSex", 0, 25, 50);



        //temperature
        FuzzyVariable Temperature = m_FuzzyModule2.CreateFLV("Temperature");

        FzSet hot  = Temperature.AddLeftShoulderSet("hot", 0, 250, 500);
        FzSet warm = Temperature.AddTriangularSet("warm", 250, 500, 750);
        FzSet cold = Temperature.AddRightShoulderSet("cold", 500, 750, 1000);

        FuzzyVariable Hunger2     = m_FuzzyModule2.CreateFLV("Hunger2");
        FzSet         VeryHungry2 = Hunger2.AddRightShoulderSet("VeryHungry", 50, 75, 100);
        FzSet         Hungry2     = Hunger2.AddTriangularSet("Hungry", 25, 50, 75);
        FzSet         NotHungry2  = Hunger2.AddLeftShoulderSet("NotHungry", 0, 25, 50);

        FuzzyVariable Libido2       = m_FuzzyModule2.CreateFLV("Libido2");
        FzSet         HighLibido2   = Libido2.AddRightShoulderSet("HighLibido", 50, 75, 100);
        FzSet         MediumLibido2 = Libido2.AddTriangularSet("MediumLibido", 25, 50, 75);
        FzSet         NoLibido2     = Libido2.AddLeftShoulderSet("NoLibido", 0, 25, 50);

        FuzzyVariable Desirability2  = m_FuzzyModule2.CreateFLV("Desirability2");
        FzSet         VeryDesirable2 = Desirability2.AddRightShoulderSet("VeryDesirable", 50, 75, 100);
        FzSet         Desirable2     = Desirability2.AddTriangularSet("Desirable", 25, 50, 75);
        FzSet         Undesirable2   = Desirability2.AddLeftShoulderSet("Undesirable", 0, 25, 50);

        FuzzyVariable Sex2       = m_FuzzyModule2.CreateFLV("Sex2");
        FzSet         HighSex2   = Sex2.AddRightShoulderSet("HighSex", 50, 75, 100);
        FzSet         MediumSex2 = Sex2.AddTriangularSet("MediumSex", 25, 50, 75);
        FzSet         NoSex2     = Sex2.AddLeftShoulderSet("NoSex", 0, 25, 50);

        //Temperature Rules
        m_FuzzyModule2.AddRule(new FzAND(hot, VeryHungry2), Undesirable2);
        m_FuzzyModule2.AddRule(new FzAND(hot, Hungry2), Undesirable2);
        m_FuzzyModule2.AddRule(new FzAND(hot, NotHungry2), Undesirable2);

        m_FuzzyModule2.AddRule(new FzAND(warm, VeryHungry2), VeryDesirable2);
        m_FuzzyModule2.AddRule(new FzAND(warm, Hungry2), VeryDesirable2);
        m_FuzzyModule2.AddRule(new FzAND(warm, NotHungry2), Desirable2);

        m_FuzzyModule2.AddRule(new FzAND(cold, VeryHungry2), Desirable2);
        m_FuzzyModule2.AddRule(new FzAND(cold, Hungry2), Undesirable2);
        m_FuzzyModule2.AddRule(new FzAND(cold, NotHungry2), Undesirable2);


        m_FuzzyModule2.AddRule(new FzAND(hot, HighLibido2), NoSex2);
        m_FuzzyModule2.AddRule(new FzAND(hot, MediumLibido2), NoSex2);
        m_FuzzyModule2.AddRule(new FzAND(hot, NoLibido2), NoSex2);

        m_FuzzyModule2.AddRule(new FzAND(warm, HighLibido2), MediumSex2);
        m_FuzzyModule2.AddRule(new FzAND(warm, MediumLibido2), NoSex2);
        m_FuzzyModule2.AddRule(new FzAND(warm, NoLibido2), NoSex2);

        m_FuzzyModule2.AddRule(new FzAND(cold, HighLibido2), HighSex2);
        m_FuzzyModule2.AddRule(new FzAND(cold, MediumLibido2), HighSex2);
        m_FuzzyModule2.AddRule(new FzAND(cold, NoLibido2), NoSex2);



        //food
        //antecedents and consequents are FzSet isntances, so Clone() uses FzSet member function Clone().
        m_FuzzyModule.AddRule(new FzAND(Target_Close, HighLibido, VeryHungry), VeryDesirable);    //done
        m_FuzzyModule.AddRule(new FzAND(Target_Close, MediumLibido, VeryHungry), VeryDesirable);  //done
        m_FuzzyModule.AddRule(new FzAND(Target_Close, NoLibido, VeryHungry), VeryDesirable);      //done

        m_FuzzyModule.AddRule(new FzAND(Target_Close, HighLibido, Hungry), Desirable);            //done
        m_FuzzyModule.AddRule(new FzAND(Target_Close, MediumLibido, Hungry), Desirable);          //done
        m_FuzzyModule.AddRule(new FzAND(Target_Close, NoLibido, Hungry), VeryDesirable);          //done

        m_FuzzyModule.AddRule(new FzAND(Target_Close, HighLibido, NotHungry), Undesirable);       //done
        m_FuzzyModule.AddRule(new FzAND(Target_Close, MediumLibido, NotHungry), Undesirable);     //done
        m_FuzzyModule.AddRule(new FzAND(Target_Close, NoLibido, NotHungry), Undesirable);         //done

        m_FuzzyModule.AddRule(new FzAND(Target_Medium, HighLibido, VeryHungry), Desirable);       //done
        m_FuzzyModule.AddRule(new FzAND(Target_Medium, MediumLibido, VeryHungry), VeryDesirable); //done
        m_FuzzyModule.AddRule(new FzAND(Target_Medium, NoLibido, VeryHungry), VeryDesirable);     //done

        m_FuzzyModule.AddRule(new FzAND(Target_Medium, HighLibido, Hungry), Desirable);           //done
        m_FuzzyModule.AddRule(new FzAND(Target_Medium, MediumLibido, Hungry), Desirable);         //done
        m_FuzzyModule.AddRule(new FzAND(Target_Medium, NoLibido, Hungry), VeryDesirable);         //done

        m_FuzzyModule.AddRule(new FzAND(Target_Medium, HighLibido, NotHungry), Undesirable);      //done
        m_FuzzyModule.AddRule(new FzAND(Target_Medium, MediumLibido, NotHungry), Undesirable);    //done
        m_FuzzyModule.AddRule(new FzAND(Target_Medium, NoLibido, NotHungry), Undesirable);        //done

        m_FuzzyModule.AddRule(new FzAND(Target_Far, HighLibido, VeryHungry), VeryDesirable);      //done
        m_FuzzyModule.AddRule(new FzAND(Target_Far, MediumLibido, VeryHungry), VeryDesirable);    //done
        m_FuzzyModule.AddRule(new FzAND(Target_Far, NoLibido, VeryHungry), VeryDesirable);        //done

        m_FuzzyModule.AddRule(new FzAND(Target_Far, HighLibido, Hungry), Desirable);              //done
        m_FuzzyModule.AddRule(new FzAND(Target_Far, MediumLibido, Hungry), Desirable);            //done
        m_FuzzyModule.AddRule(new FzAND(Target_Far, NoLibido, Hungry), VeryDesirable);            //done

        m_FuzzyModule.AddRule(new FzAND(Target_Far, HighLibido, NotHungry), Undesirable);         //done
        m_FuzzyModule.AddRule(new FzAND(Target_Far, MediumLibido, NotHungry), Undesirable);       //done
        m_FuzzyModule.AddRule(new FzAND(Target_Far, NoLibido, NotHungry), Undesirable);           //done

        //sex
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, VeryHungry, HighLibido), MediumSex);   //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, VeryHungry, MediumLibido), MediumSex); //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, VeryHungry, NoLibido), NoSex);         //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Close, Hungry, HighLibido), HighSex);         //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, Hungry, MediumLibido), MediumSex);     //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, Hungry, NoLibido), NoSex);             //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Close, NotHungry, HighLibido), HighSex);      //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, NotHungry, MediumLibido), HighSex);    //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Close, NotHungry, NoLibido), NoSex);          //done


        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, VeryHungry, HighLibido), MediumSex);  ///done
        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, VeryHungry, MediumLibido), NoSex);    //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, VeryHungry, NoLibido), NoSex);        //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, Hungry, HighLibido), HighSex);        //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, Hungry, MediumLibido), MediumSex);    //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, Hungry, NoLibido), NoSex);            //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, NotHungry, HighLibido), HighSex);     //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, NotHungry, MediumLibido), MediumSex); //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Medium, NotHungry, NoLibido), NoSex);         //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Far, VeryHungry, HighLibido), MediumSex);     //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Far, VeryHungry, MediumLibido), NoSex);       //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Far, VeryHungry, NoLibido), NoSex);           //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Far, Hungry, HighLibido), MediumSex);         //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Far, Hungry, MediumLibido), MediumSex);       //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Far, Hungry, NoLibido), NoSex);               //done

        m_FuzzyModule.AddRule(new FzAND(Mate_Far, NotHungry, HighLibido), HighSex);        //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Far, NotHungry, MediumLibido), MediumSex);    //done
        m_FuzzyModule.AddRule(new FzAND(Mate_Far, NotHungry, NoLibido), NoSex);            //done
    }
コード例 #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("hello {0}", "John");

            FuzzyModule   fm           = new FuzzyModule();
            FuzzyVariable Dist2Target  = fm.CreateFLV("Dist2Target");
            FuzzyVariable Desirability = fm.CreateFLV("Desirability");
            FuzzyVariable AmmoStatus   = fm.CreateFLV("AmmoStatus");

            FzSet Target_Close = Dist2Target.AddLeftShoulderSet("Target_Close",
                                                                0, 25, 150);
            FzSet Target_Medium = Dist2Target.AddTrianglularSet("Target_Medium",
                                                                25, 150, 300);
            FzSet Target_Far = Dist2Target.AddRightShoulderSet("Target_Far",
                                                               150, 300, 400);

            FzSet Ammon_low = AmmoStatus.AddLeftShoulderSet("Ammon_low",
                                                            0, 0, 10);
            FzSet Ammon_Okay = AmmoStatus.AddTrianglularSet("Ammon_Okay",
                                                            0, 10, 30);
            FzSet Ammon_Loads = AmmoStatus.AddRightShoulderSet("Ammon_Loads",
                                                               10, 30, 40);

            FzSet Undesirable = Desirability.AddLeftShoulderSet("Undesirable",
                                                                0, 25, 50);
            FzSet Desirable = Desirability.AddTrianglularSet("Desirable",
                                                             25, 50, 75);
            FzSet VeryDesirable = Desirability.AddRightShoulderSet("VeryDesirable",
                                                                   50, 75, 100);

            bool Combos = true;

            if (Combos)
            {
                fm.AddRule((Target_Far), Undesirable);
                fm.AddRule((Target_Medium), VeryDesirable);
                fm.AddRule((Target_Close), Undesirable);
                fm.AddRule((Ammon_Loads), VeryDesirable);
                fm.AddRule((Ammon_Okay), Desirable);
                fm.AddRule((Ammon_low), Undesirable);

                //fm.AddRule(new FzFairly(Target_Far), Undesirable);
                //fm.AddRule(new FzFairly(Target_Medium), VeryDesirable);
                //fm.AddRule(new FzFairly(Target_Close), Undesirable);
                //fm.AddRule(new FzFairly(Ammon_Loads), VeryDesirable);
                //fm.AddRule(new FzFairly(Ammon_Okay), Desirable);
                //fm.AddRule(new FzFairly(Ammon_low), Undesirable);

                //fm.AddRule(new FzVery(Target_Far), Undesirable);
                //fm.AddRule(new FzVery(Target_Medium), VeryDesirable);
                //fm.AddRule(new FzVery(Target_Close), Undesirable);
                //fm.AddRule(new FzVery(Ammon_Loads), VeryDesirable);
                //fm.AddRule(new FzVery(Ammon_Okay), Desirable);
                //fm.AddRule(new FzVery(Ammon_low), Undesirable);
            }
            else
            {
                fm.AddRule(new FzAND(Target_Far, Ammon_Loads), Desirable);
                fm.AddRule(new FzAND(Target_Far, Ammon_Okay), Undesirable);
                fm.AddRule(new FzAND(Target_Far, Ammon_low), Undesirable);

                fm.AddRule(new FzAND(Target_Medium, Ammon_Loads), VeryDesirable);
                fm.AddRule(new FzAND(Target_Medium, Ammon_Okay), VeryDesirable);
                fm.AddRule(new FzAND(Target_Medium, Ammon_low), Desirable);

                fm.AddRule(new FzAND(Target_Close, Ammon_Loads), Undesirable);
                fm.AddRule(new FzAND(Target_Close, Ammon_Okay), Undesirable);
                fm.AddRule(new FzAND(Target_Close, Ammon_low), Undesirable);
            }

            fm.Fuzzify("Dist2Target", 200);
            fm.Fuzzify("AmmoStatus", 8);

            double result = fm.Defuzzify("Desirability", FuzzyModule.DefuzzifyMethod.max_av);

            Console.WriteLine("Dist2Target is {0}", fm.Defuzzify("Dist2Target", FuzzyModule.DefuzzifyMethod.max_av));
            Console.WriteLine("AmmoStatus is {0}", fm.Defuzzify("AmmoStatus", FuzzyModule.DefuzzifyMethod.max_av));
            Console.WriteLine("Desirability is {0}", result);
        }