Exemplo n.º 1
0
    // high stakes Tournament returns the strongest possible play the CPU can make
    public List <Card> highStakesTournament(List <Card> hand, List <Player> players)
    {
        strategyUtil strat       = new strategyUtil();
        List <Card>  cardsToPlay = new List <Card>();

        // loop through the hand
        for (int i = 0; i < hand.Count; i++)
        {
            // play the amour card if we haven't already
            if (hand[i].type == "Amour Card" && strat.checkDuplicate(hand[i], cardsToPlay, "Amour Card"))
            {
                cardsToPlay.Add(hand[i]);
                hand.Remove(hand[i]);
            }
            // play the weapon card if we haven't already played a weapon of that type
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], cardsToPlay, "Weapon Card"))
            {
                cardsToPlay.Add(hand[i]);
                hand.Remove(hand[i]);
            }
            // play any ally card with BP
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.getBattlePoints("", players) > 0)
                {
                    cardsToPlay.Add(hand[i]);
                    hand.Remove(hand[i]);
                }
            }
        }
        // return all the eligible cards to play
        return(cardsToPlay);
    }
Exemplo n.º 2
0
    public List <Card> playFinalFoe(List <Card> hand, bool amour)
    {
        strategyUtil strat        = new strategyUtil();
        List <Card>  foeEncounter = new List <Card>();

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], foeEncounter, "Weapon Card"))
            {
                foeEncounter.Add(hand[i]);
            }
            if (hand[i].type == "Ally Card")
            { // && hand[i].battlePoints > 0){
                AllyCard ally = (AllyCard)hand[i];
                if (ally.battlePoints > 0)
                {
                    foeEncounter.Add(hand[i]);
                }
            }
            if (hand[i].type == "Amour Card" && (amour == false))
            {
                foeEncounter.Add(hand[i]);
                amour = true;
            }
        }
        return(foeEncounter);
    }
Exemplo n.º 3
0
    public List <Card> playFinalFoe(List <Card> hand, bool amour)
    {
        strategyUtil strat        = new strategyUtil();
        List <Card>  foeEncounter = new List <Card>();

        // loop through our hand and play ALL non duplicate weapons allies and possible amours

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], foeEncounter, "Weapon Card"))
            {
                foeEncounter.Add(hand[i]);
            }
            if (hand[i].type == "Ally Card")
            {
                foeEncounter.Add(hand[i]);
            }
            if (hand[i].type == "Amour Card" && (amour == false))
            {
                foeEncounter.Add(hand[i]);
                amour = true;
            }
        }
        return(foeEncounter);
    }
Exemplo n.º 4
0
    // This CPU will play the stongest hand possible while NOT duplicating weapons
    public List <Card> playTournament(List <Player> players, List <Card> hand, int baseBP, int shields)
    {
        strategyUtil strat      = new strategyUtil();
        List <Card>  validCards = new List <Card>();

        for (int i = 0; i < hand.Count; i++)
        {
            var type = hand[i].type;
            if (type == "Ally Card" || type == "Weapon Card" || type == "Amour Card")
            {
                validCards.Add(hand[i]);
            }
        }

        validCards = strat.sortAllValidCardsByDescendingBP(validCards, players, "");
        List <Card> cardsToPlay = new List <Card>();

        for (int i = 0; i < validCards.Count; i++)
        {
            if (strat.checkDuplicate(validCards[i], cardsToPlay, "Weapon Card"))
            {
                cardsToPlay.Add(validCards[i]);
                hand.Remove(validCards[i]);
            }
        }
        return(cardsToPlay);
    }
Exemplo n.º 5
0
    // sets up the final stage of a quest for this CPU player, in this strategy:
    // we need to get 40BP in as few cards as possible
    public List <Card> setUpFinalFoe(List <Card> hand, string questFoe)
    {
        strategyUtil strat = new strategyUtil();

        // instantiate a List of foes and weapons from the user's hand
        List <Card> foes    = new List <Card>();
        List <Card> weapons = new List <Card>();

        // seperate the foes and weapons into their own lists from the hand
        for (var i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Foe Card")
            {
                foes.Add(hand[i]);
            }
            // make sure that we sort out weapons that are already in the weapons
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], weapons, "Weapon Card"))
            {
                weapons.Add(hand[i]);
            }
        }
        foes    = strat.sortFoesByDescendingOrder(foes, questFoe);
        weapons = strat.sortWeaponsByDescendingOrder(weapons);

        // instantiate the foeEncounter list
        List <Card> foeEncounter = new List <Card>();

        // subtract the foe with the MOST BP in the user's hand from 40, the AI threshold
        FoeCard strongFoe = (FoeCard)foes[0];
        int     bpNeeded  = (40 - strongFoe.minBP);

        // Add this foe to the foeEncounter as the foe to be played
        foeEncounter.Add(foes[0]);
        hand.Remove(foes[0]);

        // initialize index as 0 to loop through the weapons
        int index = 0;

        // while we still need BP toreach our 40 threshold
        while (bpNeeded > 0 && index < weapons.Count)
        {
            // if we still have weapons to loop through
            // subtract the BP of the next most powerful weapon from the threshold
            WeaponCard nextWeapon = (WeaponCard)weapons[index];
            bpNeeded -= nextWeapon.battlePoints;
            // add this weapon to the encounter
            foeEncounter.Add(weapons[index]);
            hand.Remove(weapons[index]);
            // increment index
            index++;
        }

        // return the most powerful foe we have with the set of weapons that most quickly gets us to 40 BP.
        return(foeEncounter);
    }
Exemplo n.º 6
0
    public List <Card> setUpFinalFoe(List <Card> hand, string questFoe)
    {
        strategyUtil strat = new strategyUtil();
        // get a list of our foes and weapons
        List <Card> foes    = new List <Card>();
        List <Card> weapons = new List <Card>();

        for (var i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Foe Card")
            {
                foes.Add(hand[i]);
            }
            // for our weapons, we also filter out duplicates
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], weapons, "Weapon Card"))
            {
                weapons.Add(hand[i]);
            }
        }

        // sort the foes in descending order so our strongest foe is first
        foes = strat.sortFoesByDescendingOrder(foes, questFoe);

        // instantiate the foe encounter
        List <Card> foeEncounter = new List <Card>();

        // add the strongest foe to the encounter
        foeEncounter.Add(foes[0]);
        hand.Remove(foes[0]);

        // loop twice, once to add all of our non duplicate weapons to the encounter
        for (int i = 0; i < weapons.Count; i++)
        {
            foeEncounter.Add(weapons[i]);
        }

        // and once to remove from our hands
        for (int i = 1; i < foeEncounter.Count; i++)
        {
            hand.Remove(foeEncounter[i]);
        }

        return(foeEncounter);
    }
Exemplo n.º 7
0
    // We play the fewest cards possible to get to 50 or our best possible total
    public List <Card> playTournament(List <Player> players, List <Card> hand, int baseBP, int shields)
    {
        strategyUtil strat = new strategyUtil();
        // Generate a list of valid cards --> weapon, ally, and amour
        List <Card> validCards = new List <Card>();

        for (var i = 0; i < hand.Count; i++)
        {
            var type = hand[i].type;
            if (type == "Ally Card" || type == "Weapon Card" || type == "Amour Card")
            {
                validCards.Add(hand[i]);
            }
        }
        validCards = strat.sortAllValidCardsByDescendingBP(validCards, players, "");
        // get how much BP we need left by subtracting our base
        int bpNeeded = 50 - baseBP;

        // instantiate the list of cards were returning to play
        List <Card> cardsToPlay = new List <Card>();

        // index = 0, because were trying to move through the validCards one at a time
        int index = 0;

        // until either we run out of validCards or we have gone above the BP threshold we wish to hit (50)
        while (bpNeeded > 0 && index < validCards.Count)
        {
            // first make sure that we still have cards in validCards to evaluate
            // check that the card were trying to play isn't a duplicate weapon
            if (strat.checkDuplicate(validCards[index], cardsToPlay, "Weapon Card"))
            {
                // add the card to our cards to be played
                bpNeeded -= strat.getValidCardBP(validCards[index], players, "");
                cardsToPlay.Add(validCards[index]);
                hand.Remove(validCards[index]);
            }
            index++;
        }
        return(cardsToPlay);
    }
Exemplo n.º 8
0
    // generates the list that is the actual bid to be played by the user, given the round they are bidding in
    public List <Card> playBid(List <Card> hand, int round)
    {
        strategyUtil strat = new strategyUtil();
        // instantiate a list that represents the bid we're willing to play
        List <Card> bid = new List <Card>();

        // In Round 1 this AI will bid foes with less than 25 BP, no duplicates
        if (round == 1)
        {
            for (int i = 0; i < hand.Count; i++)
            {
                if ((hand[i].type == "Foe Card" && strat.checkDuplicate(hand[i], bid, "Foe Card")))
                { //        hand[i].minBP < 25)
                    FoeCard foe = (FoeCard)hand[i];
                    if (foe.minBP < 25)
                    {
                        bid.Add(hand[i]);
                    }
                }
            }
        }
        // in Round 2, this AI will bid the same way as round 1, except it will allow duplicates
        if (round == 2)
        {
            for (int i = 0; i < hand.Count; i++)
            {
                if (hand[i].type == "Foe Card")
                { // && hand[i].minBP < 25){
                    FoeCard foe = (FoeCard)hand[i];
                    if (foe.minBP < 25)
                    {
                        bid.Add(hand[i]);
                    }
                }
            }
        }
        // return our bid as a list of cards
        return(bid);
    }
Exemplo n.º 9
0
    // low stakes tournament, will only play weapons of which there are 2 or more
    public List <Card> lowStakesTournament(List <Card> hand)
    {
        strategyUtil strat       = new strategyUtil();
        List <Card>  cardsToPlay = new List <Card>();

        // loop through the hand
        for (int i = 0; i < hand.Count; i++)
        {
            // if it is a weapon and our hand has multiple we play it
            if (hand[i].type == "Weapon Card" && strat.hasMultiple(hand, hand[i].name) && strat.checkDuplicate(hand[i], cardsToPlay, "Weapon Card"))
            {
                cardsToPlay.Add(hand[i]);
                hand.Remove(hand[i]);
            }
        }
        return(cardsToPlay);
    }
Exemplo n.º 10
0
    public List <Card> setUpEarlyFoeEncounter(List <Card> hand, string questFoe, int prev)
    {
        strategyUtil strat        = new strategyUtil();
        List <Card>  foeEncounter = new List <Card>();
        List <Card>  foes         = new List <Card>();

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Foe Card" && strat.getValidCardBP(hand[i], new List <Player>(), questFoe) < prev)
            {
                foes.Add(hand[i]);
            }
        }

        foes = strat.sortFoesByDescendingOrder(foes, questFoe);
        foeEncounter.Add(foes[0]);
        hand.Remove(foes[0]);

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card" && strat.hasMultiple(hand, hand[i].name) && strat.checkDuplicate(hand[i], foeEncounter, "Weapon Card") && ((strat.sumFoeEncounterCards(foeEncounter, questFoe) + strat.getValidCardBP(hand[i], new List <Player>(), questFoe) < prev)))
            {
                foeEncounter.Add(hand[i]);
                hand.Remove(hand[i]);
            }
        }
        return(foeEncounter);
    }
Exemplo n.º 11
0
    public List <Card> playBid(List <Card> hand, int round)
    {
        strategyUtil strat = new strategyUtil();
        // this CPU bids with any test cards, foe cards of less than 30bp and duplicate weapons (1 of each)
        List <Card> bid = playBid(hand, round);

        if (round > 1)
        {
            return(bid);
        }
        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Test Card")
            {
                bid.Add(hand[i]);
            }
            if (hand[i].type == "Foe Card")
            {
                FoeCard foe = (FoeCard)hand[i];
                if (foe.minBP < 30)
                {
                    bid.Add(hand[i]);
                }
            }
            if (hand[i].type == "Weapon Card" && strat.hasMultiple(hand, hand[i].name) && strat.checkDuplicate(hand[i], bid, hand[i].type))
            {
                bid.Add(hand[i]);
            }
        }
        return(bid);
    }
Exemplo n.º 12
0
    // earlier foe behavior, we try to play using the smallest cards possible until we play 10 more than the previous foe encounter
    public List <Card> playEarlierFoe(List <Card> hand, int previous, bool amour, string questName, List <Player> players)
    {
        strategyUtil strat = new strategyUtil();
        // set our threshold
        int bpNeeded = previous + 10;
        // instantiate the list of cards were going to play and return
        List <Card> foeEncounter = new List <Card>();

        // if we haven't yet played the amour
        // check if we have an amour card and play it, deduct its BP from the bpNeeded
        if (amour == false)
        {
            for (int i = 0; i < hand.Count; i++)
            {
                if (hand[i].type == "Amour Card")
                {
                    foeEncounter.Add(hand[i]);
                    bpNeeded -= 10;
                }
            }
        }

        List <Card> weapons = new List <Card>();
        List <Card> allies  = new List <Card>();

        // make a list of the valid cards to play, non-duplicate weapons and Allies with more than 0 BP.
        List <Card> validCards = new List <Card>();

        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], weapons, "Weapon Card"))
            {
                weapons.Add(hand[i]);
            }
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.getBattlePoints(questName, players) > 0)
                {
                    allies.Add(hand[i]);
                }
            }
        }

        // sort them by ascending order
        allies  = strat.sortAlliesByAscendingOrder(allies, questName, players);
        weapons = strat.sortWeaponsByAscendingOrder(weapons);

        while (allies.Count > 0 && bpNeeded > 0)
        {
            foeEncounter.Add(allies[0]);
            AllyCard ally = (AllyCard)allies[0];
            bpNeeded -= ally.getBattlePoints(questName, players);
            allies.Remove(allies[0]);
        }

        while (weapons.Count > 0 && bpNeeded > 0)
        {
            foeEncounter.Add(weapons[0]);
            WeaponCard weapon = (WeaponCard)weapons[0];
            bpNeeded -= weapon.battlePoints;
            weapons.Remove(weapons[0]);
        }
        // return the resulting list
        return(foeEncounter);
    }
Exemplo n.º 13
0
    public bool canIIncrement(int stages, List <Card> hand, List <Player> players, QuestCard card)
    {
        strategyUtil strat            = new strategyUtil();
        int          firstStageToFill = 1;
        bool         hasAmour         = false;
        int          prev             = 0;

        List <Card> allies  = new List <Card>();
        List <Card> weapons = new List <Card>();

        // Seperately fill lists with our weapons and allies
        for (int i = 0; i < hand.Count; i++)
        {
            if (hand[i].type == "Weapon Card")
            {
                weapons.Add(hand[i]);
            }
            // If we have an Amour Card, it will immediately be played meaning we start filling stages from round 2 (bc round 1 will be 10BP)
            if (hand[i].type == "Amour Card" && (hasAmour == false))
            {
                hasAmour         = true;
                firstStageToFill = 2;
                prev             = 10;
            }
            if (hand[i].type == "Ally Card")
            {
                AllyCard ally = (AllyCard)hand[i];
                if (ally.getBattlePoints(card.name, players) > 0)
                {
                    allies.Add(hand[i]);
                }
            }
        }
        // sort them by ascending order
        allies  = strat.sortAlliesByAscendingOrder(allies, card.name, players);
        weapons = strat.sortWeaponsByAscendingOrder(weapons);

        // Now we walk through each stage of the quest
        for (int i = firstStageToFill; i <= stages; i++)
        {
            // instantiate a list of unique weapon to ensure each stage doesn't have duplicate weapons
            List <Card> uniqueWeapons = new List <Card>();
            // set our threshold for how many BP this stage needs (incremented by 10)
            int pointThreshold = (10 + prev);
            // our current points for this stage
            int points = 0;
            // while we still have allies to play and we have yet to hit our point threshold
            while (allies.Count > 0 && (points < pointThreshold))
            {
                // play our allies and increment points to include their battlePoints
                AllyCard ally = (AllyCard)allies[0];
                points += ally.getBattlePoints(card.name, players);
                allies.Remove(allies[0]);
            }
            // if we run out of allies, we can loop through weapons and make sure that were not gonna play a duplicate weapon
            while (weapons.Count > 0 && (points < pointThreshold) && strat.checkDuplicate(weapons[0], uniqueWeapons, "Weapon Card"))
            {
                WeaponCard weapon = (WeaponCard)weapons[0];
                points += weapon.battlePoints;
                weapons.Remove(weapons[0]);
            }
            // if we've run out of allies AND weapons but haven't filled in this current stage yet then return false
            if (points < pointThreshold)
            {
                return(false);
            }
            // set prev to whatever our points ended up as
            prev = points;
        }
        // return true if weve made it through all stages
        return(true);
    }