예제 #1
0
    public void RequestNextDecision(LudoAgent ludoAgent)
    {
        LudoAgent other = GetOtherAgent(ludoAgent);

        other.RequestDecision();
        //Debug.LogFormat("[ReqDecision] A:{0}", other.name);
    }
예제 #2
0
    public bool UpdateGameState(LudoAgent agent, LudoPiece piece)
    {
        LudoAgent otherAgent = GetOtherAgent(agent);

        // Game completed
        if (agent.piece1.IsFinished && agent.piece2.IsFinished)
        {
            agent.AddReward(1f);
            agent.Done();
            otherAgent.AddReward(-1f);
            otherAgent.Done();
            LudoUI.Instance.IncrementWin(agent.index);
            Debug.LogWarningFormat("[GO] {0}:{1} {2}:{3}",
                                   agent.name, agent.GetReward(),
                                   otherAgent.name, otherAgent.GetReward());
            // reset academy
            academy.AcademyReset();
            return(true);
        }

        // didn't finish the game -0.01
        agent.AddReward(-0.01f);

        // Killed another player's piece
        // provided both of the pieces of other agent were not on the same position
        LudoPiece otherPiece = null;

        if (!otherAgent.piece1.IsFinished && piece.CurrentPosition == otherAgent.piece1.CurrentPosition)
        {
            otherPiece = otherAgent.piece1;
        }
        if (!otherAgent.piece2.IsFinished && piece.CurrentPosition == otherAgent.piece2.CurrentPosition)
        {
            otherPiece = otherAgent.piece2;
        }

        if (otherPiece != null && otherAgent.piece1.CurrentPosition != otherAgent.piece2.CurrentPosition)
        {
            Debug.LogWarningFormat("[Kill] {0}:{1} {2}:{3}",
                                   agent.name, piece.CurrentPosition,
                                   otherAgent.name, otherPiece.CurrentPosition);

            agent.AddReward(1f * otherPiece.CurrentPosition / gridSize);
            LudoUI.Instance.IncrementKill(agent.index);

            otherPiece.MoveTo(0);
            otherAgent.AddReward(-0.25f);
        }

        return(false);
    }
예제 #3
0
 public void UpdateAgent(LudoAgent agent, LudoPiece piece)
 {
     currrentAgent.text = agent.name + "-" + piece.name;
 }
예제 #4
0
 public LudoAgent GetOtherAgent(LudoAgent ludoAgent)
 {
     return(ludoAgent.Equals(agents[0]) ? agents[1] : agents[0]);
 }