handeval: Evaluates your hand.

Description Usage Arguments Value Author(s) Examples

View source: R/handeval.R

Description

Returns a number corresponding to the strength of your best 5-card poker hand.

Usage

1
handeval(num1, suit1)

Arguments

num1

vector of numbers of your cards and the board cards.

suit1

corresponding suits of your cards and the board cards.

Value

If you have a straight flush, then it will return a value in the 8 million to 9 million range, if you have four of a kind, then it will return a value between 7 million and 8 million, etc., according to the list below.

Straight Flush: 8,000,000 - 8,999,999 Four of a kind: 7,000,000 - 7,999,999. Full House: 6,000,000 - 6,999,999. Flush: 5,000,000 - 5,999,999. Straight: 4,000,000 - 4,999,999. 3 of a kind: 3,000,000 - 3,999,999. Two pairs: 2,000,000 - 2,999,999. One pair: 1,000,000 - 1,999,999. No pairs: 0 - 999,999. If one player's hand beats that of another, then the value returned by this function will be higher for the first player than the second.

Author(s)

Frederic Paik Schoenberg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
boardcards = c(4,5,6,8,13)
boardsuits = c(2,3,2,2,2)
player1cards = c(2,3)
player1suits = c(2,1)
player2cards = c(7,3)
player2suits = c(2,4)
handeval(c(boardcards,player1cards),c(boardsuits,player1suits)) ## pl.1's value
handeval(c(boardcards,player2cards),c(boardsuits,player2suits)) ## pl.2's value

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(num1,suit1){
    a1 = strflsh1(num1,suit1) 
    if(a1>0.5) return(8000000+a1)
    a1 = four1(num1)
    if(a1>0.5) return(7000000+a1)
    a1 = full1(num1)
    if(a1>0.5) return(6000000+a1)
    a1 = flush1(num1,suit1)
    if(a1>0.5) return(5000000+a1)
    a1 = straight1(num1)
    if(a1>0.5) return(4000000+a1)
    a1 = trip1(num1)
    if(a1>0.5) return(3000000+a1)
    a1 = twopair1(num1)
    if(a1>0.5) return(2000000+a1)
    a1 = onepair1(num1)
    if(a1>0.5) return(1000000+a1)
    a1 = nothing1(num1)
    return(a1)
  } ## end of handeval

Example output

[1] 5686537
[1] 5686794
function (num1, suit1) 
{
    a1 = strflsh1(num1, suit1)
    if (a1 > 0.5) 
        return(8e+06 + a1)
    a1 = four1(num1)
    if (a1 > 0.5) 
        return(7e+06 + a1)
    a1 = full1(num1)
    if (a1 > 0.5) 
        return(6e+06 + a1)
    a1 = flush1(num1, suit1)
    if (a1 > 0.5) 
        return(5e+06 + a1)
    a1 = straight1(num1)
    if (a1 > 0.5) 
        return(4e+06 + a1)
    a1 = trip1(num1)
    if (a1 > 0.5) 
        return(3e+06 + a1)
    a1 = twopair1(num1)
    if (a1 > 0.5) 
        return(2e+06 + a1)
    a1 = onepair1(num1)
    if (a1 > 0.5) 
        return(1e+06 + a1)
    a1 = nothing1(num1)
    return(a1)
}

holdem documentation built on May 2, 2019, 9:21 a.m.