GR.Gambling.Blackjack.CardSet.Shuffle C# (CSharp) Method

Shuffle() public method

public Shuffle ( Random rand ) : void
rand System.Random
return void
        public void Shuffle(Random rand)
        {
            for (int i = 0; i < card_set.Count; i++)
            {
                Card c = card_set[i];

                int index = rand.Next(card_set.Count - i) + i;
                card_set[i] = card_set[index];

                card_set[index] = c;
            }
        }

Usage Example

Example #1
0
        public void ResetShoe()
        {
            shoe.Clear();

            int decks = rules.Decks;

            for (int i = 0; i < decks; i++)
            {
                shoe.Add(CardsFactory.StandardDeck);
            }

            shoe.Shuffle(random);

            agent.ResetShoe(this);
        }