예제 #1
0
    override public bool decideOnPlayer(CardDecision decision, RpsAgent otherPlayer)
    {
        Card opponentsCard = decisionToCard(decision);

        //Only accept requests we know we can win
        return(parentAI.IndexOfCardInHand(counterCard(opponentsCard)) != -1);
    }
예제 #2
0
    override public Card decideOnCard(CardDecision decision, RpsAgent otherPlayer)
    {
        Card opponentsCard = decisionToCard(decision);
        Dictionary <Card, int> cardCounts = parentAI.getCardCounts();

        //The AI will counter the player or match the player depending on which is more out of balance
        if (parentAI.IndexOfCardInHand(counterCard(opponentsCard)) != -1 && (cardCounts.Values.Aggregate(0, Mathf.Max) - cardCounts.Values.Aggregate(cardCounts.Count, Mathf.Max)) > 1)
        {
            return(counterCard(opponentsCard));
        }
        else if (cardCounts[opponentsCard] == cardCounts.Values.Aggregate(0, Mathf.Max))
        {
            return(opponentsCard);
        }
        else if (isProbable(decision) && (cardCounts.Values.Aggregate(0, Mathf.Max) - cardCounts.Values.Aggregate(cardCounts.Count, Mathf.Max)) > 1)
        {
            //return the card we have the most of
            return(cardCounts.First(entry => entry.Value == cardCounts.Values.Aggregate(0, Mathf.Max)).Key);
        }
        else
        {
            //Shouldn't happen, but if it does, return a random card
            return((Card)Random.Range(0, 2));
        }
    }
예제 #3
0
    override public Card decideOnCard(CardDecision decision, RpsAgent otherPlayer)
    {
        //If we don't know what the opponent will play, assume they are playing the card with the highest number in play
        if (decision == CardDecision.Random)
        {
            Dictionary <Card, int> totalCardCounts = GameObject.FindObjectOfType <ChallengeLobbyManager>().getTotalCardCounts();
            Card highestCardInPlay = totalCardCounts.Keys.Aggregate(Card.Rock, (x, y) => totalCardCounts[x] > totalCardCounts[y] ? x : y);

            if (parentAI.IndexOfCardInHand(counterCard(highestCardInPlay)) != -1)
            {
                return(counterCard(highestCardInPlay));
            }
            else
            {
                return(highestCardInPlay);
            }
        }

        Card opponentsCard = decisionToCard(decision);

        //The AI will do their best to counter the opponent
        if (parentAI.IndexOfCardInHand(counterCard(opponentsCard)) != -1)
        {
            return(counterCard(opponentsCard));
        }
        else
        {
            return(opponentsCard);
        }
    }
예제 #4
0
    override public bool decideOnPlayer(CardDecision decision, RpsAgent otherPlayer)
    {
        Card opponentsCard = decisionToCard(decision);
        Dictionary <Card, int> totalCardCounts = GameObject.FindObjectOfType <ChallengeLobbyManager>().getTotalCardCounts();

        Card highestCardInPlay = totalCardCounts.Keys.Aggregate(Card.Rock, (x, y) => totalCardCounts[x] > totalCardCounts[y] ? x : y);

        if (parentAI.IndexOfCardInHand(counterCard(opponentsCard)) != -1)
        {
            return(highestCardInPlay == opponentsCard);
        }
        return(highestCardInPlay != opponentsCard);
    }
예제 #5
0
    override public Card decideOnCard(CardDecision decision, RpsAgent otherPlayer)
    {
        Card opponentsCard = decisionToCard(decision);

        //The AI blindly decides to counter the player decision or match it if possible
        if (parentAI.IndexOfCardInHand(counterCard(opponentsCard)) != -1)
        {
            return(counterCard(opponentsCard));
        }
        else
        {
            return(opponentsCard);
        }
    }
예제 #6
0
    public override int getSelectedCard(RpsAgent otherPlayer)
    {
        CardDecision opponentsDecision = getCardDecision(otherPlayer);

        Card bestCard = this.currentStrategyState.decideOnCard(opponentsDecision, otherPlayer);

        int index = IndexOfCardInHand(bestCard);

        if (index > -1)
        {
            selectedCard = index;
        }
        selectedCard = returnRandomCardFromHand();
        return(selectedCard);
    }
예제 #7
0
 //Returns the card that this decision would have you play
 public Card decisionToCard(CardDecision decision)
 {
     if (decision == CardDecision.ProbableRock || decision == CardDecision.DefiniteRock)
     {
         return(Card.Rock);
     }
     else if (decision == CardDecision.ProbablePaper || decision == CardDecision.DefinitePaper)
     {
         return(Card.Paper);
     }
     else if (decision == CardDecision.ProbableScissors || decision == CardDecision.DefiniteScissors)
     {
         return(Card.Scissors);
     }
     else
     {
         return((Card)Random.Range(0, 2));
     }
 }
예제 #8
0
    override public bool decideOnPlayer(CardDecision decision, RpsAgent otherPlayer)
    {
        Card opponentsCard = decisionToCard(decision);

        //Only accept requests which can leave our hand balanced
        Dictionary <Card, int> cardCounts = parentAI.getCardCounts();

        if (parentAI.IndexOfCardInHand(counterCard(opponentsCard)) != -1)
        {
            return(cardCounts.Values.Aggregate(0, Mathf.Max) - cardCounts[counterCard(opponentsCard)] <= 1);
        }
        else if (parentAI.IndexOfCardInHand(opponentsCard) != -1)
        {
            return(cardCounts.Values.Aggregate(0, Mathf.Max) - cardCounts[opponentsCard] <= 1);
        }
        else
        {
            //If we can't beat the card, we'll challenge if our hand is sufficiently out of whack in terms of balance
            return(isProbable(decision) && (cardCounts.Values.Aggregate(0, Mathf.Max) - cardCounts.Values.Aggregate(cardCounts.Count, Mathf.Max)) > 1);
        }
    }
예제 #9
0
 public void AddSuggestion(CardDecision card)
 {
     _stackCard.Push(card);
 }
예제 #10
0
 //Returns which card we should play based on what we think the other player is going to play and our own hand
 public abstract Card decideOnCard(CardDecision card, RpsAgent otherPlayer);
예제 #11
0
 //Returns whether or not we should play this player based on what we think the other player is going to play and our own hand
 public abstract bool decideOnPlayer(CardDecision card, RpsAgent otherPlayer);
예제 #12
0
 //Basic used to see if a decision is probable
 public bool isProbable(CardDecision decision)
 {
     return(decision == CardDecision.ProbableRock || decision == CardDecision.ProbablePaper || decision == CardDecision.ProbableScissors);
 }
예제 #13
0
 override public bool decideOnPlayer(CardDecision decision, RpsAgent otherPlayer)
 {
     //Accept any match
     return(true);
 }
예제 #14
0
    private bool makeRequestDecision(RpsAgent otherPlayer)
    {
        CardDecision opponentsDecision = getCardDecision(otherPlayer);

        return(currentStrategyState.decideOnPlayer(opponentsDecision, otherPlayer));
    }