/// <summary> /// Returns a prediction of the opponent's hand cards, i.e. set of cards and there probability, /// based on the bi-gram map and cards which haven been played the opponent. /// </summary> /// <param name="cardCount">the number of sets which will by predicted</param> /// <param name="simulationGame">the game the prediction is performed on</param> /// <param name="playedCards">the cards which have been played by the opponent</param> /// <param name="boardCards">the board cards of the opponent</param> /// <param name="classPrediction">the prediction of the deck classes of the opponent</param> /// <returns>the set of cards and there probability</returns> private List <PredictedCards> predictCards(int cardCount, POGame.POGame simulationGame, PlayedCards playedCards, BoardCards boardCards, Dictionary <CardClass, double> classPrediction) { List <Dictionary <string, double> > occMaps = getOccurenceMaps(playedCards); var combinedOccMap = new Dictionary <string, double>(); foreach (Dictionary <string, double> occMap in occMaps) { occMap.ToList().ForEach(o => { string cardId = o.Key; double cardValue = o.Value; if (combinedOccMap.ContainsKey(cardId)) { // greedy approach if (combinedOccMap[cardId] < cardValue) { combinedOccMap[cardId] = cardValue; } } else { combinedOccMap.Add(cardId, cardValue); } }); } Dictionary <Card, double> playableCards = convertToCardMap(combinedOccMap, classPrediction); // get number of cards in relation to the class distribution of already drawn cards var tempPredictedCardGroups = new List <PredictedCards>(); classPrediction.ToList().ForEach(c => { // filter cards if they have already been exhausted or not var filterdPlayableCards = new PredictedCards( playableCards.Where(p => p.Key.Class == c.Key) .Where(p => { if (p.Key.Rarity == Rarity.LEGENDARY) { return(boardCards.Cards .Count(b => b == p.Key) < 1); } else { return(boardCards.Cards .Count(b => b == p.Key) < 2); } }).ToList()); int share = (int)(c.Value * cardCount); var predictedCards = new PredictedCards(filterdPlayableCards .CardEntries.Take(share) .ToList()); tempPredictedCardGroups.Add(predictedCards); }); var combinedPredictedCards = new PredictedCards( tempPredictedCardGroups.SelectMany(g => g.CardEntries) .ToList()); double sum = combinedPredictedCards.Sum; var predictedCardGroups = new List <PredictedCards>(); foreach (PredictedCards group in tempPredictedCardGroups) { var newGroup = new PredictedCards(); group.CardEntries // sort list .OrderByDescending(c => c.Value) .ToList().ForEach(c => newGroup.Add(c.Key, (c.Value / sum))); predictedCardGroups.Add(newGroup); } return(predictedCardGroups); }
public void AddPredictedCard(string cardId) => PredictedCards.Add(cardId);