Beispiel #1
0
    private void GetBreakDesire()
    {
        _breakDesire.GetFunction("Break").Fuzzy = (Logic.OR(Logic.OR(Logic.AND(_velocity.IS("Alta"), _distance.IS("Perto")), Logic.AND(_velocity.IS("Media"), _distance.IS("Perto"))), _distance.IS("Muito Perto")));

        _breakDesire.GetFunction("Dont").Fuzzy = (Logic.OR(_velocity.IS("Baixa"), _distance.IS("Longe")));

        float __defuzzy = _breakDesire.Defuzzyfication(0.01f);

        Debug.Log("Break: " + _breakDesire.GetFunction("Break").Fuzzy + " | Dont: " + _breakDesire.GetFunction("Dont").Fuzzy + " | Defuzzy: " + __defuzzy);

        if (_breakDesire.GetFunction("Break").Fuzzy >= 0.85f)
        {
            AccForce = -1 * (_breakDesire.GetFunction("Break").Fuzzy) + 0.12f;
        }
        else if (_breakDesire.GetFunction("Break").Fuzzy < 0.85f && _breakDesire.GetFunction("Dont").Fuzzy >= 0.2f)
        {
            AccForce = 1 * _breakDesire.GetFunction("Dont").Fuzzy + 0.25f;
        }
        else
        {
            AccForce = 1;
        }
        //float __percentage;
        //if (__defuzzy <= 0.2f)
        //{
        //    __percentage = 1 * (0.2f / __defuzzy);
        //    AccForce = -__percentage;
        //}
        //else
        //{
        //    __percentage = 1 * __defuzzy / 0.8f;
        //    AccForce = __percentage;
        //}
    }
Beispiel #2
0
    private void FuzzyCalculations()
    {
        _fBehaviour.SetConceptValue("Truck_Distancia", distancia);
        _fBehaviour.SetConceptValue("Truck_Velocidade", velocidade);


        Concept __concept = _fBehaviour.GetConcept("Truck_Risco");

        _fBehaviour.ExecuteConditions();
        print("Risco 1: " + __concept.GetFunction(0).Fuzzy);
        print("Risco 2: " + __concept.GetFunction(1).Fuzzy);
        print("Risco 3: " + __concept.GetFunction(2).Fuzzy);

        print("Defuzzy: " + __concept.Defuzzyfication(0.001f));
        Debug.Break();
    }