Class Player

java.lang.Object
  extended by Player

public class Player
extends java.lang.Object

Provides methods needed to emulate poker player behaviors.

Core behaviors:
  01. Evaluates hand consisting of pocket cards only (implemented)
  02. Evaluates hand consisting of pocket and flop cards (in progress)
  03. Evaluates hand consisting of pocket, flop, and turn cards (NOT implemented)
  04. Evaluates hand consisting of pocket, flop, turn, and river cards (NOT implemented)

Auxiliary behaviors:
  01. Prints active players hands to the console (implemented)

Possible future behaviors:
  01. Predict players hands probability to win at each stage of a round.


Constructor Summary
Player()
           
 
Method Summary
static int evalHandOnFlop(int playerNumber, java.lang.String[] playersHand, java.lang.String[] playersStatus, java.lang.String[] houseHand, int topHandSeat, java.lang.String[] topHandType, int[] topHandPoints, int[] topFHSValue, int[] topFLSValue, int[] topSTRValue, int[] topTRPValue, int[] top2PRValue, int[] top1PRValue, int[] topCRDValue, int[] topPairValue)
          Evaluates player's pocket + flop cards to stay or fold.
static void evalHandOnPocket(int playerNumber, java.lang.String[] playersHand, java.lang.String[] playersStatus)
          Evaluates player's pocket cards to stay or fold.
static void evalHandOnRiver(int playerNumber, java.lang.String[] playersHand, java.lang.String[] playersStatus, java.lang.String[] houseHand)
          public static int evalHandOnTurn(int playerNumber, String[] playersHand, String[] playersStatus, String[] houseHand, int topHandSeat, String[] topHandType, int[] topHandPoints, int[] topFHSValue) { // Check for series (start of - or a complete - straight) in all 5 cards.
static void evalHandOnTurn(int playerNumber, java.lang.String[] playersHand, java.lang.String[] playersStatus, java.lang.String[] houseHand)
          Evaluates player's pocket + flop + turn cards to stay or fold.
static void getFullHands(int playerNumber, java.lang.String[] playersHand, java.lang.String[] playersStatus, java.lang.String[] houseHand, java.lang.String[][] fullHands)
           
static void printActivePlayersHands(java.lang.String[] playersHands, java.lang.String[] playersStatus)
          Output players hands contents to the console.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Player

public Player()
Method Detail

evalHandOnPocket

public static void evalHandOnPocket(int playerNumber,
                                    java.lang.String[] playersHand,
                                    java.lang.String[] playersStatus)
Evaluates player's pocket cards to stay or fold.

Parameters:
playerNumber - Player's position at the table.
playersHand - Player's current hand of (pocket) cards.
playersStatus - Player's current status (IN or OUT of the round).

evalHandOnFlop

public static int evalHandOnFlop(int playerNumber,
                                 java.lang.String[] playersHand,
                                 java.lang.String[] playersStatus,
                                 java.lang.String[] houseHand,
                                 int topHandSeat,
                                 java.lang.String[] topHandType,
                                 int[] topHandPoints,
                                 int[] topFHSValue,
                                 int[] topFLSValue,
                                 int[] topSTRValue,
                                 int[] topTRPValue,
                                 int[] top2PRValue,
                                 int[] top1PRValue,
                                 int[] topCRDValue,
                                 int[] topPairValue)
Evaluates player's pocket + flop cards to stay or fold.

Parameters:
playerNumber - Player's position at the table.
playersHand - Player's current hand of (pocket) cards.
playersStatus - Player's current status (IN or OUT of the round).
houseHand - The house hand's current cards (3 flop cards)

evalHandOnTurn

public static void evalHandOnTurn(int playerNumber,
                                  java.lang.String[] playersHand,
                                  java.lang.String[] playersStatus,
                                  java.lang.String[] houseHand)
Evaluates player's pocket + flop + turn cards to stay or fold.

Parameters:
playerNumber - Player's position at the table.
playersHand - Player's current hand of (pocket) cards.
playersStatus - Player's current status (IN or OUT of the round).
houseHand - The house hand's current cards (3 flop + 1 turn cards).

evalHandOnRiver

public static void evalHandOnRiver(int playerNumber,
                                   java.lang.String[] playersHand,
                                   java.lang.String[] playersStatus,
                                   java.lang.String[] houseHand)
public static int evalHandOnTurn(int playerNumber, String[] playersHand, String[] playersStatus, String[] houseHand, int topHandSeat, String[] topHandType, int[] topHandPoints, int[] topFHSValue) { // Check for series (start of - or a complete - straight) in all 5 cards. If found add 2 pts per card total and stay in round. // Check for same suits (start of a flush). If found add 2 pts per card total and stay in round. // NOTE: If both series and same suit found, total pts will be 4 pts per card to total cards sum value. // Change playersStatus to "OUT" if no series or flush detected. // Split and parse the dealt card's suit and value. String delims = "[.]"; int handPoints = 0; int turnHandCardValue[] = {0, 0, 0, 0, 0, 0}; String turnHandCardSuit[] = { null, null, null, null, null, null }; // Parse player's first card's value and suit String[] tokens = playersHand[playerNumber+(playersHand.length/3)].split(delims); turnHandCardValue[0] = Integer.parseInt(tokens[0]); turnHandCardSuit[0] = tokens[1]; handPoints += turnHandCardValue[0]; // JNS point system adding first card value as points. // Parse player's second card's value and suit tokens = playersHand[playerNumber+(playersHand.length-(playersHand.length/3))].split(delims); turnHandCardValue[1] = Integer.parseInt(tokens[0]); turnHandCardSuit[1] = tokens[1]; handPoints += turnHandCardValue[1]; // JNS point system adding second card value as points. // Parse the flop card's values and suits tokens = houseHand[0].split(delims); // Parse first flop card. turnHandCardValue[2] = Integer.parseInt(tokens[0]); turnHandCardSuit[2] = tokens[1]; handPoints += turnHandCardValue[2]; // JNS point system adding third card value as points. tokens = houseHand[1].split(delims); // Parse second flop card. turnHandCardValue[3] = Integer.parseInt(tokens[0]); turnHandCardSuit[3] = tokens[1]; handPoints += turnHandCardValue[3]; // JNS point system adding fourth card value as points. tokens = houseHand[2].split(delims); // Parse third flop card. turnHandCardValue[4] = Integer.parseInt(tokens[0]); turnHandCardSuit[4] = tokens[1]; handPoints += turnHandCardValue[4]; // JNS point system adding fifth card value as points. tokens = houseHand[3].split(delims); // Parse the turn card. turnHandCardValue[5] = Integer.parseInt(tokens[0]); turnHandCardSuit[5] = tokens[1]; handPoints += turnHandCardValue[5]; // JNS point system adding fifth card value as points. // Sum this hand's card values. int thisHandValue = 0; for(int i = 0; i < turnHandCardValue.length; i++) { thisHandValue += turnHandCardValue[i]; } // Update the top hand points. if (topHandPoints[0] < thisHandValue) { topHandPoints[0] = thisHandValue; } System.out.print("\n\n[Player] Seat " + playerNumber + " thisHandValue: " + thisHandValue + "\n"); System.out.print("[Player]Top Hand Points = " + topHandPoints[0] + "\n"); // Check to see if player's hand is a Royal Flush. topHandSeat = Ranker.evalTurnHandForRoyalFlush(playerNumber, turnHandCardSuit, thisHandValue, topHandType, topHandSeat); Ranker.printFlopHand(playerNumber, turnHandCardValue, turnHandCardSuit, thisHandValue); // Check to see if player's hand is a Straight Flush. topHandSeat = Ranker.evalTurnHandForStraightFlush(playerNumber, turnHandCardSuit, turnHandCardValue, thisHandValue, topHandType, topHandSeat); // Check to see if player's hand is a Quad (four of a kind). topHandSeat = Ranker.evalTurnHandForQuad(playerNumber, turnHandCardSuit, turnHandCardValue, thisHandValue, topHandType, topHandSeat); // ===================================================================================================== // !! ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION !! // ===================================================================================================== // * APP execution flow begins a new pattern here due to how low-end hand detection & ranking happens! * // // From this point forward, hand evaluation will occur only if a top-hand seat of the major three // hand types above has not already been detected (nullifying all need to detect or evaluate and rank // any possible low-end hands). Additionally, since multiple specific low-hand types (Full Houses, // Straights, Trips, Pairs, High Cards) may exist on the flop, turn, and river phases of the deal, ALL // instances of such hands must be detected and ranked by multiple passes of the remaining associated // hand evaluation methods below if none of the High-end hand types have been detected so far by the // three major top-hand evaluation methods above. Those high-hand methods will still be trying to detect // such hands (because not all players hands may have been evaluated yet). // ===================================================================================================== // Check to see if player's hand is a Full House. // NOTE: Temporary (non-winning) topHandSeat values will indicate one of the following: // -1 means no top hand of any type has been detected. // -2 means at least one Full House has been detected. // -3 means at least one regular flush (non-Royal and non-Straight flush) has been detected. // -4 meant at least one regular straight (non-flush) has been detected. // -5 means at least one Trips has been detected. // -6 means at least one Pair has been detected. // -7 means at the highest of the high-card only hands has been determined. // ================================================================================================ if ((topHandSeat < 0) || (topHandType[0].equals("FHS"))) { System.out.print("\n[Player] checking for FHS on playerNumber " + playerNumber + "\n"); topHandSeat = Ranker.evalTurnHandForFullHouse(playerNumber, turnHandCardSuit, turnHandCardValue, thisHandValue, topHandType, topHandSeat, topFHSValue); } // Check to see if player's hand is a Flush. if ((topHandSeat < 0) || (topHandType[0].equals("FLS"))) { System.out.print("\n[Player] checking for FHS on playerNumber " + playerNumber + "\n"); topHandSeat = Ranker.evalTurnHandForFlush(playerNumber, turnHandCardSuit, turnHandCardValue, thisHandValue, topHandType, topHandSeat, topFHSValue); } // Check to see if player's hand is a Straight. if (topHandSeat == -1) { // Ranker.evalFlopHandForStraight(...); } // Check to see if player's hand is Trips (three of a kind). if (topHandSeat == -1) { // Ranker.evalFlopHandForTrips(...); } // No Trips found. Check to see if player's hand is Two Pair. if (topHandSeat == -1) { // Ranker.evalFlopHandForTwoPair(...); } // No Two Pair found. Check to see if player's hand is a Pair. if (topHandSeat == -1) { // Ranker.evalFlopHandForPair(...); } // No Pair found. Check to see if players hand is High Card. if (topHandSeat == -1) { // Ranker.evalFlopHandForHighCard(...); } if (playerNumber == topHandSeat) { System.out.print("Player - Seat " + (playerNumber+1) + " " + playersStatus[playerNumber] + " points: " + handPoints + " <<<< TOP HAND SEAT (" + topHandType[0] + ")\n"); } else { System.out.print("Player - Seat " + (playerNumber+1) + " " + playersStatus[playerNumber] + " points: " + handPoints + "\n"); } System.out.print("\n"); return topHandSeat; // Top hand seat was not determined. }


getFullHands

public static void getFullHands(int playerNumber,
                                java.lang.String[] playersHand,
                                java.lang.String[] playersStatus,
                                java.lang.String[] houseHand,
                                java.lang.String[][] fullHands)
Parameters:
playerNumber - Player's position at the table.
playersHand - Player's current hand of (pocket) cards.
playersStatus - Player's current status (IN or OUT of the round).
houseHand - The house hand's current cards (3 flop cards).
fullHands - The full hands (all cards available for play by players and by house).

printActivePlayersHands

public static void printActivePlayersHands(java.lang.String[] playersHands,
                                           java.lang.String[] playersStatus)
Output players hands contents to the console.

Parameters:
playersHands - The players hands store.
playersStatus - The players status store.