Ejemplo n.º 1
0
        public static float[] CalculateFast(int[] hand, int handLength, SdKind sdKind)
        {
            Debug.Assert(handLength >= 0 && handLength <= 7);
            if (handLength == 7)
            {
                // SdKind.SdPlus1 will throw an exception, this is exactly what we want.
                return(Calculate(hand, handLength, sdKind == SdKind.SdPlus1 ? 4 : 3));
            }

            if (_lut2 == null)
            {
                LoadLuts();
            }

            float[] hssd = new float[2];

            int      round    = HeHelper.HandSizeToRound[handLength];
            CardSet  pocket   = StdDeck.Descriptor.GetCardSet(hand, 0, 2);
            CardSet  board    = StdDeck.Descriptor.GetCardSet(hand, 2, handLength - 2);
            NormSuit se       = new NormSuit();
            CardSet  sePocket = se.Convert(pocket);
            CardSet  seBoard  = se.Convert(board);

            if (round == 2)
            {
                Entry2 keyEntry = new Entry2(HePocket.CardSetToKind(sePocket), seBoard);
                int    idx      = Array.BinarySearch(_lut2, keyEntry);
                if (idx < 0)
                {
                    ThrowNoEntryException(sePocket, seBoard);
                }
                hssd[0] = _lut2[idx].Hs;
                // For turn, there is no difference between SD kinds.
                hssd[1] = _lut2[idx].SdPlus1;
            }
            else
            {
                Entry01 keyEntry = new Entry01(HePocket.CardSetToKind(sePocket), seBoard);
                int     idx      = Array.BinarySearch(_lut01[round], keyEntry);
                if (idx < 0)
                {
                    ThrowNoEntryException(sePocket, seBoard);
                }
                // For turn, there is no difference between SD kinds.
                hssd[0] = _lut01[round][idx].Hs;
                hssd[1] = sdKind == SdKind.SdPlus1 ? _lut01[round][idx].SdPlus1 : _lut01[round][idx].Sd3;
            }
            return(hssd);
        }
Ejemplo n.º 2
0
 public static float[] CalculateFast(int[] hand, SdKind sdKind)
 {
     return(CalculateFast(hand, hand.Length, sdKind));
 }