Learn R Programming

holdem (version 1.2)

straightdraw1: See if you have a straight draw.

Description

Sees how many possibilities there are that will make a straight for you.

Usage

straightdraw1(x)

Arguments

x

Value

returns 26 if you already have a straight. returns 4 is there are 2 possibilities for a straight. returns 2 for a gutshot straight draw. returns 0 otherwise.

Examples

Run this code
# NOT RUN {
straightdraw1(c(2,5,6,7,9,14))
straightdraw1(c(4,5,6,7,9,14))
##---- 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(x){
    ## returns 4 is there are 2 possibilities for a straight. 
    ## returns 2 for a gutshot straight draw.
    ## returns 0 otherwise
    ## Note: returns 26 if you already have a straight!
    a1 = 0
    for(i in c(2:14)){
	a2 = straight1(c(i,x))
	if(a2 > .5) a1 = a1 + 1
    }
    a1 * 2 
  }	## end of straightdraw1
# }

Run the code above in your browser using DataLab