Exemple #1
0
    public override void AgentAction(float[] vectorAction, string textAction)
    {
        //if (brain.brainParameters.vectorActionSpaceType == SpaceType.discrete)
        //{
        for (int i = 0; i < vectorAction.Length; i++)
        {
            rocketController.SetThrustFloat(i, Mathf.Clamp(vectorAction[i], -1f, 1f));
        }
        //}
        if (Vector3.Distance(rocketObject.transform.position, goal.transform.position) > 50f)
        {
            Done();
            SetReward(-1f);
        }
        else
        {
            float curDistance = Vector3.Distance(goal.transform.position, rocketObject.transform.position);

            /*if (curDistance < lastDistance)
             * {
             *  SetReward(0.1f);
             * }
             * else
             * {
             *  SetReward(-0.1f);
             * }*/

            //Debug.Log(lastDistance - curDistance);

            SetReward(lastDistance - curDistance);

            //Debug.Log("Distance: " + curDistance.ToString());

            lastDistance = curDistance;
        }


        if (timeRun <= 0f && randomiseStart)
        {
            Done();
        }
    }