R/blinds.R

Defines functions blinds

Documented in blinds

#' Add the Big/Small blinds to a vector.
#'
#' @param players A list of elements from the S4 class "player".
#' @param bets A vector representing each player's total contribution
#' to the pot.
#' @param start The index of the player who is due to act first.
#'
#' @return A list of double the length of players. The first half of
#' the list is a list of players. The second half is a list of the bets.
#' @export
#'
blinds <- function(players,bets,start){
  n <- length(players)
  sblind <- (start + n - 2)%%n
  bblind <- (start + n - 1)%%n
  if (sblind == 0) sblind <- n
  if (bblind == 0) bblind <- n
  bets[sblind] <- 1
  bets[bblind] <- 2
  players[[sblind]]@chips <- players[[sblind]]@chips - 1
  players[[bblind]]@chips <- players[[bblind]]@chips - 2
  return(c(players,bets))
}
dfcorbin/pokersim2 documentation built on Jan. 15, 2020, 12:20 a.m.