Пример #1
0
        public List <Tuple <int, int> > GetHandValue(bool output = false)
        {
            List <Card> allCards = new List <Card>(pHand.GetCards());

            allCards.AddRange(communityCards.GetCards());

            PokerHand totalHand = new PokerHand();

            totalHand.SetCards(allCards);

            return(totalHand.GetValue(output));
        }
Пример #2
0
        // AI for valuing hand and placing bets
        public override int TakeBet(int matchBet)
        {
            List <Card> allCards = new List <Card>(pHand.GetCards());

            allCards.AddRange(communityCards.GetCards());

            PokerHand totalHand = new PokerHand();

            totalHand.SetCards(allCards);

            List <Tuple <int, int> > value = totalHand.GetValue();

            // Most of this is done randomly just to generate an amount to bet

            int roughValue = 0;

            foreach (Tuple <int, int> tup in value)
            {
                roughValue += (tup.Item1 * 4) * (tup.Item2 / 4);
            }

            Random rnd    = new Random();
            int    rndInt = rnd.Next(10) - 5; // Random int from 5 to -5

            // rndInt = 0;

            int val = roughValue + rndInt;

            if (val > 100)
            {
                val = 100;
            }                             // val is a number from 1 to 100 representing the hands value

            double percent = val / 100d;
            int    bet     = Convert.ToInt32(chips * percent);

            // RAISE, CHECK/CALL, FOLD
            rnd    = new Random();
            rndInt = rnd.Next(100);

            if (rndInt < val && bet > matchBet)
            {
                // Raise
                Console.WriteLine($"{name} is Raising to {bet}...");
                return(Bet(bet - chipsIn));
            }
            else if (rndInt > val * matchBet)
            {
                // Fold
                Console.WriteLine($"{name} is Folding...");
                return(-1);
            }
            else
            {
                // Call/Check
                if (chipsIn == matchBet)
                {
                    Console.WriteLine($"{name} is Checking...");
                    return(0);
                }
                else
                {
                    Console.WriteLine($"{name} is Calling...");
                    return(Bet(matchBet - chipsIn));
                }
            }

            Console.WriteLine("ERROR : TakeBet DIDN'T RETURN A VALUE, FOLDING");
            return(-1);
        }