Esempio n. 1
0
    public override void AgentAction(float[] vectorAction, string textAction)
    {
        currentAngleDiff = Vector3.Angle(transform.up, Vector3.up);

        if (currentAngleDiff < AngleGoal)
        {
            time     += Time.deltaTime;
            mat.color = Color.yellow;

            if (time > 3)
            {
                AddReward(0.5f);
                StartCoroutine(FlashColor(Color.green));
                Done();
            }
        }
        else
        {
            AddReward(-1f / agentParameters.maxStep);
            time = 0;
            StartCoroutine(FlashColor(Color.red, 0.5f));
        }

        ////reward if angle decreases
        //if (currentAngleDiff < previousAngleDiff)
        //{
        //    AddReward(0.01f);
        //}

        //punish if angle increases
        if (currentAngleDiff > previousAngleDiff)
        {
            AddReward(-0.02f);
        }

        //fail being upside down
        if (Quaternion.Angle(transform.rotation, Quaternion.Euler(0, 1, 0)) > 90f)
        {
            AddReward(-1f);
            StartCoroutine(FlashColor(Color.red));
            AgentReset();
        }

        //punish over time
        //AddReward(-1f / agentParameters.maxStep);

        falcon.ThrustAUX(vectorAction[0]);
        previousAngleDiff = currentAngleDiff;
    }
Esempio n. 2
0
    void doThrust(float[] act)
    {
        int thruster = 0;
        int action   = Mathf.FloorToInt(act[0]);

        switch (action)
        {
        case 0:
            thruster = 0;
            break;

        case 1:
            thruster = 1;
            break;

        case 2:
            thruster = -1;
            break;
        }

        falcon.ThrustAUX(thruster);
    }
Esempio n. 3
0
    public override void AgentAction(float[] vectorAction, string textAction)
    {
        currentAngularVelocity = Mathf.Abs(rb.angularVelocity.magnitude);
        currentAngleDiff       = Vector3.Angle(transform.up, Vector3.up);

        if (currentAngleDiff < AngleGoal)
        {
            AddReward(1);
            StartCoroutine(Success(Color.green));
            Done();
        }

        //punish if angle increases
        if (currentAngleDiff < previousAngleDiff)
        {
            AddReward(0.01f);
        }

        //punish if angle increases
        if (currentAngleDiff > previousAngleDiff)
        {
            AddReward(-0.05f);
        }

        //fail being upside down
        if (Quaternion.Angle(transform.rotation, Quaternion.Euler(0, 1, 0)) > 90f)
        {
            AddReward(-1f);
            StartCoroutine(Success(Color.red));
            AgentReset();
        }

        //punish over time
        AddReward(-1f / agentParameters.maxStep);

        falcon.ThrustAUX(vectorAction[0]);
        previousAngleDiff       = currentAngleDiff;
        previousAngularVelocity = currentAngularVelocity;
    }