Ejemplo n.º 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;
        //}
    }