Esempio n. 1
0
 //Raise Button:
 private void buttonRaise_Click(object sender, EventArgs e)
 {
     int raiseAmount = (int)numericUpDownRaiseAmount.Value;
     int playerChipCount = game.getCurrentRound().getActivePlayer().getChipCount();
     if (raiseAmount >= minimumRaise)
     {
         if (playerChipCount >= raiseAmount)
         {
             Raise moveChoice = new Raise(raiseAmount);
             moveChoice.setRaiseAmount(raiseAmount);
             Player activePlayer = game.getCurrentRound().getActivePlayer();
             if (activePlayer != null)
             {
                 activePlayer.setMoveChoice(moveChoice);
                 minimumRaise = 1;//reset minimum raise for later use
             }
             else
             {
                 throw new Exception("activePlayer was null while attempting to raise in GameForm.");
             }
         }
         else
         {
             MessageBox.Show("Your Chips: " + playerChipCount + Environment.NewLine +
                 "Raise Amount: " + raiseAmount + Environment.NewLine + Environment.NewLine +
                 "You do not have enough chips to raise by this much.");
         }
     }
     else
     {
         MessageBox.Show("Your Chips: " + playerChipCount + Environment.NewLine +
                 "Minimum Raise: " + minimumRaise + Environment.NewLine +
                 "Raise Amount: " + raiseAmount + Environment.NewLine + Environment.NewLine +
                 "Your raise amount must be greater than or equal to the Minimum Raise, but less than or equal to Your Chips. By raising by the Minimum Raise you will call that amount and match the current highest raise.");
     }
 }
Esempio n. 2
0
        /// <summary>
        /// choose a move to preform after the river card has been shown
        /// </summary>
        public Move postRiverAction()
        {
            List<Card> fiveCardHand = new List<Card>();
            fiveCardHand.AddRange(playerHand);
            currentHandValue = handEval.evaluateHand(fiveCardHand);
            List<Card> boardCards = new List<Card>();
            for (int i = 2; i < playerHand.Count; i++)
            {
                boardCards.Add(playerHand[i]);
            }
            EvalResult boardValue = handEval.evaluateHand(boardCards);

            //If theres a huge difference between the strength of my hand + board and just the board, we generally have a strong hand
            //For example if the best hand on the board is a pair, and my best with my hand is a pair, we have the same evaluation and its likely that other players do aswell
            if (currentHandValue.getHandValue() >= boardValue.getHandValue())
            {
                int evalDifference = currentHandValue.getHandValue() - boardValue.getHandValue();
                Boolean canRaise = false;
                Boolean canCall = false;
                int raiseAmount = 1;
                int callAmount = 1;
                int highestChips = 0;

                // check which player in the list has the highest chips
                // the list of players will contain all other players still in the hand, excluding ourself
                foreach (Player player in players)
                {
                    if (player.getChipCount() > highestChips)
                        highestChips = player.getChipCount();
                }
                if (highestChips == 0)
                {
                    highestChips = 1;
                }

                // check if we are allowed to raise or call this turn
                // if we can, retrieve the minimum amounts associated with these actions
                foreach (Move move in possibleMoves)
                {
                    if (move is Raise)
                    {
                        raiseAmount = ((Raise)move).getMinimumRaise();
                        canRaise = true;
                    }
                    else if (move is Call)
                    {
                        callAmount = ((Call)move).getCallAmount();
                        canCall = true;
                    }
                }

                if (evalDifference >= 3)//significant strength compared to board, bully opponent
                {
                    if (getChipCount() / highestChips > .75)
                    {
                        // we can try to bully the opponents
                        // bet 10% of our chips
                        raiseAmount += Convert.ToInt32(getChipCount() * .1);
                        Raise moveChoice = new Raise(raiseAmount);
                        moveChoice.setRaiseAmount(raiseAmount);
                        return moveChoice;
                    }
                    // otherwise call or check depending on the call amount
                    if (!canCall)
                        return new Check();
                    else
                    {
                        // if the call amount is less than 10% of our chips, then
                        if (getChipCount() / callAmount > 20)
                        {
                            return new Call(callAmount);
                        }

                        else
                            return new Fold();
                    }
                }
                else if (evalDifference > 0)//moderate strength
                {
                    // if we are unable to call then we can check for free
                    if (!canCall)
                    {
                        return new Check();
                    }
                    // if the call is a small percentage of our chips then make it
                    else if (canCall && getChipCount() / callAmount < .05)
                    {
                        return new Call(callAmount);
                    }
                    else
                    {
                        return new Fold();
                    }

                }
                else //our hand strength is basically that of whats on the board i.e. not strong
                {
                    // check if possible. if not then fold
                    if (!canCall)
                        return new Check();
                    // checking is not an option, fold
                    return new Fold();
                }
            }
            else
            {
                //I dont think its possible a board value alone is stronger than (board + hand value) ever..
                return null;
            }

            // Now we know what our best hand is and know that another player either has a good hand or is bluffing since in almost all hands that get here we plan to bet(excluding the possible case were our hand is bad and we keep checkin)
            // again we will use isOurHandLiklyBetterThanAnyOtherPlayers to determine if our hand is better and we will bet accordingly
            // here we must again consider bluffing and our aggression level based on relative chip count(our compared to the players at the table
        }
Esempio n. 3
0
        //*****these action methods may be better as a class so we can store information since it is likly there will be multiple rounds of betting
        //it would probably be better use to classes to store the data then doing it inside this class
        public Move preFlopAction()
        {
            //Code to set up booleans based on given hand
            //assuming hand holds only 2 cards
            if (playerHand[0].suit == playerHand[1].suit)
            {
                suited = true;
            }
            else if (playerHand[0].value == playerHand[1].value)
            {
                pair = true;
            }
            // get integer values of cards
            int cardOne = ((int)playerHand[0].value), cardTwo = ((int)playerHand[1].value);
            // if both cards are with in one point and the cards are not with in the last or first few cards in order, this hand has a good chace of becomming a straight
            if ((cardOne == (cardTwo + 1) || cardTwo == (cardOne + 1)) && (cardOne + cardTwo > 3) && (cardOne + cardTwo < 19))
            {
                highStraightChance = true;
            }
            // if the cards are within five numbers of one another or are the Ace Two wrap around then there is a low chace for a straight
            else if (Math.Abs(cardOne - cardTwo) < 5 || (cardOne == 12 && cardTwo == 0) || (cardTwo == 12 && cardOne == 0))
            {
                lowStraightChance = true;
            }
            if (cardOne > 10 || cardTwo > 10)
            {
                highCard = true;
                if (cardOne > 10 && cardTwo > 10)
                {
                    doubleHighCard = true;
                }
            }
            double value = preFlopHandValue();

            Boolean canRaise = false;
            Boolean canCall = false;
            int raiseAmount = 1;
            int callAmount = 1;
            int highestChips = 1;

            // check which player in the list has the highest chips
            // the list of players will contain all other players still in the hand, excluding ourself
            foreach (Player player in players)
            {
                if (player.getChipCount() > highestChips)
                    highestChips = player.getChipCount();
            }
            if(highestChips == 0)
            {
                highestChips = 1;
            }

            // check if we are allowed to raise or call this turn
            // if we can, retrieve the minimum amounts associated with these actions
            foreach (Move move in possibleMoves)
            {
                if(move is Raise)
                {
                    raiseAmount = ((Raise)move).getMinimumRaise();
                    canRaise = true;
                }
                else if(move is Call)
                {
                    callAmount = ((Call)move).getCallAmount();
                    canCall = true;
                }
            }

            //very good hand
            if (value > preFlopMultiplierValues.getAverageMultiplier() * 2)
            {
                // we probably want to raise here depending on numbers of players left, our current chip total, and our current chips already in the pot

                // check if our current contribution to the pot is a low percentage of our chip count
                // check how far off of the highest our contribution is (given in Call if it exists, if it does not then we are the contribution leader)
                // check how many players remain
                if (players.Count < 3)
                {
                    // since there are so few players, all still in probably have decent hands and will call any bet
                    // raise to put more money into the pot but not a large bet
                    raiseAmount += Convert.ToInt32(getChipCount() * .1);
                }
                else // there are still a lot of players remaining in this round of betting
                {
                    // since there are still a lot of players in this round we will make a larger bet to force out weaker hands that may
                    // end up beating us if they stick around for too long with a lucky flop/river
                    raiseAmount += Convert.ToInt32(getChipCount() * .2);
                }

                // we can be aggressive if we have a solid ranking in the chip leaderboard and if we have not already raised twice this round
                if (getChipCount() / highestChips > .85 && numRaisesThisRound < 3)
                {
                    // we are the chip leader or very close and there are few players remaining
                    // play aggressively
                    numRaisesThisRound++;
                    Raise moveChoice = new Raise(raiseAmount);
                    moveChoice.setRaiseAmount(raiseAmount);
                    return moveChoice;
                }
                else
                // either we are not high on the chip leaderboard or we have raised enough this round already
                // check whether we should call or check this hand
                {
                    // if we can check for free and we are not high on chips let's test the waters before diving all in
                    if (!canCall)
                        return new Check();
                    else
                    {
                        // we have a really strong hand and probably cannot afford to give it up and hope for a better one which may not come
                        // even if the call makes us go all in let's try for it since we have a good shot at winning
                        return new Call(callAmount);
                    }
                }
            }
            //above average playable hand
            else if (value > preFlopMultiplierValues.getAverageMultiplier() * 1.5)
            {
                // we may want to raise here. most likely want to call assumming the call amount is not a huge percentage of our chips

                // if there are only a few players remaining then we should call and try to stay in the pot since our chances are good
                if(players.Count < 3)
                {
                    return new Call(callAmount);
                }
                else
                // if there are a lot of players left then we should raise in order to force out weaker hands
                {
                    // only raise if we havent already this round
                    if (numRaisesThisRound < 1)
                    {
                        raiseAmount += Convert.ToInt32(getChipCount() * .1);
                        numRaisesThisRound++;
                        Raise moveChoice = new Raise(raiseAmount);
                        moveChoice.setRaiseAmount(raiseAmount);
                        return moveChoice;
                    }
                    else
                        return new Call(callAmount);
                }
            }
            //slightly above average playable hand
            else if (value > preFlopMultiplierValues.getAverageMultiplier() * 1.25)
            {
                // make a small raise if we are currently the chip leader for the given hand or the difference between our chip stacks is small

                // check if our stack is at least 75% of the leader's stack and we have not raised this round yet
                if(getChipCount()/highestChips > .75 && numRaisesThisRound < 1)
                {
                    // we can try to bully the opponents
                    // bet 10% of our chips
                    raiseAmount +=  Convert.ToInt32(getChipCount() * .1);
                    numRaisesThisRound++;
                    Raise moveChoice = new Raise(raiseAmount);
                    moveChoice.setRaiseAmount(raiseAmount);
                    return moveChoice;
                }
                // otherwise call or check depending on the call amount
                if (!canCall)
                    return new Check();
                else
                {
                    // if the call amount is less than 10% of our chips, then
                    if (getChipCount() / callAmount > 20)
                    {
                        return new Call(callAmount);
                    }

                    else
                        return new Fold();
                }
            }
            //playable hand
            else if (value > preFlopMultiplierValues.getAverageMultiplier())
            {
                // make small calls or check if available
                // fold if the call is too large

                // if we are unable to call then we can check for free
                if(!canCall)
                {
                    return new Check();
                }
                // if the call is a small percentage of our chips then make it
                else if(canCall && getChipCount()/callAmount > 20)
                {
                    return new Call(callAmount);
                }
                else
                {
                    return new Fold();
                }
            }
            //currently not a playable hand
            else
            {
                // check if possible. if not then fold
                if (!canCall)
                    return new Check();
                // checking is not an option, fold
                return new Fold();
            }

            //use the value of the hand to decide to call raise check or fold
            //also use this value to determine the number of chips to risk using for raise or calling
            //essentailly the number of chip we think this hand is worth

            //return a move with the desired play
            // need a logic block to deal with the case of multiple rounds of betting durring preflop

            //always "check" if we possible before folding
        }
Esempio n. 4
0
        /// <summary>
        /// determines what to do in any round of betting between the flop and the turn
        /// may need hand/ possible actions(moves) as a param/s
        /// will return a move that we want to preform
        /// </summary>
        public Move postFlopAction()
        {
            List<Card> fiveCardHand = new List<Card>();
            fiveCardHand.AddRange(playerHand);
            currentHandValue = handEval.evaluateHand(fiveCardHand);
            List<Card> boardCards = new List<Card>();
            Boolean likelyToImproveHand = false;
            for(int i = 2; i < playerHand.Count; i++)
            {
                boardCards.Add(playerHand[i]);
            }
            EvalResult boardValue = handEval.evaluateHand(boardCards);

            //If theres a huge difference between the strength of my hand + board and just the board, we generally have a strong hand
            //For example if the best hand on the board is a pair, and my best with my hand is a pair, we have the same evaluation and its likely that other players do aswell
            if(currentHandValue.getHandValue() >= boardValue.getHandValue())
            {
                int likelyNextHandValue = getMostLikelyNextHandValue();
                if(likelyNextHandValue > currentHandValue.getHandValue())//if we are likely to get a good hand value
                {
                    likelyToImproveHand = true; //this will be used to skew the evalutationDifference
                }
                int evalDifference = currentHandValue.getHandValue() - boardValue.getHandValue();
                if(likelyToImproveHand)//if we are likely to improve our hand, up the difference by 1
                {
                    evalDifference++;
                }
                Boolean canRaise = false;
                Boolean canCall = false;
                int raiseAmount = 1;
                int callAmount = 1;
                int highestChips = 0;

                // check which player in the list has the highest chips
                // the list of players will contain all other players still in the hand, excluding ourself
                foreach (Player player in players)
                {
                    if (player.getChipCount() > highestChips)
                        highestChips = player.getChipCount();
                }
                if (highestChips == 0)
                {
                    highestChips = 1;
                }

                // check if we are allowed to raise or call this turn
                // if we can, retrieve the minimum amounts associated with these actions
                foreach (Move move in possibleMoves)
                {
                    if (move is Raise)
                    {
                        raiseAmount = ((Raise)move).getMinimumRaise();
                        canRaise = true;
                    }
                    else if (move is Call)
                    {
                        callAmount = ((Call)move).getCallAmount();
                        canCall = true;
                    }
                }

                if (evalDifference >= 3)//significant strength compared to board, bully opponent
                {
                    if ((getChipCount() / highestChips) > .60)
                    {
                        // we can try to bully the opponents
                        // bet a base of 10% of our chips
                        // hand strength is up to 8, add up to handStrength% of chips: 8 = 18% of our chips
                        raiseAmount += Convert.ToInt32(getChipCount() * (.1 + (((double)currentHandValue.getHandValue())/100)));
                        Raise moveChoice = new Raise(raiseAmount);
                        moveChoice.setRaiseAmount(raiseAmount);
                        return moveChoice;
                    }
                    // otherwise call or check depending on the call amount
                    if (!canCall)
                        return new Check();
                    else
                    {
                        // if the call amount is less than 10% of our chips, then
                        if (( callAmount / getChipCount()) > .10)
                        {
                            return new Call(callAmount);
                        }

                        else
                            return new Fold();
                    }
                }
                else if(evalDifference > 0)//moderate strength
                {
                    // if we are unable to call then we can check for free
                    if (!canCall)
                    {
                        return new Check();
                    }
                    // if the call is a small percentage of our chips then make it
                    else if (canCall && (callAmount / getChipCount()) > .05)
                    {
                        return new Call(callAmount);
                    }
                    else
                    {
                        return new Fold();
                    }

                }
                else //our hand strength is basically that of whats on the board i.e. not strong
                {
                    // check if possible. if not then fold
                    if (!canCall)
                        return new Check();
                    // checking is not an option, fold
                    return new Fold();
                }
            }
            else
            {
                //I dont think its possible a board value alone is stronger than (board + hand value) ever..
                return null; // again this should really never be reached
            }

            // at this point we have a good idea of what our hand is going to be or can possibly be
            // have a logic block that determines what move to make based on the returns from the 2 methods below
            // may also consider if the player(s) are prone to bluffing
            // may act different based on number of chip or an aggression attribute
            // learning could affect the action taken
        }