R/end_criteria.R

Defines functions end_criteria

Documented in end_criteria

#' Test if a betting round has ended.
#'
#' @param bets A vector representing each player's total contribution
#' to the pot.
#' @param skip A logical vector representing which players have folded.
#' @param counter The total number of actions that have been made
#' in the betting round so far.
#'
#' @return
#' @export
#'
#' @examples
end_criteria <- function(bets,skip,counter){
  #First check to see everyone has folded except one.
  n <- length(skip)
  if(sum(skip) == n-1){
    return(TRUE)
  } else if(
    equal(bets[!skip]) && (counter >= sum(!skip))
  ){
    return(TRUE)
  } else return(FALSE)
}
dfcorbin/pokersim documentation built on Nov. 13, 2019, 4:21 p.m.