public static HandCategory Evaluate(BotState state, HandHoldem hand) { //Merge your cards with the cards on the board IEnumerable <Card> CardsToEvaluateToEvaluate = hand.Cards.Concat(state.Table); return(CheckRoyalFlush(CardsToEvaluateToEvaluate, hand)); }
/// <summary> /// Askins the bot to perform a move, depending on the current state of the game /// </summary> /// <param name="state">Current state of the game</param> /// <param name="timeOut">Represents the time we have to perform a move</param> /// <returns>Returns a PokerMove</returns> public PokerMove GetMove(BotState state, long timeOut) { HandHoldem hand = state.Hand; // We are playing preflop if (state.Table.Count == 0) { string action = PreFlopStrategy.StartingHandEvalute(state, hand); switch (action) { case "call": return(new PokerMove(state.MyName, action, state.AmountToCall)); case "raise": return(new PokerMove(state.MyName, action, 3 * state.BigBlind)); case "fold": return(new PokerMove(state.MyName, action, 0)); default: return(new PokerMove(state.MyName, "check", 0)); } } return(EvaluateBoard(state, hand)); }
private static HandCategory CheckFlush(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .GroupBy(x => x.getSuit()) .Count() == 1) { return(HandCategory.Flush); } else { return(CheckStraight(CardsToEvaluate, hand)); } }
private static HandCategory CheckPair(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .GroupBy(x => x.getHeight()) .Count(group => group.Count() == 2) == 1) { return(HandCategory.Pair); } else { return(HandCategory.NoPair); } }
private static HandCategory CheckTwoPair(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .GroupBy(x => x.getSuit()) .Count(group => group.Count() >= 2) > 1) { return(HandCategory.TwoPair); } else { return(CheckPair(CardsToEvaluate, hand)); } }
/// <summary> /// Evaluate the board and return a Poker move /// </summary> public PokerMove EvaluateBoard(BotState state, HandHoldem hand) { var handCategory = GetHandCategory(state, hand); //Pair if (handCategory == HandCategory.Pair) { if (state.OpponentAction.getAction().Equals("raise")) { return(new PokerMove(state.MyName, "call", state.AmountToCall)); } else { return(new PokerMove(state.MyName, "raise", 2 * state.Pot)); } } //Two Pair else if (handCategory == HandCategory.TwoPair) { return(new PokerMove(state.MyName, "raise", 2 * state.Pot)); } //Three of a kind else if (handCategory == HandCategory.TwoPair) { return(new PokerMove(state.MyName, "raise", 2 * state.Pot)); } //We have a highcard else { if (PreFlopStrategy.StartingHandEvalute(state, hand) == "raise" && state.AmountToCall < 5 * state.Pot) { return(new PokerMove(state.MyName, "call", state.AmountToCall)); } else if (!state.OpponentAction.getAction().Equals("raise")) { return(new PokerMove(state.MyName, "check", 0)); } else if (state.OpponentAction.getAction().Equals("raise") && state.AmountToCall > state.Pot) { return(new PokerMove(state.MyName, "fold", 0)); } } return(new PokerMove(state.MyName, "check", 0)); }
//Im using a preflop poker chart for evaluation //https://tinyurl.com/je4sdav public static string StartingHandEvalute(BotState state, HandHoldem hand) { Card card = hand.GetCard(0); //Store the 2nd card in our hand Card othercard = hand.GetCard(1); // We have a pocket pair if (card.getHeight() == othercard.getHeight()) { //If we have 99 or higher we raise if ((int)card.getHeight() > 7) { return("raise"); } //If we have 88 or smaller , we flat call else { return("call"); } } //If we have an Ace we always raise else if (card.getHeight() == CardHeight.ACE) { //If the opponent raised , we flat call , otherwise we raise if (state.OpponentAction != null && state.OpponentAction.getAction().Equals("raise")) { return("call"); } else { return("raise"); } } else if (card.getHeight() == CardHeight.KING) { //IF we have K6 suited or better if (card.getSuit() == othercard.getSuit() && (int)othercard.getHeight() > 6) { //If the opponent raised , we flat call , otherwise we raise if (state.OpponentAction != null && state.OpponentAction.getAction().Equals("raise")) { return("call"); } else { return("raise"); } } else { return("fold"); } } // We have suited connectors else if ((int)card.getHeight() - (int)othercard.getHeight() < 2 && card.getSuit() == othercard.getSuit()) { //If the opponent raised , we flat call , otherwise we raise if (state.OpponentAction != null && state.OpponentAction.getAction().Equals("raise")) { return("call"); } else { return("raise"); } } return("fold"); }
private static HandCategory CheckStraight(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .GroupBy(x => x.getHeight()) .Count() >= 5 && CardsToEvaluate.Max(x => (int)x.getHeight()) - CardsToEvaluate.Min(x => (int)x.getHeight()) == 4) { return(HandCategory.Straight); } else { return(CheckThreeOfAKind(CardsToEvaluate, hand)); } }
private static HandCategory CheckFullHouse(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CheckPair(CardsToEvaluate, hand) == HandCategory.Pair && CheckThreeOfAKind(CardsToEvaluate, hand) == HandCategory.ThreeOfAKind) { return(HandCategory.FullHouse); } else { return(CheckFlush(CardsToEvaluate, hand)); } }
private static HandCategory CheckFourOfAKind(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .GroupBy(card => card.getHeight()) .Any(group => group.Count() == 4)) { return(HandCategory.FourOfAKind); } else { return(CheckFullHouse(CardsToEvaluate, hand)); } }
private static HandCategory CheckStraightFlush(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CheckFlush(CardsToEvaluate, hand) == HandCategory.Flush && CheckStraight(CardsToEvaluate, hand) == HandCategory.Straight) { return(HandCategory.StraightFlush); } else { return(CheckFourOfAKind(CardsToEvaluate, hand)); } }
private static HandCategory CheckRoyalFlush(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .Min(x => (int)x.getHeight()) == (int)CardHeight.TEN && CheckStraightFlush(CardsToEvaluate, hand) == HandCategory.StraightFlush) { return(HandCategory.RoyalFlush); } else { return(CheckStraightFlush(CardsToEvaluate, hand)); } }
private static HandCategory CheckThreeOfAKind(IEnumerable <Card> CardsToEvaluate, HandHoldem hand) { if (CardsToEvaluate .GroupBy(x => x.getHeight()) .Any(group => group.Count() == 3)) { return(HandCategory.ThreeOfAKind); } else { return(CheckTwoPair(CardsToEvaluate, hand)); } }
/// <summary> /// Ge the hand category (ex. Two pair) /// </summary> public HandCategory GetHandCategory(BotState state, HandHoldem hand) { return(HandEval.Evaluate(state, hand)); }