示例#1
0
    IEnumerator BasicAct()
    {
        while (true)
        {
            ActionReward bestAction = null;
            float        maxReward  = float.MinValue;
            foreach (ActionReward action in actions)
            {
                float reward = action.GetReward(this);
                if (reward > maxReward)
                {
                    bestAction = action;
                    maxReward  = reward;
                }
            }
            if (maxReward >= 0)
            {
                yield return(bestAction.PerformAction(this));
            }
            else
            {
                yield return(MoveTo(transform.position + new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f))));

                yield return(Wait(5f));
            }
        }
    }
示例#2
0
    public override void AgentStep(float[] act)
    {
        int action = Mathf.FloorToInt(act[0]);

        if (!busy)
        {
            currentAction = actions[action];
            StartCoroutine(currentAction.PerformAction(this));
            //Debug.Log(currentAction.ToString());
        }
    }