예제 #1
0
        private static void SendMasterSuitOrScores(ArrayList sendedCards, int count, int suit, CurrentPoker myCP, ArrayList myPokerList, bool protectPairs)
        {
            if (sendedCards.Count >= count)
            {
                return;
            }

            for (int asuit = 1; asuit < 5; asuit++)
            {
                if (asuit != suit)
                {
                    continue;
                }

                int[] cardsCount = myCP.GetSuitAllCards(asuit);

                

                int n = 8;

                if (myCP.Rank == 8)
                {
                    n = 11; //打10时,先出K
                }

                if (cardsCount[n] > 0)
                {
                    if (sendedCards.Count < count)
                    {
                        if (protectPairs) //保护对
                        {
                            if (cardsCount[n] == 1)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (suit - 1) * 13);
                            }
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13);
                            if (sendedCards.Count < count)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13);
                            }
                        }
                    }
                    if (sendedCards.Count >= count)
                    {
                        return;
                    }
                }
                else
                {
                    continue;
                }

                n = 11;

                if (myCP.Rank == 8)
                {
                    n = 8; //打10时,后出10
                }

                if (cardsCount[n] > 0)
                {
                    if (sendedCards.Count < count)
                    {
                        if (protectPairs) //保护对
                        {
                            if (cardsCount[n] == 1)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (suit - 1) * 13);
                            }
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13);
                            if (sendedCards.Count < count)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13);
                            }
                        }
                    }
                    if (sendedCards.Count >= count)
                    {
                        return;
                    }
                }
                else
                {
                    continue;
                }

                n = 3;

                if (cardsCount[n] > 0)
                {
                    if (sendedCards.Count < count)
                    {
                        if (protectPairs) //保护对
                        {
                            if (cardsCount[n] == 1)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (suit - 1) * 13);
                            }
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13);
                            if (sendedCards.Count < count)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13);
                            }
                        }
                    }
                    if (sendedCards.Count >= count)
                    {
                        return;
                    }
                }
                else
                {
                    continue;
                }
            }
            

            //非分
            for (int asuit = 1; asuit < 5; asuit++)
            {
                if (asuit != suit)
                {
                    continue;
                }

                int[] cardsCount = myCP.GetSuitAllCards(asuit);


                for (int m = 0; m < 13; m++)
                {
                    

                    if (cardsCount[m] > 0)
                    {
                        if (sendedCards.Count < count)
                        {
                            if (protectPairs) //保护对
                            {
                                if (cardsCount[m] == 1)
                                {
                                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (suit - 1) * 13);
                                }
                            }
                            else
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13);
                                if (sendedCards.Count < count)
                                {
                                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13);
                                }
                            }
                        }
                        if (sendedCards.Count >= count)
                        {
                            return;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            //Rank
            if (protectPairs) //保护对
            {
                if (sendedCards.Count < count)
                {
                    if (myCP.HeartsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.PeachsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 13);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.DiamondsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 26);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.ClubsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 39);
                    }
                }
            }
            else
            {
                if (sendedCards.Count < count)
                {
                    if (myCP.HeartsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.HeartsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.PeachsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 13);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.PeachsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 13);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.DiamondsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 26);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.DiamondsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 26);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.ClubsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 39);
                    }
                }
                if (sendedCards.Count < count)
                {
                    if (myCP.ClubsRankTotal > 0)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 39);
                    }
                }
            }
           
            //
            if (myCP.SmallJack > 0)
            {
                if (sendedCards.Count < count)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, 52);

                }
            }
            if (myCP.SmallJack > 0)
            {
                if (sendedCards.Count < count)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, 52);

                }
            }
            if (myCP.BigJack > 0)
            {
                if (sendedCards.Count < count)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, 53);

                }
            }
            if (myCP.BigJack > 0)
            {
                if (sendedCards.Count < count)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, 53);

                }
            }
        }
예제 #2
0
        private static void SendThisSuit(ArrayList sendedCards, int count, int suit, int firstSuit, CurrentPoker myCP, ArrayList myPokerList, bool protectPairs)
        {
            if (suit == firstSuit)
            {
                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList,protectPairs);
                return;
            }

            int[] cards = myCP.GetSuitAllCards(firstSuit);

            for (int m = 0; m < 13; m++)
            {
               
                if (cards[m] > 0)
                {
                    if (sendedCards.Count < count)
                    {
                        if (protectPairs) //保护对
                        {
                            if (cards[m] == 1)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (firstSuit - 1) * 13);
                            }
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (firstSuit - 1) * 13);
                            if (sendedCards.Count < count)
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (firstSuit - 1) * 13);
                            }
                        }

                    }
                    if (sendedCards.Count >= count)
                    {
                        return;
                    }
                }
            }

        }
예제 #3
0
파일: Algorithm.cs 프로젝트: nxsky/Tractor
        internal static void Send8Cards2(MainForm form, ArrayList list, ArrayList sendCards, CurrentPoker cp, int[] suits, int rank, int suit)
        {
            int previous = 0, next = 0;

            int[] suitCards = cp.GetSuitAllCards(suits[0]);

            GetShouldSend8CardsNoScores(list, sendCards, suits[0], rank, suit, previous, next, suitCards);

            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[1]);
                GetShouldSend8CardsNoScores(list, sendCards, suits[1], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[2]);
                GetShouldSend8CardsNoScores(list, sendCards, suits[2], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[3]);
                GetShouldSend8CardsNoScores(list, sendCards, suits[3], rank, suit, previous, next, suitCards);
            }

            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[0]);
                GetShouldSend8Cards(list, sendCards, suits[0], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[1]);
                GetShouldSend8Cards(list, sendCards, suits[1], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[2]);
                GetShouldSend8Cards(list, sendCards, suits[2], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[3]);
                GetShouldSend8Cards(list, sendCards, suits[3], rank, suit, previous, next, suitCards);
            }

            //牌还不够
            if (sendCards.Count < 8)
            {
               Send8Cards3(form, list, sendCards, cp, suits, rank, suit);
            }
        }
예제 #4
0
        private static void SendOtherSuit(ArrayList sendedCards, int count, int firstSuit, CurrentPoker myCP, ArrayList myPokerList, bool protectPairs)
        {
            for (int asuit = 1; asuit < 5; asuit++)
            {
                if (asuit == firstSuit)
                {
                    continue;
                }
                if (asuit == myCP.Suit)
                {
                    continue;
                }


                int[] cards = myCP.GetSuitAllCards(asuit);

                for (int m = 0; m < 13; m++)
                {
                    if (cards[m] > 0)
                    {
                        if (sendedCards.Count < count)
                        {
                            if (protectPairs) //保护对
                            {
                                if (cards[m] == 1)
                                {
                                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13);
                                }
                            }
                            else
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13);
                                if (sendedCards.Count < count)
                                {
                                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13);
                                }
                            }
                        }
                        if (sendedCards.Count >= count)
                        {
                            return;
                        }
                    }
                }

            }


        }
예제 #5
0
파일: Algorithm.cs 프로젝트: nxsky/Tractor
        internal static void Send8Cards3(MainForm form, ArrayList list, ArrayList sendCards, CurrentPoker cp, int[] suits, int rank, int suit)
        {
            int previous = 0, next = 0;

            int[][] suitCards = new int[4][];

            suitCards[0] = cp.GetSuitAllCards(suits[0]);
            suitCards[1] = cp.GetSuitAllCards(suits[1]);
            suitCards[2] = cp.GetSuitAllCards(suits[2]);
            suitCards[3] = cp.GetSuitAllCards(suits[3]);

            for (int i = 0; i < 13; i++)
            {
                //
                if (i == 0)
                {
                    previous = 0;
                }
                else if (rank == (i - 1))
                {
                    if (i == 1)
                    {
                        previous = 0;
                    }
                    else
                    {
                        previous = suitCards[0][i - 2];
                    }
                }
                else
                {
                    previous = suitCards[0][i - 1];
                }
                //
                if (i == 12)
                {
                    next = 0;
                }
                else if (rank == (i + 1))
                {
                    if (i == 11)
                    {
                        next = 0;
                    }
                    else
                    {
                        next = suitCards[0][i + 2];
                    }
                }
                else
                {
                    next = suitCards[0][i + 1];

                }


                if (IsCanSend(i, suitCards[0][i], previous, next, suit))
                {
                   
                    
                    list.Remove((suits[0] - 1) * 13 + i);
                    sendCards.Add((suits[0] - 1) * 13 + i);
                    cp.RemoveCard((suits[0] - 1) * 13 + i);
                }

                if (sendCards.Count >= 8)
                {
                    return;
                }
                //2
                if (i == 0)
                {
                    previous = 0;
                }
                else if (rank == (i - 1))
                {
                    if (i == 1)
                    {
                        previous = 0;
                    }
                    else
                    {
                        previous = suitCards[2][i - 2];
                    }
                }
                else
                {
                    previous = suitCards[2][i - 1];
                }
                //
                if (i == 12)
                {
                    next = 0;
                }
                else if (rank == (i + 1))
                {
                    if (i == 11)
                    {
                        next = 0;
                    }
                    else
                    {
                        next = suitCards[2][i + 2];
                    }
                }
                else
                {
                    next = suitCards[2][i + 1];

                }

                if (IsCanSend(i, suitCards[1][i], previous, next, suit))
                {
                    
                    list.Remove((suits[1] - 1) * 13 + i);
                    sendCards.Add((suits[1] - 1) * 13 + i);
                    cp.RemoveCard((suits[1] - 1) * 13 + i);
                }

                if (sendCards.Count >= 8)
                {
                    return;
                }
                //3.
                if (i == 0)
                {
                    previous = 0;
                }
                else if (rank == (i - 1))
                {
                    if (i == 1)
                    {
                        previous = 0;
                    }
                    else
                    {
                        previous = suitCards[2][i - 2];
                    }
                }
                else
                {
                    previous = suitCards[2][i - 1];
                }
                //
                if (i == 12)
                {
                    next = 0;
                }
                else if (rank == (i + 1))
                {
                    if (i == 11)
                    {
                        next = 0;
                    }
                    else
                    {
                        next = suitCards[2][i + 2];
                    }
                }
                else
                {
                    next = suitCards[2][i + 1];

                }

                if (IsCanSend(i, suitCards[2][i], previous, next, suit))
                {
                   
                    list.Remove((suits[2] - 1) * 13 + i);
                    sendCards.Add((suits[2] - 1) * 13 + i);
                    cp.RemoveCard((suits[2] - 1) * 13 + i);
                }

                if (sendCards.Count >= 8)
                {
                    return;
                }

                //4.
                if (sendCards.Count >= 8)
                {
                    return;
                }
                if (suit == 5)
                {
                    if (i == 0)
                    {
                        previous = 0;
                    }
                    else if (rank == (i - 1))
                    {
                        if (i == 1)
                        {
                            previous = 0;
                        }
                        else
                        {
                            previous = suitCards[3][i - 2];
                        }
                    }
                    else
                    {
                        previous = suitCards[3][i - 1];
                    }
                    //
                    if (i == 12)
                    {
                        next = 0;
                    }
                    else if (rank == (i + 1))
                    {
                        if (i == 11)
                        {
                            next = 0;
                        }
                        else
                        {
                            next = suitCards[3][i + 2];
                        }
                    }
                    else
                    {
                        next = suitCards[3][i + 1];

                    }

                    if (IsCanSend(i, suitCards[3][i], previous, next, suit))
                    {
                        list.Remove((suits[3] - 1) * 13 + i);
                        sendCards.Add((suits[3] - 1) * 13 + i);
                        cp.RemoveCard((suits[3] - 1) * 13 + i);
                    }

                    if (sendCards.Count >= 8)
                    {
                        return;
                    }
                }
                
            }
           
            //last
            if (suit < 5)
            {
                for (int i = 0; i < 13; i++)
                {
                    if (sendCards.Count >= 8)
                    {
                        return;
                    }

                    //
                    if (i == 0)
                    {
                        previous = 0;
                    }
                    else if (rank == (i - 1))
                    {
                        if (i == 1)
                        {
                            previous = 0;
                        }
                        else
                        {
                            previous = suitCards[3][i - 2];
                        }
                    }
                    else
                    {
                        previous = suitCards[3][i - 1];
                    }
                    //
                    if (i == 12)
                    {
                        next = 0;
                    }
                    else if (rank == (i + 1))
                    {
                        if (i == 11)
                        {
                            next = 0;
                        }
                        else
                        {
                            next = suitCards[3][i + 2];
                        }
                    }
                    else
                    {
                        next = suitCards[3][i + 1];

                    }


                    if (IsCanSend(i, suitCards[3][i], previous, next, suit))
                    {
                       
                        list.Remove((suits[3] - 1) * 13 + i);
                        sendCards.Add((suits[3] - 1) * 13 + i);
                        cp.RemoveCard((suits[3] - 1) * 13 + i);
                    }

                    if (sendCards.Count >= 8)
                    {

                        return;
                    }
                }
            }

            if (sendCards.Count >= 8)
            {
                return;
            }
            else
            {
                Send8Cards3(form, list, sendCards,cp, suits, rank, suit);
            }
        }