// the first condition checks that more than one player can rank up in this quest and the CPU has valid sponsorship. public bool firstCondition(List <Player> players, int stages, List <Card> hand) { strategyUtil strat = new strategyUtil(); int count = strat.rankUpCount(players, stages); return(count > 1 && strat.canISponsor(hand, stages)); }
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); }
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); }
// 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); }
// Return a list of list the count of stages, where at each index is the card(s) that sets up each stage public List <List <Card> > setupQuest(int stages, List <Card> hand, string questFoe) { strategyUtil strat = new strategyUtil(); // instantiate the quest line List <List <Card> > questLine = new List <List <Card> >(); // create the final stage first List <Card> finalStage = setupFoeStage(stages, stages, hand, questFoe, 0); // if we have a test, create a test stage and then work from the first stage to fill in the foe stages if (strat.haveTest(hand)) { List <Card> testStage = setupTestStage(hand); for (int i = 0; i < (stages - 2); i++) { List <Card> foeStage = setupFoeStage(i, stages, hand, questFoe, 0); questLine.Add(foeStage); } questLine.Add(testStage); // else we don't have a test, we fill in foe stages the same way but 1 more for the missing test } else { for (int i = 0; i < (stages - 1); i++) { List <Card> foeStage = setupFoeStage(i, stages, hand, questFoe, 0); questLine.Add(foeStage); } } // add our final Stage that we created first so its on the end and return questLine.Add(finalStage); return(questLine); }
// 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); }
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); }
//GONNA NEED TO MAKE A SMALL CHANGE HERE public List <Card> fixHandDiscrepancy(List <Card> hand) { strategyUtil strat = new strategyUtil(); List <Card> toDiscard = strat.fixHandCPU(hand); return(toDiscard); }
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); }
public int GetStageBP(int index, QuestCard q) { strategyUtil util = new strategyUtil(); int sum = 0; Debug.Log("GetStageBP index: " + index.ToString()); if (index >= QuestState.stages.Length) { Debug.Log("Invalid index given to GetStageBP"); return(-2); } if (QuestState.stages[index] == null) { Debug.Log("null index given to GetStageBP"); return(-2); } if (QuestState.stages[index].Count < 1) { Debug.Log("Blank Stage"); return(-2); } if (QuestState.stages[index][0] == null) { Debug.Log("Blank Stage"); return(-2); } if (QuestState.stages[index][0].type != "Foe Card" && QuestState.stages[index][0].type != "Test Card") { Debug.Log("First card in stage[" + index.ToString() + "] is not a Foe or Test card"); return(-2); } else { if (QuestState.stages[index][0].type == "Test Card") { return(-1); } else { //We have a foe and weapon card sum += util.getContextBP((FoeCard)QuestState.stages[index][0], QuestState.currentQuest.foe); for (int i = 1; i < QuestState.stages[index].Count; i++) { if (QuestState.stages[index][i].type != "Weapon Card") { Debug.Log("Invalid quest stage config, stage[" + index.ToString() + "] has a " + QuestState.stages[index][i].type + " at index " + i.ToString() + "."); return(-2); } else { sum += ((WeaponCard)QuestState.stages[index][i]).battlePoints; } } } return(sum); } }
// 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); }
// Tournament Strategy // Strategy #1, the player participates if anyone, including themselves, can stand to rank up public int participateInTourney(List <Player> players, int shields, Controller game) { Debug.Log("I was asked If I want to participate in a tournament!"); strategyUtil strat = new strategyUtil(); if (strat.canSomeoneRankUp(players, shields)) { Debug.Log("I'm going to say yes... because its possible for someone to rank up during this tourney!"); return(1); } Debug.Log("I'm going to say no... because its NOT possible for someone to rank up during this tourney!"); return(0); }
public List <Card> playTournament(List <Player> players, List <Card> hand, int baseBP, int shields) { strategyUtil strat = new strategyUtil(); // This AI evaluates wheteher there is a potential rank up on this tournament if (strat.canSomeoneRankUp(players, shields)) { // If there is, he considers it high stakes and plays his strongest hand return(highStakesTournament(hand, players)); } // else he considers it low stakes and plays only duplicate weapons return(lowStakesTournament(hand)); }
// The second condition checks that the CPU has a valid sponsorship and 6 or more foes. public bool secondCondition(List <Card> hand, int stages) { strategyUtil strat = new strategyUtil(); int foeCount = 0; for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { foeCount += 1; } } return(foeCount > 5 && strat.canISponsor(hand, stages)); }
// Quest Strategy public int sponsorQuest(List <Player> players, int stages, List <Card> hand, Controller game) { strategyUtil strat = new strategyUtil(); if (strat.canSomeoneRankUp(players, stages)) { return(0); } if (strat.canISponsor(hand, stages)) { return(1); } return(0); }
// Quest Strategy public int sponsorQuest(List <Player> players, int stages, List <Card> hand, Controller game) { strategyUtil strat = new strategyUtil(); // if somebody can rank up, we return false to decline sponsoring the quest if (strat.canSomeoneRankUp(players, stages)) { return(0); } if (strat.canISponsor(hand, stages)) { return(1); } return(0); }
public List <List <Card> > setupQuest(int stages, List <Card> hand, string questFoe) { // instantiate the quest line strategyUtil strat = new strategyUtil(); List <List <Card> > questLine = new List <List <Card> >(); // create the final stage first List <Card> finalStage = setupFoeStage(stages, stages, hand, questFoe, 0); int prevBP = strat.sumFoeEncounterCards(finalStage, questFoe); questLine.Add(finalStage); // if we have a test, create a test stage and then work from the first stage to fill in the foe stages if (strat.haveTest(hand)) { List <Card> testStage = setupTestStage(hand); questLine.Add(testStage); for (int i = 0; i < (stages - 2); i++) { List <Card> foeStage = setupFoeStage(i, stages, hand, questFoe, prevBP); questLine.Add(foeStage); prevBP = strat.sumFoeEncounterCards(foeStage, questFoe); } // else we don't have a test, we fill in foe stages the same way but 1 more for the missing test } else { for (int i = 0; i < (stages - 1); i++) { List <Card> foeStage = setupFoeStage(i, stages, hand, questFoe, prevBP); questLine.Add(foeStage); prevBP = strat.sumFoeEncounterCards(foeStage, questFoe); } } questLine.Reverse(); /* * for (int i = 0; i < questLine.Count; i++) * { * for (int j = 0; j < questLine[i].Count; j++) * { * questLine[i][j].display(); * } * } */ return(questLine); }
// 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); }
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); }
public List <Card> setupTestStage(List <Card> hand) { strategyUtil strat = new strategyUtil(); List <Card> tests = new List <Card>(); for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Test Card") { tests.Add(hand[i]); } } tests = strat.sortTetstsbyAscendingOrder(tests); List <Card> test = new List <Card>(); test.Add(tests[0]); return(test); // get the test card with the highest bid test card in the hand }
public List <Card> setupTestStage(List <Card> hand) { strategyUtil strat = new strategyUtil(); List <Card> tests = new List <Card>(); // gather all of the tests in the CPU hand for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Test Card") { tests.Add(hand[i]); } } // sort them in ascending order and return the first tests = strat.sortTetstsbyAscendingOrder(tests); List <Card> test = new List <Card>(); test.Add(tests[0]); return(test); }
public List <List <Card> > setupQuest(int stages, List <Card> hand, string questFoe) { strategyUtil strat = new strategyUtil(); // initalize the quest line List <List <Card> > questLine = new List <List <Card> >(); // call setupFoeStage with stage == stages so it'll know to set up the FINAL encounter. List <Card> finalStage = setupFoeStage(stages, stages, hand, questFoe, 0); // get the BP of the foe encounter and add it to the questLine int prevBP = strat.sumFoeEncounterCards(finalStage, questFoe); questLine.Add(finalStage); // we either build the rest of the Quest taking into account a test encounter. if (strat.haveTest(hand)) { List <Card> testStage = setupTestStage(hand); questLine.Add(testStage); for (int i = 0; i < (stages - 2); i++) { List <Card> foeStage = setupFoeStage(i, stages, hand, questFoe, prevBP); prevBP = strat.sumFoeEncounterCards(foeStage, questFoe); questLine.Add(foeStage); } } // or a quest being filled by purely foe encounters else { for (int i = 0; i < (stages - 1); i++) { List <Card> foeStage = setupFoeStage(i, stages, hand, questFoe, prevBP); prevBP = strat.sumFoeEncounterCards(foeStage, questFoe); questLine.Add(foeStage); } } // reverse the quest because weve set up the stages backward then return questLine.Reverse(); return(questLine); }
// 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); }
//NEEDS CHANGESSSSSSSSSSSS!!!!!!!!!!!!!! public void CalculateTotalBP() { int total = 0; strategyUtil util = new strategyUtil(); for (int i = 0; i < selectedCards.Count; i++) { if (selectedCards[i].type == "Foe Card") { FoeCard foe = (FoeCard)selectedCards[i]; if (QuestState.currentQuest != null) { total += util.getContextBP(foe, QuestState.currentQuest.foe); } else { total += foe.minBP; } } else if (selectedCards[i].type == "Weapon Card") { WeaponCard weapon = (WeaponCard)selectedCards[i]; total += weapon.battlePoints; } else if (selectedCards[i].type == "Ally Card") { AllyCard ally = (AllyCard)selectedCards[i]; total += ally.battlePoints; } else if (selectedCards[i].type == "Amour Card") { AmourCard amour = (AmourCard)selectedCards[i]; total += amour.battlePoints; } } totalBP.text = "BP: " + total.ToString(); }
// 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); }
public List <Card> setUpEarlyFoeEncounter(List <Card> hand, string questFoe, int prev) { strategyUtil strat = new strategyUtil(); // instantiate a list of foes we have and the foe encounter List <Card> foeEncounter = new List <Card>(); List <Card> foes = new List <Card>(); // put all valid foe cards in the foes list 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]); } } // sort by descending order, take teh strongest and return foes = strat.sortFoesByDescendingOrder(foes, questFoe); foeEncounter.Add(foes[0]); hand.Remove(foes[0]); return(foeEncounter); }
// This sets up an early Foe Encounter, a Foe encounter before the last round of a Quest. // This strategy is to simply play the lowest BP foe from the hand with NO weapons attached public List <Card> setUpEarlyFoeEncounter(List <Card> hand, string questFoe) { strategyUtil strat = new strategyUtil(); // get the list of foe cards from the user's hand List <Card> foes = new List <Card>(); for (var i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { foes.Add(hand[i]); } } foes = strat.sortFoesByAscendingOrder(foes, questFoe); // make a list, add the lowest BP foe and return it List <Card> foeEncounter = new List <Card>(); foeEncounter.Add(foes[0]); hand.Remove(foes[0]); return(foeEncounter); }
// checks whether or not a CPU has the requisite cards to sponsor the quest public bool canISponsor(List <Card> hand, int stages) { // see if we have enough cards to sponsor the quest // Count through our hand and subtract strategyUtil strat = new strategyUtil(); int stageCount = stages; List <Card> foes = new List <Card>(); for (var i = 0; i < hand.Count; i++) { // count up our foes to compare to the # of stages if (hand[i].type == "Foe Card" && checkDuplicate(hand[i], foes, "Foe Card")) { stageCount -= 1; foes.Add(hand[i]); } } // decreate stageCount by one more if we had a Test if (strat.haveTest(hand)) { stageCount -= 1; } return(stageCount <= 0); }
public List <Card> playEarlierFoe(List <Card> hand, int previous, bool amour, string questName, List <Player> players) { strategyUtil strat = new strategyUtil(); List <Card> foeEncounter = new List <Card>(); List <Card> weapons = new List <Card>(); /* * Loop through the hand, if it as an Amour and Amour == false we add it, if it is an ally we add it * This is because the effects of these will be felt throughout the quest, play them now. * * We also add only our weakest weapon each round. */ for (int i = 0; i < hand.Count; i++) { if (amour == false) { if (hand[i].type == "Amour Card") { foeEncounter.Add(hand[i]); amour = true; } } if (hand[i].type == "Ally Card") { foeEncounter.Add(hand[i]); } if (hand[i].type == "Weapon Card") { weapons.Add(hand[i]); } } weapons = strat.sortWeaponsByAscendingOrder(weapons); foeEncounter.Add(weapons[0]); return(foeEncounter); }
// Discard 2 lowest BP foes for the King's Call Event public List <Card> discardFoesForKing(List <Card> hand) { strategyUtil strat = new strategyUtil(); return(strat.discardFoesForKing(hand)); }