/* -------------------------------------------------------- valueHand(): return value of a hand -------------------------------------------------------- */ public static int valueHand( Card[] h ) { if ( isFlush(h) && isStraight(h) ) return valueStraightFlush(h); else if ( is4s(h) ) return valueFourOfAKind(h); else if ( isFullHouse(h) ) return valueFullHouse(h); else if ( isFlush(h) ) return valueFlush(h); else if ( isStraight(h) ) return valueStraight(h); else if ( is3s(h) ) return valueSet(h); else if ( is22s(h) ) return valueTwoPairs(h); else if ( is2s(h) ) return valueOnePair(h); else return valueHighCard(h) // Lowest Poker hand; } |
Value( a better Poker hand ) > Value( a worse Poker hand ) |
|
Royal Flush > Straight Flush > 4 of a Kind > Full House > Flush > Straight > 3 of a Kind > 2 pairs > 1 pair > High Card |
Royal Flush: all equal value Straight Flush: highest rank card wins 4 of a Kind: hihest rank quads wins Full House: highest rank set (3) cards wins Flush: highest rank card wins Straight: highest rank card wins 3 of a Kind: highest rank set (3) cards wins 2 pairs: highest pair wins if tie, lowest pair wins if also tie, highest unmatched card wins 1 pair: highest pair wins if tie, highest unmatched card wins if also tie, second highest unmatched card wins if also tie, lowest unmatched card wins High Card: highest rank card wins if tie, second highest rank card wins and so on... |
![]() |
|
Example:
![]() |
Explanation:
|
Value(Poker hand) = InterValue(Poker hand) + IntraValue(Poker hand) |
where:
|
InterValue( Straight Flush ) = 8000000 InterValue( Four of a Kind ) = 7000000 InterValue( Full House ) = 6000000 InterValue( Flush ) = 5000000 InterValue( Straight ) = 4000000 InterValue( 3 of a Kind ) = 3000000 InterValue( Two pairs ) = 2000000 InterValue( One pair ) = 1000000 InterValue( High Card ) = 0 |
|
Royal Flush: all equal value Straight Flush: highest rank card wins 4 of a Kind: hihest rank quads wins Full House: highest rank set (3) cards wins Flush: highest rank card wins Straight: highest rank card wins 3 of a Kind: highest rank set (3) cards wins 2 pairs: highest pair wins if tie, lowest pair wins if also tie, highest unmatched card wins 1 pair: highest pair wins if tie, highest unmatched card wins if also tie, second highest unmatched card wins if also tie, lowest unmatched card wins High Card: highest rank card wins if tie, second highest rank card wins and so on... |
![]() |
value of High Card hand = sum of the ranks of each card |
This will not assign the appropriate value
Here is why:
|
|
/* ----------------------------------------------------- valueHighCard(): return value of a high card hand value = 14^4*highestCard + 14^3*2ndHighestCard + 14^2*3rdHighestCard + 14^1*4thHighestCard + LowestCard ----------------------------------------------------- */ public static int valueHighCard( Card[] h ) { int val; sortByRank(h); // Sorth cards by their ranks first val = h[0].rank() + 14* h[1].rank() + 14*14* h[2].rank() + 14*14*14* h[3].rank() + 14*14*14*14* h[4].rank(); return val; } |
Example:
value of hand ------------------------------------ High Card Poker hand 1: 2 3 4 5 K 2+3*14+4*142+5*143+13*144 = 513956 High Card Poker hand 2: 6 7 8 9 Q 6+7*14+8*142+9*143+12*144 = 487360 |
By giving the highest card K the weight 144, we can make sure that the assigned value is greater than any hand with a high card that is smaller than K.
![]() |
|
/* ----------------------------------------------------- valueOnePair(): return value of a One-Pair hand value = ONE_PAIR (the inter Poker hand) + 14^3*PairCard + 14^2*HighestCard + 14*MiddleCard + LowestCard ----------------------------------------------------- */ public static int valueOnePair( Card[] h ) { int val = 0; sortByRank(h); // Sort by rank first /* --------------------------------------------- Compute: intra "One Pair" hand value --------------------------------------------- */ if ( h[0].rank() == h[1].rank() ) // a a x y z val = 14*14*14*h[0].rank() + + h[2].rank() + 14*h[3].rank() + 14*14*h[4].rank(); else if ( h[1].rank() == h[2].rank() ) // x a a y z val = 14*14*14*h[1].rank() + + h[0].rank() + 14*h[3].rank() + 14*14*h[4].rank(); else if ( h[2].rank() == h[3].rank() ) // x y a a z val = 14*14*14*h[2].rank() + + h[0].rank() + 14*h[1].rank() + 14*14*h[4].rank(); else // x y z a a val = 14*14*14*h[3].rank() + + h[0].rank() + 14*h[1].rank() + 14*14*h[2].rank(); /* -------------------------------- Add the inter Poker hand value -------------------------------- */ return ONE_PAIR + val; } |
![]() |
|
/* ----------------------------------------------------- valueTwoPairs(): return value of a Two-Pairs hand value = TWO_PAIRS + 14*14*HighPairCard + 14*LowPairCard + UnmatchedCard ----------------------------------------------------- */ public static int valueTwoPairs( Card[] h ) { int val = 0; sortByRank(h); /* --------------------------------------------- Compute: intra "One Pair" hand value --------------------------------------------- */ if ( h[0].rank() == h[1].rank() && h[2].rank() == h[3].rank() ) // a a b b x val = 14*14*h[2].rank() + 14*h[0].rank() + h[4].rank(); else if ( h[0].rank() == h[1].rank() && h[3].rank() == h[4].rank() ) // a a x b b val = 14*14*h[3].rank() + 14*h[0].rank() + h[2].rank(); else // x a a b b val = 14*14*h[3].rank() + 14*h[1].rank() + h[0].rank(); /* --------------------------------------------- Add the Inter Poker hand value --------------------------------------------- */ return TWO_PAIRS + val; } |
![]() |
|
/* --------------------------------------------------------------- valueSet(): return value of a Set hand value = SET + SetCardRank Trick: After sorting by rank, the middle card h[2] is always a card that is part of the set hand There is ONLY ONE hand with a set of a given rank. --------------------------------------------------------------- */ public static int valueSet( Card[] h ) { sortByRank(h); /* ----------------------------------- Possible "3 of a kind" hands: a a a x y x a a a y x y a a a ^ | h[2] ----------------------------------- */ return SET + h[2].rank(); } |
![]() |
|
/* ----------------------------------------------------------- valueFullHouse(): return value of a Full House hand value = FULL_HOUSE + SetCardRank ----------------------------------------------------------- */ public static int valueFullHouse( Card[] h ) { sortByRank(h); /* ----------------------------------- Possible "Full House" hands: a a a x x x x a a a ^ | h[2] ----------------------------------- */ return FULL_HOUSE + h[2].rank(); } |
![]() |
|
/* -------------------------------------------------------------- valueFourOfAKind(): return value of a 4 of a kind hand value = FOUR_OF_A_KIND + 4sCardRank Trick: card h[2] is always a card that is part of the 4-of-a-kind hand There is ONLY ONE hand with a quads of a given rank. --------------------------------------------------------------- */ public static int valueFourOfAKind( Card[] h ) { sortByRank(h); /* ----------------------------------- Possible "4 of a Kind" hands: a a a a x x a a a a ^ | h[2] ----------------------------------- */ return FOUR_OF_A_KIND + h[2].rank(); } |
![]() |
|
/* ----------------------------------------------------- valueFlush(): return value of a Flush hand value = FLUSH + valueHighCard() ----------------------------------------------------- */ public static int valueFlush( Card[] h ) { return FLUSH + valueHighCard(h); } |
Explanation:
|
![]() |
|
/* ----------------------------------------------------- valueStraight(): return value of a Straight hand value = STRAIGHT + valueHighCard() ----------------------------------------------------- */ public static int valueStraight( Card[] h ) { return STRAIGHT + valueHighCard(h); } |
![]() |
![]() |
A Royal Flush is just the highest Straight Flush....
|
/* ----------------------------------------------------- valueStraight(): return value of a Straight hand value = STRAIGHT + valueHighCard() ----------------------------------------------------- */ public static int valueStraightFlush( Card[] h ) { return STRAIGHT_FLUSH + valueHighCard(h); } |
How to use the program:
|