/// <summary> /// Converts a list of cards to a Picks /// </summary> /// <param name="toConvert">List to convert</param> /// <returns>Picks created using the list</returns> public static Picks List2Picks(List<Card> toConvert) { if (toConvert == null) throw new ArgumentNullException("List<Card> toConvert was null"); Picks toRet = new Picks(); foreach (Card card in toConvert) toRet.Add(card); return toRet; }
/// <summary> /// Choose the best card for the AI /// based on its deck's top two colors. /// </summary> /// <param name="AINum">AI number to choose for</param> /// <param name="packNum">Pack number to choose from</param> private void Logic(int AINum, int packNum) { try { var temp = File.Create("AI " + AINum.ToString() + "-think.dmf-temp");//Create temp file temp.Close(); for (int j = 0; j < packs[packNum].Count; j++) SortRelevantColors(AINum, j, packNum);//Sort the relevantly colored cards in the pack List<Card> usableX = GetRelevantColors(AINum, packNum);//Get the relevantly colored cards in the pack Picks usable = new Picks();//Generate a Picks for use in logic foreach (Card card in usableX) usable.Add(card); if (usable.Cards.Count < 1)//If there is no usable card in the pack, just choose the best one { for (int j = 0; j < packs[packNum].Count; j++) PointSys(AINum, j, packNum); } else { Picks toUse = usable; if (draftedCards[AINum].Proportion < .667F)//If the number of creatures in the usable picks is less than 2/3s { toUse = Picks.List2Picks(toUse.Creatures);//Pick a creature from the pack if (draftedCards[AINum].AvgCMC < 3.5F || toUse.CMCLessThan(3).Count < 1)//If the curve is too high, toUse = Picks.List2Picks(toUse.CMCLessThan(4));//Choose a low cmc creature else if (draftedCards[AINum].AvgCMC < 2.7)//If the curve is moderate, toUse = Picks.List2Picks(Picks.List2Picks(toUse.CMCLessThan(6)).CMCGreaterThan(3));//choose a middle-costed card else//if the curve is low toUse = Picks.List2Picks(toUse.CMCGreaterThan(5));//choose a high cmc creature } else//if we have atleast 2/3 of our usable picks as creatures, pick a noncreature card { toUse = Picks.List2Picks(toUse.Noncreature); if (draftedCards[AINum].AvgCMC < 3.5F)//If the curve is too high, toUse = Picks.List2Picks(toUse.CMCLessThan(4));//Choose a low cmc card else if (draftedCards[AINum].AvgCMC < 2.7)//If the curve is moderate, toUse = Picks.List2Picks(Picks.List2Picks(toUse.CMCLessThan(6)).CMCGreaterThan(3));//Choose a middle-costed card else//if the curve is low toUse = Picks.List2Picks(toUse.CMCGreaterThan(5));//choose a high cmc card } if (toUse.Cards.Count < 1)//if we can't use any of the cards in the pack toUse = usable;//just pick one of the relevantly colored cards in the pack for (int j = 0; j < toUse.Cards.Count; j++) PointSys(AINum, j, toUse.Cards);//Choose the highest rated card in the usable picks //read our highest-scored card StreamReader reader = new StreamReader("AI " + AINum.ToString() + ".dmf-temp"); reader.ReadLine(); int high = gInclude.Parse.String2Int(reader.ReadLine()); reader.Close(); reader = new StreamReader("AI " + AINum.ToString() + "-think.dmf-temp"); if (high > 0) { for (int i = 1; i < high; i++) reader.ReadLine(); } //and tell the AI to pick it StreamWriter writer = new StreamWriter("AI " + AINum.ToString() + ".dmf-temp"); writer.WriteLine(); writer.WriteLine(reader.ReadLine()); reader.Close(); writer.Close(); } File.Delete("AI " + AINum.ToString() + "-think.dmf-temp"); } catch { } }