Esempio n. 1
0
        /// <summary>
        /// Splits this hand into two separate hands with one card each.
        /// This hand becomes the first hand and the second hand is returned.
        /// </summary>
        /// <returns></returns>
        public PlayerHand Split()
        {
            // Create the new hand.
            PlayerHand p1 = new PlayerHand()
            {
                Bet          = this.Bet,
                Player       = this.Player,
                HasBeenSplit = true
            };

            // Add the top card to the new hand.
            p1.AddCard(cards[1]);

            // Save the current bottom card for this hand.
            Card temp = cards[0];

            // Clear the cards from this hand.
            cards.Clear();

            // Reset this hand.
            Value = 0;
            Soft  = false;

            // Add the bottom card to this hand.
            AddCard(temp);

            // Flag that this hand has been split.
            HasBeenSplit = true;

            // Return the new hand.
            return(p1);
        }
Esempio n. 2
0
        public PlayerHand Split()
        {
            PlayerHand p1 = new PlayerHand()
            {
                Bet = this.Bet,
                Player = this.Player,
                HasBeenSplit = true
            };
            Card temp = cards[0];
            p1.AddCard(cards[1]);

            cards.Clear();
            Value = 0;
            Soft = false;
            AddCard(temp);
            HasBeenSplit = true;

            return p1;
        }
Esempio n. 3
0
        public PlayerHand Split()
        {
            PlayerHand p1 = new PlayerHand()
            {
                Bet          = this.Bet,
                Player       = this.Player,
                HasBeenSplit = true
            };
            Card temp = cards[0];

            p1.AddCard(cards[1]);


            cards.Clear();
            Value = 0;
            Soft  = false;
            AddCard(temp);
            HasBeenSplit = true;

            return(p1);
        }
Esempio n. 4
0
        public static ActionTable FromStrategy(IBlackjackPlayer strategy)
        {
            var table = new ActionTypes[35, 10];
            List<PlayerHand> hands = new List<PlayerHand>();
            hands.Add(null);
            for (int dealer = 0; dealer < 10; dealer++)
            {
                DealerHand dealerHand = new DealerHand();
                dealerHand.AddCard(new Card((Ranks)dealer));

                for (int p = 0; p < 35; p++)
                {
                    PlayerHand playerHand = new PlayerHand()
                    {
                        Player = strategy,
                        Bet = 1
                    };

                    if (p < 10)
                    {
                        playerHand.AddCard(new Card((Ranks)p));
                        playerHand.AddCard(new Card((Ranks)p));
                    }
                    else if (p < 19)
                    {
                        playerHand.AddCard(new Card(Ranks.Ace));
                        playerHand.AddCard(new Card((Ranks)(p - 10)));
                    }
                    else if (p < 26)
                    {
                        playerHand.AddCard(new Card(Ranks.Two));
                        playerHand.AddCard(new Card((Ranks)(p - 18)));
                    }
                    else
                    {
                        playerHand.AddCard(new Card(Ranks.Ten));
                        playerHand.AddCard(new Card((Ranks)(p - 26)));
                    }
                    hands[0] = playerHand;

                    HandInfo info = new HandInfo()
                    {
                        DealerHand = dealerHand,
                        HandToPlay = 0,
                        PlayerHands = hands
                    };

                    var hs = strategy.Hit(info) ? ActionTypes.Hit : ActionTypes.Stand;
                    var type = hs;
                    if (p < 10 && strategy.Split(info))
                        type = hs == ActionTypes.Hit ? ActionTypes.SplitOrHit : ActionTypes.SplitOrStand;
                    else if (strategy.DoubleDown(info))
                        type = hs == ActionTypes.Hit ? ActionTypes.DoubleDownOrHit : ActionTypes.DoubleDownOrStand;

                    table[p, dealer] = type;
                }

            }

            return new ActionTable(table);
        }
Esempio n. 5
0
        public static ActionTable FromStrategy(IBlackjackPlayer strategy)
        {
            var table = new ActionTypes[35, 10];
            List <PlayerHand> hands = new List <PlayerHand>();

            hands.Add(null);
            for (int dealer = 0; dealer < 10; dealer++)
            {
                DealerHand dealerHand = new DealerHand();
                dealerHand.AddCard(new Card((Ranks)dealer));

                for (int p = 0; p < 35; p++)
                {
                    PlayerHand playerHand = new PlayerHand()
                    {
                        Player = strategy,
                        Bet    = 1
                    };

                    if (p < 10)
                    {
                        playerHand.AddCard(new Card((Ranks)p));
                        playerHand.AddCard(new Card((Ranks)p));
                    }
                    else if (p < 19)
                    {
                        playerHand.AddCard(new Card(Ranks.Ace));
                        playerHand.AddCard(new Card((Ranks)(p - 10)));
                    }
                    else if (p < 26)
                    {
                        playerHand.AddCard(new Card(Ranks.Two));
                        playerHand.AddCard(new Card((Ranks)(p - 18)));
                    }
                    else
                    {
                        playerHand.AddCard(new Card(Ranks.Ten));
                        playerHand.AddCard(new Card((Ranks)(p - 26)));
                    }
                    hands[0] = playerHand;

                    HandInfo info = new HandInfo()
                    {
                        DealerHand  = dealerHand,
                        HandToPlay  = 0,
                        PlayerHands = hands
                    };

                    var hs   = strategy.Hit(info) ? ActionTypes.Hit : ActionTypes.Stand;
                    var type = hs;
                    if (p < 10 && strategy.Split(info))
                    {
                        type = hs == ActionTypes.Hit ? ActionTypes.SplitOrHit : ActionTypes.SplitOrStand;
                    }
                    else if (strategy.DoubleDown(info))
                    {
                        type = hs == ActionTypes.Hit ? ActionTypes.DoubleDownOrHit : ActionTypes.DoubleDownOrStand;
                    }

                    table[p, dealer] = type;
                }
            }

            return(new ActionTable(table));
        }
Esempio n. 6
0
        /// <summary>
        /// Splits this hand into two separate hands with one card each.
        /// This hand becomes the first hand and the second hand is returned.
        /// </summary>
        /// <returns></returns>
        public PlayerHand Split()
        {
            // Create the new hand.
            PlayerHand p1 = new PlayerHand()
            {
                Bet = this.Bet,
                Player = this.Player,
                HasBeenSplit = true
            };

            // Add the top card to the new hand.
            p1.AddCard(cards[1]);

            // Save the current bottom card for this hand.
            Card temp = cards[0];

            // Clear the cards from this hand.
            cards.Clear();

            // Reset this hand.
            Value = 0;
            Soft = false;

            // Add the bottom card to this hand.
            AddCard(temp);

            // Flag that this hand has been split.
            HasBeenSplit = true;

            // Return the new hand.
            return p1;
        }