Inheritance: IComparable
示例#1
0
        public void Action(Card dealer_upcard, CardSet[] player_hands, int active_hand_index, List<ActionEv> actions)
        {
            ActionInfo info = new ActionInfo() {
                hand_index = active_hand_index,
                player_cards = player_hands[active_hand_index],
                action_evs = actions.ToArray()
            };

            action_history.Add(info);
        }
        // seen_cards include active_hand's cards
        public override ActionType GetAction(CardSet seen_cards, Card dealer_upcard, CardSet[] player_hands, int active_hand, List<ActionType> available_actions)
        {
            List<ActionEv> actions = GetActions(seen_cards, dealer_upcard, player_hands, active_hand, available_actions);

            ActionType best = actions[0].Action;

            if (best == ActionType.Split)
            {
                split_count++;
            }
            else if (best == ActionType.Double)
            {
                hand_doubled[active_hand] = true;
            }
            else if (best == ActionType.Surrender)
            {
                surrendered = true;
            }

            action_count++;

            return best;
        }
示例#3
0
        // splits the active hand to two new hands
        public void Split(Card card1, Card card2)
        {
            Hand[] split_hands = ActiveHand.Split(card1, card2);

            hands.Add(split_hands[0]);
            hands.Add(split_hands[1]);
        }
示例#4
0
 private void RemoveCount(Card card)
 {
     card_counts[card.PointValue - 1]--;
 }
示例#5
0
 public void Add(Card card)
 {
     card_set.Add(card);
     AddCount(card);
 }
示例#6
0
 public CardSet(Card[] cards)
     : this(cards.Length)
 {
     this.Add(cards);
     UpdateCount();
 }
示例#7
0
 private void AddCount(Card card)
 {
     card_counts[card.PointValue - 1]++;
 }
示例#8
0
 public void AddCard(Card card)
 {
     cards.Add(card);
 }
示例#9
0
 public void Remove(Card card)
 {
     if (card_set.Remove(card))
         RemoveCount(card);
 }
示例#10
0
        private List<ActionEv> Evaluate(Card upcard, Hand hand)
        {
            shell.StandardInput.WriteLine(upcard.PointValue);
            shell.StandardInput.WriteLine(hand.Count);

            foreach (Card card in hand)
                shell.StandardInput.WriteLine(card.PointValue);

            string line = "";
            List<ActionEv> actions = new List<ActionEv>();
            while (true)
            {
                line = shell.StandardOutput.ReadLine();

                if (line.StartsWith("done"))
                    break;

                ActionEv action_ev = new ActionEv();

                string[] param = line.Split(new char[] { ' ' });

                action_ev.Ev = double.Parse(param[1]);
                if (param[0] == "Surrender")
                    action_ev.Action = ActionType.Surrender;
                else if (param[0] == "Hit")
                    action_ev.Action = ActionType.Hit;
                else if (param[0] == "Stand")
                    action_ev.Action = ActionType.Stand;
                else if (param[0] == "Double")
                    action_ev.Action = ActionType.Double;
                else if (param[0] == "Split")
                    action_ev.Action = ActionType.Split;
                else
                    Console.WriteLine("BIG F*****G UPS!!!!!");

                actions.Add(action_ev);
            }

            actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return ae2.Ev.CompareTo(ae1.Ev); });

            /*Console.WriteLine("Upcard: " + upcard + " Hand: " + hand);
            foreach (ActionEv ae in actions)
                Console.WriteLine(ae.Action + " " + ae.Ev);
            Console.ReadKey();*/

            return actions;
        }
示例#11
0
 public override void DealCard(Card card)
 {
     primary.DealCard(card);
     secondary.DealCard(card);
 }
示例#12
0
        public List<ActionEv> GetActions(CardSet seen_cards, Card dealer_upcard, CardSet[] player_hands, int active_hand, List<ActionType> available_actions)
        {
            ValidateActions(player_hands[active_hand], available_actions);

            Shoe tmp_shoe = shoe.Copy();
            tmp_shoe.Remove(seen_cards);

            Eval.CacheDealerProbs(dealer_upcard.PointValue, tmp_shoe.ToArray());

            List<ActionEv> actions = new List<ActionEv>();

            foreach (ActionType a in available_actions)
            {
                double ev = GetActionEV(tmp_shoe, player_hands[active_hand], a, dealer_upcard);

                actions.Add(new ActionEv() { Action = a, Ev = ev });
            }

            actions.Sort(delegate(ActionEv ae1, ActionEv ae2) { return ae2.Ev.CompareTo(ae1.Ev); });

            game_logger.Action(dealer_upcard, player_hands, active_hand, actions);

            return actions;
        }
示例#13
0
        private double GetActionEV(Shoe tmp_shoe, CardSet active_hand, ActionType action, Card dealer_upcard)
        {
            Hand hand = new Hand(active_hand);

            SHand shand;
            int soft_total = hand.SoftTotal();
            if (soft_total <= 21 && hand.HasAce())
            {
                shand.Total = soft_total;
                shand.Soft = true;
            }
            else
            {
                shand.Total = hand.HardTotal();
                shand.Soft = false;
            }

            int[] shoe_counts = tmp_shoe.ToArray();
            int upcard = dealer_upcard.PointValue;

            switch (action)
            {
                case ActionType.Stand:

                    return Eval.StandEv(shand, upcard, shoe_counts);

                case ActionType.Hit:

                    return Eval.HitEv(shand, upcard, shoe_counts);

                case ActionType.Double:

                    return Eval.DoubleEv(shand, upcard, current_bet, shoe_counts);

                case ActionType.Split:

                    return Eval.SplitEv(active_hand[0].PointValue, upcard, current_bet, max_splits - split_count, shoe_counts);

                case ActionType.Surrender:

                    return Eval.SurrenderEv();
            }

            return -1;
        }
示例#14
0
 // seen_cards include active_hand's cards
 public abstract ActionType GetAction(CardSet seen_cards, Card dealer_upcard, CardSet[] player_hands, int active_hand, List<ActionType> available_actions);
示例#15
0
 public void Remove(Card card)
 {
     total--;
     counts[card.PointValue - 1]--;
 }
示例#16
0
        // splits this hand to two new hands
        public Hand[] Split(Card card1, Card card2)
        {
            Hand[] hands = new Hand[] { new Hand(), new Hand() };

            hands[0].AddCard(cards[0]);
            hands[1].AddCard(cards[1]);

            hands[0].AddCard(card1);
            hands[1].AddCard(card2);

            //hands[0].Bet = this.bet;
            //hands[1].Bet = this.bet;

            if (cards[0].IsAce() && cards[1].IsAce())
            {
                hands[0].from_aces = true;
                hands[1].from_aces = true;
            }

            this.split = true;

            return hands;
        }
示例#17
0
 public void Hit(Card card)
 {
     cards.Add(card);
     hit_count++;
 }
示例#18
0
 public void Double(Card card)
 {
     cards.Add(card);
     doubled = true;
 }
示例#19
0
 public override void DealCard(Card card)
 {
     card_counter.RemoveCard(card.PointValue);
 }
示例#20
0
 public void Add(Card[] cards)
 {
     card_set.AddRange(cards);
     foreach (Card card in cards)
         AddCount(card);
 }
示例#21
0
        public void Add(string cards)
        {
            string[] split = cards.Split(new char[] { ' ' });

            for (int i = 0; i < split.Length; i++)
            {
                Card c = new Card(split[i]);
                Add(c);
            }
        }
示例#22
0
 public virtual void DealCard(Card card)
 {
 }