private static void RecordShuffleResult(CardPack cardPack, ShuffleTypes shuffleType, int shuffleNo, ICollection <ShuffleResult> shuffleResults) //================================================================================================================ // Add the given shuffle results to the collection // // Parameters // cardPack: Shuffled pack of cards // shuffleResults: Collection of shuffle results //================================================================================================================ { // Create a new shuffle result ShuffleResult shuffleResult = new ShuffleResult { ShuffleType = shuffleType, ShuffleNo = shuffleNo }; // Loop through each card in the deck foreach (PlayingCard card in cardPack.CardDeck) { // The shuffle pattern is determined by building a string fom the card codes shuffleResult.ShufflePattern += card.CardCode.Substring(0, 1); } // Add the shuffle result to the collection shuffleResults.Add(shuffleResult); }
//================================================================================================================ //================================================================================================================ #endregion // Constants #region Shuffling //================================================================================================================ //================================================================================================================ public static ShuffledPackage ShuffleCards(CardPack cardPack, ShuffleTypes shuffleType, int shuffleCount, bool recordResults) //================================================================================================================ // Shuffle the given pack of cards the specified nyumber of times using the given algorithm // // Parameters // cardPack: Reference to a pack of cards // shuffleType: Shuffling alroithm to use // shuffleCount: Number of times to shuffle // recordResults: Flag, record the results of each shuffle // // Returns // a shuufled package //================================================================================================================ { ShuffledPackage shuffledPackage; if (shuffleType == ShuffleTypes.FisherYates) { shuffledPackage = ShuffleCards_FisherYates(cardPack, shuffleCount, recordResults); } else { shuffledPackage = ShuffleCards_Naive(cardPack, shuffleCount, recordResults); } return(shuffledPackage); }