Ejemplo n.º 1
0
        public static bool NeedsInsurance(Dealer dealer, Hand playerHand, HiLoCounter counter)
        {
            if (counter.TrueCount > 3 && dealer.FaceUpCard.Value == CardValue.Ace)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static PlayerAction CalculateStrategy(Dealer dealer, Hand playerHand, HiLoCounter counter, bool hasSplitHand)
        {
            int       trueCount   = counter.TrueCount;
            CardValue dealerValue = dealer.FaceUpCard.Value;

            if ((playerHand.Value == 16 && dealerValue == CardValue.Ten && dealerValue != CardValue.Ace && trueCount >= 0) ||
                (playerHand.Value == 15 && dealerValue >= CardValue.Ten && dealerValue != CardValue.Ace && counter.TrueCount >= 4) ||
                (playerHand.Value == 16 && dealerValue == CardValue.Nine && trueCount >= 5) ||
                (playerHand.Value == 10 && dealerValue == CardValue.Three && trueCount >= 2) ||
                (playerHand.Value == 10 && dealerValue == CardValue.Two && trueCount >= 4))
            {
                return(PlayerAction.Stand);
            }
            else if ((playerHand.HasPair && playerHand.Value == 10 && dealerValue == CardValue.Five && trueCount >= 5) ||
                     (playerHand.HasPair && playerHand.Value == 10 && dealerValue == CardValue.Six && trueCount >= 4))
            {
                if (hasSplitHand)
                {
                    return(PlayerAction.NoAction);
                }

                return(PlayerAction.Split);
            }
            else if ((playerHand.Value == 11 && dealerValue == CardValue.Ace && trueCount >= 1) ||
                     (playerHand.Value == 9 && dealerValue == CardValue.Two && trueCount >= 1) ||
                     (playerHand.Value == 10 && dealerValue == CardValue.Ace && trueCount >= 4) ||
                     (playerHand.Value == 9 && dealerValue == CardValue.Seven && trueCount >= 4) ||
                     (playerHand.HasPair && playerHand.FirstCard.Value >= CardValue.Ten && dealerValue >= CardValue.Ten && dealerValue != CardValue.Ace && trueCount >= 4))
            {
                return(PlayerAction.Double);
            }
            else if ((playerHand.Value == 12 && dealerValue == CardValue.Four && trueCount <= 0) ||
                     (playerHand.Value == 12 && dealerValue == CardValue.Five && trueCount <= -1) ||
                     (playerHand.Value == 12 && dealerValue == CardValue.Six && trueCount <= -1) ||
                     (playerHand.Value == 14 && dealerValue == CardValue.Three && trueCount <= 0) ||
                     (playerHand.Value == 13 && dealerValue == CardValue.Three && trueCount <= 2))
            {
                return(PlayerAction.Hit);
            }
            else
            {
                return(PlayerAction.NoAction);
            }
        }
Ejemplo n.º 3
0
        private void InitializeSimulationWithUserInput()
        {
            string input = string.Empty;
            int    bettingStrategy;
            int    startingFunds;
            int    minimumBet;

            Console.WriteLine("\nPlease enter the number of players.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out numberOfPlayers))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the number of players.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the number of total iterations to simulate (one iteration is a full played hand per player)");
            input = Console.ReadLine();

            while (!int.TryParse(input, out numberOfIterations))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the number of iterations.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the number of decks in the shoe.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out numberOfDecksInShoe))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the number of decks in the shoe.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the starting funds of the players.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out startingFunds))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the starting funds of the players.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease enter the minimum bet of the players.");
            input = Console.ReadLine();

            while (!int.TryParse(input, out minimumBet))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer for the minimum bet of the players.");
                input = Console.ReadLine();
            }

            Console.WriteLine("\nPlease choose a betting strategy: \n\t1 - Manhattan\n\t2 - Martingale");
            input = Console.ReadLine();

            while (!int.TryParse(input, out bettingStrategy))
            {
                Console.WriteLine("\nInput: \"" + input + "\" is not a valid integer. Please enter a valid integer (1 or 2) for a betting strategy.");
                input = Console.ReadLine();
            }

            shoe    = new Shoe(numberOfDecksInShoe);
            counter = new HiLoCounter(numberOfDecksInShoe);

            for (int i = 0; i < numberOfPlayers; i++)
            {
                if (bettingStrategy == 1)
                {
                    playerList.Add(new Player(typeof(Manhattan), startingFunds, minimumBet));
                }
                else
                {
                    playerList.Add(new Player(typeof(Martingale), startingFunds, minimumBet));
                }
            }
        }