예제 #1
0
 public void Fight(_Agent opponent)
 {
     try
     {
         Attack(opponent);
         opponent.Attack(this);
     }
     catch (NullReferenceException) { }
 }
예제 #2
0
    public void PerformAction(int selectedAction)
    {
        Debug.Log("Performing action: " + selectedAction);
        GlobalCounter++;
        threadStep++;
        float episodeReward = 0;

        if (selectedAction == (int)_AradisActions.MOVE_LEFT)
        {
            episodeReward = aradis.MoveForward();
        }
        else if (selectedAction == (int)_AradisActions.MOVE_RIGHT)
        {
            episodeReward = aradis.MoveBackward();
        }
        else if (selectedAction == (int)_AradisActions.JUMP)
        {
            episodeReward = aradis.Jump();
        }
        else if (selectedAction == (int)_AradisActions.ATTACK)
        {
            episodeReward = aradis.Attack();
        }

        if (aradis.KilledEnemy())
        {
            episodeReward = aradis.rewardsDict["Won"];
            done          = true;
        }

        if (aradis.Died())
        {
            episodeReward = aradis.rewardsDict["Lose"];
            done          = true;
        }

        accumRewards.Add(episodeReward);

        if (!done && threadStep < maxThreadStep)
        {
            StartCoroutine(RequestStepCo());
        }
        else
        {
            EndEpisode();
        }
    }