Esempio n. 1
0
        McHand[] CreateMcHands(int round, Bucket parentBucket)
        {
            if (parentBucket.Length == 0)
            {
                if (IsVerbose)
                {
                    Console.WriteLine("Empty parent bucket");
                }
                return(new McHand[0]);
            }
            int samplesCount = (SamplesCount[round] / parentBucket.Length + 1) * parentBucket.Length;

            McHand[] hands        = new McHand[samplesCount];
            int      shuffleCount = HeHelper.RoundToHandSize[round] - HeHelper.RoundToHandSize[round - 1];
            int      s            = 0;

            if (IsVerbose)
            {
                Console.WriteLine("Creating random hands: parent hands: {0}, samples: {1}, deal: {2}",
                                  parentBucket.Length, samplesCount, shuffleCount);
            }
            for (int h = 0; h < parentBucket.Length; ++h)
            {
                for (int rep = 0; rep < samplesCount / parentBucket.Length; ++rep)
                {
                    McHand hand = new McHand(parentBucket.Hands[h]);
                    SequenceRng.Shuffle(_rng, hand.Cards, hand.Length, shuffleCount);
                    hand.Length += shuffleCount;
                    hands[s++]   = hand;
                    if (IsVerboseSamples)
                    {
                        Console.WriteLine(StdDeck.Descriptor.GetCardNames(hand.Cards, 0, hand.Length));
                    }
                }
            }
            Debug.Assert(s == samplesCount);
            _totalMcSamples += samplesCount;
            return(hands);
        }
Esempio n. 2
0
        private Bucket[] CreatePreflopBuckets(int preflopBucketsCount)
        {
            Bucket[] buckets = new Bucket[preflopBucketsCount].Fill(i => new Bucket());

            int totalHands = 0;

            for (int i = 0; i < HePocket.Count; ++i)
            {
                HePocketKind pk = (HePocketKind)i;
                // Use all possible pockets for each pocket kind. This ensures
                // that they occur with the natural frequency in a typical case where
                // a bucket contain pocket kinds with different numbers of pockets (e.g. AA - 6, AKs - 4, AKo - 12).
                CardSet [] range = HePocket.KindToRange(pk);
                foreach (CardSet pocketCs in range)
                {
                    McHand  hand   = new McHand();
                    int[]   pocket = StdDeck.Descriptor.GetIndexesAscending(pocketCs).ToArray();
                    CardSet restCs = StdDeck.Descriptor.FullDeck;
                    restCs.Remove(pocketCs);
                    int[] rest = StdDeck.Descriptor.GetIndexesAscending(restCs).ToArray();
                    Debug.Assert(pocket.Length + rest.Length == 52);

                    pocket.CopyTo(hand.Cards, 0);
                    rest.CopyTo(hand.Cards, 2);
                    hand.Length = 2;

                    int abstrCard = Clusterizer.GetAbstractCard(hand.Cards, hand.Length);
                    buckets[abstrCard].Hands.Add(hand);
                    totalHands++;
                }
            }
            Debug.Assert(totalHands == 1326);
            if (IsVerbose)
            {
                Console.WriteLine("Preflop buckets created, buckets: {0}, hands: {1}", buckets.Length, totalHands);
            }

            return(buckets);
        }
Esempio n. 3
0
 public McHand(McHand other)
 {
     Length = other.Length;
     Cards  = other.Cards.ShallowCopy();
 }