예제 #1
0
 public static bool isSameCards(byte[] byCards, stAnswer answer)
 {
     byte[] bySrc  = new byte[13];
     byte[] byTemp = new byte[13];
     for (int i = 0; i < 13; ++i)
     {
         bySrc[i] = byCards[i];
     }
     answer.getData(byTemp);
     for (int i = 0; i < 13; ++i)
     {
         bool bFind = false;
         for (int n = 0; n < 13; ++n)
         {
             if (byTemp[n] == byCards[i])
             {
                 bFind = true;
                 break;
             }
         }
         if (bFind == false)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
        //
        public static void JudgeCards(byte[] cbCardData, byte cbCount, ref List <stAnswer> vctOut)
        {
            byte[,] byData = new byte[14, 5];
            for (byte i = 0; i < cbCount; ++i)
            {
                byte val = byte.Parse((cbCardData[i] % 0x10).ToString());
                byte cor = byte.Parse((cbCardData[i] / 0x10).ToString());
                val -= 2;
                if (val == 255)
                {
                    val = 12;
                }

                ++byData[val, 4];
                ++byData[val, cor];
                Trace.Assert(byData[val, cor] <= 1);
                if (byData[val, cor] > 1)
                {
                    return;                     // 输入数据有误! 牌值重复
                }
            }
            stAnswer answer     = new stAnswer();
            uint     dwScoreMax = DEF.CT_FIVE_MAX << 22;

            TryCards(ref byData, ref answer, dwScoreMax, ref vctOut);
        }
예제 #3
0
        private static int Compare(stAnswer temp1, stAnswer temp2)
        {
            double[,] fVal = new double[3, 16 * 14] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0.02, 0.05, 0.09, 0.17, 0.26, 0.37, 0.49, 0.60, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.68, 0.78, 0.82, 0.88, 0.93, 0.98, 1.03, 1.10, 1.16, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.33, 1.50, 1.82, 2.24, 2.78, 3.39, 4.05, 4.76, 4.76, 4.76, 4.76, 11.42, 17.58, 23.23, 28.25, 32.63, 36.36, 39.60, 42.41, 44.81, 46.84, 48.70, 50.24, 51.57, 51.57, 51.57, 51.57, 55.02, 58.68, 62.40, 66.10, 69.66, 73.21, 76.75, 80.10, 83.33, 86.66, 90.06, 93.41, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.49, 96.79, 97.09, 97.46, 97.90, 98.35, 98.79, 99.21, 99.65, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0.08, 0.34, 1.19, 1.19, 1.19, 1.19, 1.35, 1.56, 1.77, 2.00, 2.27, 2.59, 2.93, 3.30, 3.71, 4.19, 4.73, 5.42, 6.24, 6.24, 6.24, 6.24, 6.24, 6.50, 7.08, 8.02, 9.43, 11.28, 13.58, 16.18, 19.14, 22.18, 25.34, 28.39, 30.97, 30.97, 30.97, 30.97, 31.03, 31.30, 31.82, 32.63, 33.74, 35.18, 36.92, 39.15, 41.50, 44.23, 47.32, 50.62, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 53.86, 54.10, 54.32, 54.60, 54.93, 55.31, 55.81, 56.42, 57.20, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.32, 58.36, 58.46, 58.69, 59.09, 59.83, 60.93, 62.60, 64.88, 64.88, 64.88, 64.88, 67.89, 70.87, 73.79, 76.69, 79.52, 82.20, 84.71, 87.10, 89.29, 91.23, 92.98, 94.47, 95.75, 95.75, 95.75, 95.75, 96.38, 97.00, 97.58, 98.10, 98.55, 98.92, 99.23, 99.48, 99.68, 99.83, 99.92, 99.98, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0.06, 0.19, 0.51, 1.16, 2.36, 4.55, 8.73, 15.70, 27.06, 45.62, 45.62, 45.62, 45.62, 45.86, 46.30, 46.98, 47.98, 49.31, 51.12, 53.45, 56.39, 60.30, 65.35, 71.65, 79.88, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.65, 90.71, 90.94, 91.36, 91.97, 92.75, 93.72, 94.74, 95.79, 96.79, 97.73, 98.59, 99.37, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, },
            };
            // [3,DEF.CT_FIVE_MAX]
            float[,] fPer = new float[3, 14] {
                { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 5, 5, },                      // 三首权重 [CT_INVALID, CT_FIVE_MAX)
                { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 8, 10, 10, 10, },                   // 二首权重 [CT_INVALID, CT_FIVE_MAX)
                { 0, 1, 1, 3, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, },                     // 头首权重 [CT_INVALID, CT_FIVE_MAX)
            };
            uint[] t1 = new uint[3] {
                temp1.dwVal[0] >> 22, temp1.dwVal[1] >> 22, temp1.dwVal[2] >> 22
            };
            uint[] t2 = new uint[3] {
                temp2.dwVal[0] >> 22, temp2.dwVal[1] >> 22, temp2.dwVal[2] >> 22
            };
            uint[] type1 = new uint[3] {
                temp1.dwVal[0] >> 18, temp1.dwVal[1] >> 18, temp1.dwVal[2] >> 18
            };
            uint[] type2 = new uint[3] {
                temp2.dwVal[0] >> 18, temp2.dwVal[1] >> 18, temp2.dwVal[2] >> 18
            };
            float fFlag1 = 0, fFlag2 = 0;

            for (int i = 0; i < 3; ++i)
            {
                fFlag1 += fPer[i, t1[i]] * (float)fVal[i, type1[i]];
                fFlag2 += fPer[i, t2[i]] * (float)fVal[i, type2[i]];
            }
            if (fFlag1 == fFlag2)
            {
                return(0);
            }
            return(fFlag1 > fFlag2 ? -1 : 1);
        }
예제 #4
0
        public static bool cmp(ref stAnswer temp1, ref stAnswer temp2)
        {
            // [3,DEF.CT_FIVE_MAX]
            float[,] fPer = new float[3, 14] {
                { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 5, 5, },
                { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 8, 10, 10, 10, },
                { 0, 1, 1, 3, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            };
            uint[] t1 = new uint[3] {
                temp1.dwVal[0] >> 22, temp1.dwVal[1] >> 22, temp1.dwVal[2] >> 22
            };
            uint[] t2 = new uint[3] {
                temp2.dwVal[0] >> 22, temp2.dwVal[1] >> 22, temp2.dwVal[2] >> 22
            };
            float fFlag1 = 0, fFlag2 = 0;

            for (int i = 0; i < 3; ++i)
            {
                fFlag1 += fPer[i, t1[i]];
                fFlag2 += fPer[i, t2[i]];
            }
            return(fFlag1 > fFlag2);
        }
예제 #5
0
        static void Main(string[] args)
        {
            byte[] byTest =
            {
                0x09, 0x03, 0x04, 0x0D, 0x07, 0x16, 0x18, 0x19, 0x2B, 0x2D, 0x31, 0x33, 0x37, 0x38, 0x39, 0x3D, 0x1F
            };
            int byCardNum = byTest.Length;

            byte[] byTest2 =
            {
                0x01, 0x0D, 0x0A, 0x0F, 0x1F
            };
            int  byCardNum2 = byTest2.Length;
            bool isMax      = GameLogic.IsMaxTHS(byTest2, byCardNum2);

            List <stAnswer> vctOut  = new List <stAnswer>();        // 不去重结果
            List <stAnswer> vctOut2 = new List <stAnswer>();        // 去重结果

            GameLogic.JudgeCards(byTest, (byte)byCardNum, ref vctOut);

            vctOut.Sort(Compare);
            for (int i = 0; i < vctOut.Count; ++i)
            {
                int[] nType = new int[3] {
                    (int)(vctOut[i].dwVal[0] >> 22), (int)(vctOut[i].dwVal[1] >> 22), (int)(vctOut[i].dwVal[2] >> 22)
                };
                int nFlag = nType[0] * 10000 + nType[1] * 100 + nType[2];
                int j     = 0;
                for (; j < vctOut2.Count; ++j)
                {
                    int[] nType2 = new int[3] {
                        (int)(vctOut2[j].dwVal[0] >> 22), (int)(vctOut2[j].dwVal[1] >> 22), (int)(vctOut2[j].dwVal[2] >> 22)
                    };
                    int nFlag2 = nType2[0] * 10000 + nType2[1] * 100 + nType2[2];
                    // 牌型相同时,选最优的留下
                    if (nFlag == nFlag2)
                    {
                        if (Compare(vctOut[i], vctOut2[j]) <= 0)
                        {
                            vctOut2[j] = vctOut[i];
                        }
                        break;
                    }
                    // 去除所有牌型 都比现有差的组合
                    if (nType[0] <= nType2[0] && nType[1] <= nType2[1] && nType[2] <= nType2[2])
                    {
                        break;
                    }
                }
                if (j >= vctOut2.Count)
                {
                    vctOut2.Add(vctOut[i]);
                }
            }
            //*/
            vctOut2.Sort(Compare);

            //打印牌组
            for (int i = 0; i < vctOut.Count; ++i)
            {
                Console.WriteLine("");
                stAnswer answer = vctOut[i];
                for (int id = 0; id < 3; ++id)
                {
                    Console.WriteLine("type={0} -> {1} \t{2:x2}\t{3:x2}\t{4:x2}\t{5:x2}\t{6:x2}",
                                      (answer.dwVal[id] >> 22), answer.dwVal[id], (int)answer.byCards[id, 0],
                                      (int)answer.byCards[id, 1], (int)answer.byCards[id, 2], (int)answer.byCards[id, 3], (int)answer.byCards[id, 4]);
                }
            }
            Console.ReadKey();
        }
예제 #6
0
        //核心函数 (用递归+回溯法 计算所有可能组合)
        //vctAnswer:    所有结果列表
        //dwScoreMax:   阀值分
        //answer:       记录当前答案
        //byData:        当前剩余牌数量记录         [i, 0-3] 第i张牌的黑红梅方 是否存在           [i, 4] 第i张牌总数量
        public static void TryCards(ref byte[,] byData, ref stAnswer answer, uint dwScoreMax, ref List <stAnswer> vctAnswer)
        {
            byte        lineNum   = 0;
            List <byte> vctTemp   = new List <byte>();
            byte        nCardsNum = 0;

            for (byte i = 0; i < 14; ++i)
            {
                nCardsNum += byData[i, 4];
            }

            // 注意:byData[13, 4] 表示当前赖子牌总数量
            if (answer.byNum < 2)
            {
                if (dwScoreMax >= DEF.CT_FIVE_STRAIGHT_FLUSH << 22)
                {
                    //同花顺
                    for (byte i = 0; i < 13 - 4; ++i)
                    {
                        for (byte n = 0; n < 4; ++n)
                        {
                            if (byData[i, n] + byData[i + 1, n] + byData[i + 2, n] + byData[i + 3, n] + byData[i + 4, n] + byData[13, 4] >= 5)
                            {
                                vctTemp.Clear();
                                for (byte id = 0; id < 5; ++id)
                                {
                                    if (byData[i + id, n] > 0)
                                    {
                                        vctTemp.Add(HelpFun.GetCard(n, (byte)(i + id)));
                                    }
                                }
                                if (byData[13, 0] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(0, 13));
                                }
                                if (byData[13, 1] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(1, 13));
                                }
                                uint dwVal = answer.push(vctTemp, ref byData);
                                if (dwVal > 0)
                                {
                                    TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                    answer.pop(ref byData);
                                }
                            }
                        }
                    }
                }
                if (dwScoreMax >= DEF.CT_FIVE_FOUR_ONE << 22)
                {
                    //四张
                    for (byte i = 0; i < 13; ++i)
                    {
                        if (byData[i, 4] + byData[13, 4] >= 4)
                        {
                            vctTemp.Clear();
                            for (byte id = 0; id < 4; ++id)
                            {
                                if (byData[i, id] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(id, i));
                                }
                            }
                            if (byData[13, 0] > 0)
                            {
                                vctTemp.Add(HelpFun.GetCard(0, 13));
                            }
                            if (byData[13, 1] > 0)
                            {
                                vctTemp.Add(HelpFun.GetCard(1, 13));
                            }
                            if (vctTemp.Count >= 5)
                            {
                                vctTemp[4] = 0;
                            }
                            uint dwVal = answer.push(vctTemp, ref byData);
                            if (dwVal > 0)
                            {
                                TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                answer.pop(ref byData);
                            }
                        }
                    }
                }
                if (dwScoreMax >= DEF.CT_FIVE_THREE_DEOUBLE << 22)
                {
                    //三带二
                    for (byte i = 0; i < 13; ++i)
                    {
                        if (byData[13, 4] + byData[i, 4] >= 3 && byData[13, 4] <= 1)
                        {
                            byte j = 0;
                            for (; j < 13; ++j)
                            {
                                if (j != i && (byData[j, 4] == 2 || byData[j, 4] == 3))
                                {
                                    vctTemp.Clear();
                                    // 三张
                                    for (byte id = 0; id < 4; ++id)
                                    {
                                        if (byData[i, id] > 0)
                                        {
                                            vctTemp.Add(HelpFun.GetCard(id, i));
                                        }
                                    }
                                    // 这里最多只加一个赖子牌
                                    if (vctTemp.Count == 2)
                                    {
                                        if (byData[13, 0] > 0)
                                        {
                                            vctTemp.Add(HelpFun.GetCard(0, 13));
                                        }
                                        else if (byData[13, 1] > 0)
                                        {
                                            vctTemp.Add(HelpFun.GetCard(1, 13));
                                        }
                                    }
                                    // 小对
                                    for (byte id = 0; id < 4; ++id)
                                    {
                                        if (byData[j, id] > 0)
                                        {
                                            vctTemp.Add(HelpFun.GetCard(id, j));
                                        }
                                    }
                                    uint dwVal = answer.push(vctTemp, ref byData);
                                    if (dwVal > 0)
                                    {
                                        TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                        answer.pop(ref byData);
                                    }
                                }
                            }
                        }
                    }
                }
                if (dwScoreMax >= DEF.CT_FIVE_FLUSH << 22)
                {
                    //同花
                    for (byte n = 0; n < 4; ++n)
                    {
                        List <byte> vctCards = new List <byte>();
                        for (byte i = 0; i < 13; ++i)
                        {
                            if (byData[i, n] == 1)
                            {
                                vctCards.Add(HelpFun.GetCard(n, i));
                            }
                        }
                        if (byData[13, 0] > 0)
                        {
                            vctCards.Add(HelpFun.GetCard(0, 13));
                        }
                        if (byData[13, 1] > 0)
                        {
                            vctCards.Add(HelpFun.GetCard(1, 13));
                        }
                        if (vctCards.Count >= 5)
                        {
                            for (int i1 = 0; i1 < vctCards.Count; ++i1)
                            {
                                for (int i2 = i1 + 1; i2 < vctCards.Count; ++i2)
                                {
                                    for (int i3 = i2 + 1; i3 < vctCards.Count; ++i3)
                                    {
                                        for (int i4 = i3 + 1; i4 < vctCards.Count; ++i4)
                                        {
                                            for (int i5 = i4 + 1; i5 < vctCards.Count; ++i5)
                                            {
                                                vctTemp.Clear();
                                                vctTemp.Add(vctCards[i1]);
                                                vctTemp.Add(vctCards[i2]);
                                                vctTemp.Add(vctCards[i3]);
                                                vctTemp.Add(vctCards[i4]);
                                                vctTemp.Add(vctCards[i5]);
                                                uint dwVal = answer.push(vctTemp, ref byData);
                                                if (dwVal > 0)
                                                {
                                                    TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                                    answer.pop(ref byData);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (dwScoreMax >= DEF.CT_FIVE_MIXED_FLUSH_NO_A << 22)
                {
                    //顺子
                    for (byte i = 0; i < 13 - 4; ++i)
                    {
                        lineNum  = 0;
                        lineNum += byData[i, 4] > 0 ? (byte)1 : (byte)0;
                        lineNum += byData[i + 1, 4] > 0 ? (byte)1 : (byte)0;
                        lineNum += byData[i + 2, 4] > 0 ? (byte)1 : (byte)0;
                        lineNum += byData[i + 3, 4] > 0 ? (byte)1 : (byte)0;
                        lineNum += byData[i + 4, 4] > 0 ? (byte)1 : (byte)0;
                        if (lineNum + byData[13, 4] >= 5)
                        {
                            vctTemp.Clear();
                            for (byte x = 0; x < 5; ++x)
                            {
                                for (byte n = 0; n < 4; ++n)
                                {
                                    if (byData[i + x, n] == 1)
                                    {
                                        vctTemp.Add(HelpFun.GetCard(n, (byte)(i + x)));
                                        break;
                                    }
                                }
                            }
                            if (byData[13, 0] > 0)
                            {
                                vctTemp.Add(HelpFun.GetCard(0, 13));
                            }
                            if (byData[13, 1] > 0)
                            {
                                vctTemp.Add(HelpFun.GetCard(1, 13));
                            }
                            uint dwVal = answer.push(vctTemp, ref byData);
                            if (dwVal > 0)
                            {
                                TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                answer.pop(ref byData);
                            }
                        }
                    }
                    // 2 3 4 5 A
                    lineNum  = 0;
                    lineNum += byData[0, 4] > 0 ? (byte)1 : (byte)0;
                    lineNum += byData[1, 4] > 0 ? (byte)1 : (byte)0;
                    lineNum += byData[2, 4] > 0 ? (byte)1 : (byte)0;
                    lineNum += byData[3, 4] > 0 ? (byte)1 : (byte)0;
                    lineNum += byData[12, 4] > 0 ? (byte)1 : (byte)0;
                    if (lineNum + byData[13, 4] >= 5)
                    {
                        vctTemp.Clear();
                        for (byte x = 0; x < 4; ++x)
                        {
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[x, n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, x));
                                    break;
                                }
                            }
                        }
                        for (byte n = 0; n < 4; ++n)
                        {
                            if (byData[12, n] == 1)
                            {
                                vctTemp.Add(HelpFun.GetCard(n, 12));
                                break;
                            }
                        }
                        if (byData[13, 0] > 0)
                        {
                            vctTemp.Add(HelpFun.GetCard(0, 13));
                        }
                        if (byData[13, 1] > 0)
                        {
                            vctTemp.Add(HelpFun.GetCard(1, 13));
                        }
                        uint dwVal = answer.push(vctTemp, ref byData);
                        if (dwVal > 0)
                        {
                            TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                            answer.pop(ref byData);
                        }
                    }
                }
                if (dwScoreMax >= DEF.CT_THREE << 22)
                {
                    //三张
                    for (int i = 12; i >= 0; --i)
                    {
                        if (byData[i, 4] <= 3 && byData[i, 4] + byData[13, 4] >= 3)
                        {
                            vctTemp.Clear();
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[i, n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, (byte)i));
                                }
                            }
                            if (vctTemp.Count == 2)
                            {
                                if (byData[13, 0] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(0, 13));
                                }
                                else if (byData[13, 1] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(1, 13));
                                }
                            }
                            else if (vctTemp.Count == 1)
                            {
                                if (byData[13, 0] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(0, 13));
                                }
                                if (byData[13, 1] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(1, 13));
                                }
                            }
                            Trace.Assert(vctTemp.Count == 3);
                            //再选两个最小单牌
                            for (byte j = 0; j < 13; ++j)
                            {
                                if (byData[j, 4] == 1 && i != j)
                                {
                                    for (byte n = 0; n < 4; ++n)
                                    {
                                        if (byData[j, n] == 1)
                                        {
                                            vctTemp.Add(HelpFun.GetCard(n, j));
                                        }
                                    }
                                }
                                if (vctTemp.Count >= 5)
                                {
                                    break;
                                }
                            }
                            if (vctTemp.Count >= 5)
                            {
                                uint dwVal = answer.push(vctTemp, ref byData);
                                if (dwVal > 0)
                                {
                                    TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                    answer.pop(ref byData);
                                }
                            }
                        }
                    }
                }
                List <byte> vctPairs  = new List <byte>();
                List <byte> vctSingle = new List <byte>();
                for (byte i = 0; i < 13; ++i)
                {
                    if (byData[i, 4] == 2)
                    {
                        vctPairs.Add(i);
                    }
                    else if (byData[i, 4] == 1)
                    {
                        vctSingle.Add(i);
                    }
                }

                if (dwScoreMax >= DEF.CT_TWO_DOUBLE << 22)
                {
                    //两对
                    if (byData[13, 4] == 0 && vctPairs.Count >= 2)
                    {
                        //多对子时,最大的对子放到最上面(三张的那组)
                        byte byMax = (byte)(vctPairs.Count - 1);
                        if (answer.byNum == 0)
                        {
                            if (vctPairs.Count >= 5)
                            {
                                byMax -= 1;
                            }
                            else if (vctPairs.Count >= 4)
                            {
                                byMax -= 2;
                            }
                        }
                        else if (vctPairs.Count >= 3)
                        {
                            byMax -= 1;
                        }
                        vctTemp.Clear();
                        for (byte n = 0; n < 4; ++n)
                        {
                            if (byData[vctPairs[byMax], n] == 1)
                            {
                                vctTemp.Add(HelpFun.GetCard(n, vctPairs[byMax]));
                            }
                        }
                        byMax--;
                        for (byte n = 0; n < 4; ++n)
                        {
                            if (byData[vctPairs[byMax], n] == 1)
                            {
                                vctTemp.Add(HelpFun.GetCard(n, vctPairs[byMax]));
                            }
                        }

                        //再选一个最小单牌
                        for (byte i = 0; i < 13; ++i)
                        {
                            if (byData[i, 4] == 1)
                            {
                                for (byte n = 0; n < 4; ++n)
                                {
                                    if (byData[i, n] == 1)
                                    {
                                        vctTemp.Add(HelpFun.GetCard(n, i));
                                    }
                                }
                            }
                            if (vctTemp.Count >= 5)
                            {
                                break;
                            }
                        }
                        uint dwVal = answer.push(vctTemp, ref byData);
                        if (dwVal > 0)
                        {
                            TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                            answer.pop(ref byData);
                        }
                    }
                }

                if (dwScoreMax >= DEF.CT_ONE_DOUBLE << 22)
                {
                    //一对
                    if ((vctPairs.Count > 0 && byData[13, 4] == 0) || (vctPairs.Count == 0 && vctSingle.Count > 0 && byData[13, 4] == 1))
                    {
                        vctTemp.Clear();
                        if (byData[13, 4] == 0)
                        {
                            byte byMax = (byte)(vctPairs.Count - 1);
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[vctPairs[byMax], n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, vctPairs[byMax]));
                                }
                            }
                        }
                        else if (byData[13, 4] == 1)
                        {
                            byte byMax = (byte)(vctSingle.Count - 1);
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[vctSingle[byMax], n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, vctSingle[byMax]));
                                    break;
                                }
                            }
                            if (vctTemp.Count == 1)
                            {
                                if (byData[13, 0] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(0, 13));
                                }
                                else if (byData[13, 1] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(1, 13));
                                }
                            }
                        }
                        Trace.Assert(vctTemp.Count == 2);
                        //再选三个最小单牌
                        for (byte i = 0; i < 13; ++i)
                        {
                            if (byData[i, 4] == 1)
                            {
                                for (byte n = 0; n < 4; ++n)
                                {
                                    if (byData[i, n] == 1)
                                    {
                                        vctTemp.Add(HelpFun.GetCard(n, i));
                                    }
                                }
                            }
                            if (vctTemp.Count >= 5)
                            {
                                break;
                            }
                        }
                        if (vctTemp.Count == 5)
                        {
                            uint dwVal = answer.push(vctTemp, ref byData);
                            if (dwVal > 0)
                            {
                                TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                                answer.pop(ref byData);
                            }
                        }
                    }
                }

                if (dwScoreMax >= DEF.CT_SINGLE << 22)
                {
                    //单牌
                    vctTemp.Clear();
                    for (byte i = 12; i > 0; --i)
                    {
                        if (byData[i, 4] == 1)
                        {
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[i, n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, i));
                                }
                            }
                        }
                        if (vctTemp.Count >= 5)
                        {
                            break;
                        }
                    }
                    if (vctTemp.Count > 5)
                    {
                        uint dwVal = answer.push(vctTemp, ref byData);
                        if (dwVal > 0)
                        {
                            TryCards(ref byData, ref answer, dwVal, ref vctAnswer);
                            answer.pop(ref byData);
                        }
                    }
                }
            }
            else
            {
                if (dwScoreMax >= DEF.CT_THREE << 22)
                {
                    //三张
                    for (byte i = 0; i < 13; ++i)
                    {
                        if (byData[i, 4] + byData[13, 4] >= 3)
                        {
                            vctTemp.Clear();
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[i, n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, i));
                                }
                            }
                            if (byData[13, 0] > 0)
                            {
                                vctTemp.Add(HelpFun.GetCard(0, 13));
                            }
                            if (byData[13, 1] > 0)
                            {
                                vctTemp.Add(HelpFun.GetCard(1, 13));
                            }
                            uint dwVal = answer.push(vctTemp, ref byData);
                            if (dwVal > 0)
                            {
                                answer.repairNote(ref byData);
                                vctAnswer.Add(HelpFun.DeepCopy <stAnswer>(answer));
                                answer.pop(ref byData);
                                answer.undo_repair(ref byData);
                            }
                        }
                    }
                }

                if (dwScoreMax >= DEF.CT_ONE_DOUBLE << 22)
                {
                    // 一对
                    for (byte i = 0; i < 13; ++i)
                    {
                        if (byData[i, 4] <= 2 && byData[13, 4] < 2 && byData[i, 4] + byData[13, 4] >= 2)
                        {
                            vctTemp.Clear();
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[i, n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, i));
                                }
                            }
                            if (vctTemp.Count == 1)
                            {
                                if (byData[13, 0] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(0, 13));
                                }
                                else if (byData[13, 1] > 0)
                                {
                                    vctTemp.Add(HelpFun.GetCard(1, 13));
                                }
                            }
                            Trace.Assert(vctTemp.Count == 2);
                            //再选一个最大单牌
                            for (int j = 12; j >= 0; --j)
                            {
                                for (byte n = 0; n < 4; ++n)
                                {
                                    if (byData[j, n] == 1 && j != i)
                                    {
                                        vctTemp.Add(HelpFun.GetCard(n, (byte)j));
                                        break;
                                    }
                                }
                                if (vctTemp.Count >= 3)
                                {
                                    break;
                                }
                            }
                            if (vctTemp.Count >= 3)
                            {
                                uint dwVal = answer.push(vctTemp, ref byData);
                                if (dwVal > 0)
                                {
                                    answer.repairNote(ref byData);
                                    vctAnswer.Add(HelpFun.DeepCopy <stAnswer>(answer));
                                    answer.pop(ref byData);
                                    answer.undo_repair(ref byData);
                                }
                            }
                        }
                    }
                }

                if (dwScoreMax >= DEF.CT_SINGLE << 22)
                {
                    //单牌
                    vctTemp.Clear();
                    for (byte i = 0; i < 13; ++i)
                    {
                        if (byData[i, 4] == 1)
                        {
                            for (byte n = 0; n < 4; ++n)
                            {
                                if (byData[i, n] == 1)
                                {
                                    vctTemp.Add(HelpFun.GetCard(n, i));
                                    break;
                                }
                            }
                        }
                    }
                    if (vctTemp.Count >= 3)
                    {
                        byte   bySize  = (byte)vctTemp.Count;
                        byte[] byCards = new byte[5] {
                            vctTemp[bySize - 1], vctTemp[bySize - 2], vctTemp[bySize - 3], 0, 0
                        };
                        uint dwVal = answer.push(vctTemp, ref byData);
                        if (dwVal > 0)
                        {
                            answer.repairNote(ref byData);
                            vctAnswer.Add(HelpFun.DeepCopy <stAnswer>(answer));
                            answer.pop(ref byData);
                            answer.undo_repair(ref byData);
                        }
                    }
                }
            }
        }