Пример #1
0
        /// <summary>
        /// Called by the client when a bet decision should be made.
        /// </summary>
        /// <param name="player">The automated player.
        /// </param>
        /// <param name="action">The betting action which must be modified to pass the client response</param>
        /// <remarks>
        /// The limit strategy looks at the hand value first. If it is low,
        /// the player will fold when the money needed to bet is below the limit. When the hand value is high, the player will call for
        /// the first couple of times and will raise for the rest
        /// </remarks>
        public override void Bet(Player player, PlayerBettingAction action)
        {
            // check to see the player hand
            Hand hand = client.GetBestHand(player.Cards);

            // the hand good, call at first and raise near the end.
            if (hand.Family.FamilyValue > 3)
            {
                if (synchTimes < 5)
                {
                    action.Call();
                }
                else
                {
                    action.Raise(action.RaiseAmount);
                }
            }
            else // the hand is bad, watch for the limit
            {
                if (action.CallAmount > 0 && player.Money - action.CallAmount < preparedLimit)
                {
                    action.Fold();
                }
                else
                {
                    action.Call();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Called by a client which needs to manually draw cards. Draws the cards which are not part of the best hand.
        /// </summary>
        /// <param name="player">The automated player</param>
        /// <param name="action">The drawing action which must be modified to pass the strategy decision</param>
        public override void Draw(Player player, PlayerDrawingAction action)
        {
            // get the player best hand
            lastHand = client.GetBestHand(player.Cards);
            // the other cards holder
            List <Card> otherCards = new List <Card>();
            // get all of the hand cards
            IEnumerator <Card> allCards = lastHand.GetAllCards();

            while (allCards.MoveNext())
            {
                if (!lastHand.Contains(allCards.Current))
                {
                    otherCards.Add(allCards.Current);
                }
            }
            // sort the other cards by value, the order is ascending
            otherCards.Sort();
            // can draw at most 3 cards:
            int max = Math.Min(3, otherCards.Count);

            // draw the first (max) cards out of the other cards:
            action.DrawnCards.AddRange(otherCards.Take(max));
        }
Пример #3
0
 /// <summary>
 /// The default implementation of the print player method.
 /// </summary>
 /// <param name="player"></param>
 protected virtual void PrintPlayer(Player player)
 {
     Console.Write(player);
     if (player.Cards.Count > 0)
     {
         // print all non-empty cards:
         foreach (Card card in player.Cards)
         {
             if (card != Card.Empty)
             {
                 Console.Write(", ");
                 Console.Write(card);
             }
         }
         Hand hand = client.GetBestHand(player.Cards);
         // print the hand which was found, if any:
         if (hand != null)
         {
             Console.WriteLine();
             PrintHand(hand);
         }
     }
     Console.WriteLine();
 }