예제 #1
0
    public override void AgentAction(float[] vectorAction, string textAction)
    {
        matchmakingQueue.IncrementTime();

        int firstPlayerIdx  = (int)Mathf.Floor(vectorAction[0]);
        int secondPlayerIdx = (int)Mathf.Floor(vectorAction[1]);

        bool correctMatch = true;

        if (firstPlayerIdx >= PlayersInQueue.Count)
        {
            AddReward(PUNITION);
            correctMatch = false;
        }
        if (secondPlayerIdx >= PlayersInQueue.Count)
        {
            AddReward(PUNITION);
            correctMatch = false;
        }

        if (firstPlayerIdx < 0 ^ secondPlayerIdx < 0)
        {
            AddReward(PUNITION);
            correctMatch = false;
        }
        else if (firstPlayerIdx < 0 && secondPlayerIdx < 0)
        {
            correctMatch = false;
        }
        else if (secondPlayerIdx == firstPlayerIdx)
        {
            AddReward(PUNITION);
            correctMatch = false;
        }

        if (correctMatch)
        {
            float matchReward = matchmakingQueue.MakeMatch(firstPlayerIdx, secondPlayerIdx);
            AddReward(matchReward);
            noOfMatches++;
            averageMatchReward += (matchReward - averageMatchReward) / noOfMatches;
        }
        lastCumulativeReward = GetCumulativeReward();
        if (matchmakingQueue.myAgentId == 1)
        {
            Debug.Log(vectorAction[0] + "  " + vectorAction[1] + " R: " + GetReward() + matchmakingQueue.StateToString());
        }
    }