xena: A sample function that goes all in or folds

Description Usage Arguments Details Value References Examples

View source: R/xena.R

Description

Goes all in with a pair of 10s or higher, or with a pair of 7s or higher if there are 6 or fewer players, or with any cards if you have less than 2 big blinds. With AK or AQ, all in with probability 75%. Or if nobody's raised yet, under certain conditions (see details).

Usage

1
2
xena(numattable1, crds1, board1, round1, currentbet, mychips1, 
pot1, roundbets, blinds1, chips1, ind1, dealer1, tablesleft)

Arguments

numattable1

(integer) number of players at the table

crds1

(2x2 matrix) your hole cards. cards1[1,1] = the number of card 1 (between 2 and 14). cards[1,2] = suit of card 1 (between 1 and 4). cards1[2,1] = the number (2-14) of card 2. cards[2,2] = suit of card 2 (1-4).

board1

(5x2 matrix) the board cards. board1[1,1] = number of first card (2-14). board1[1,2] = suit (1-4) of first card. Both are zero if the card hasn't been seen yet. For instance, if bettinground1 < 3, then board[4,1] = board1[4,2] = 0.

round1

(integer) which betting round it is. 1 = preflop, 2 = after flop, 3 = after turn, 4 = after river.

currentbet

(integer) how much more it is to you to stay in, right now.

mychips1

(integer) how many chips you have left at the moment.

pot1

(integer) how much is in the pot at the moment.

roundbets

(numattable1 x 4 matrix) matrix of all past bets during this hand. roundbets[i,j] = total amount the player in seat i put in, in betting round j.

blinds1

(integer) big blind amount.

chips1

(vector of length numattable1) list of how many chips everyone has. chips1[i] = how many chips the player in seat i has left.

ind1

(integer) which seat you're in. (So, mychips1 = chips1[ind1]).

dealer1

(integer) which seat the dealer is in.

tablesleft

(integer) how many tables are left in the tournament (including yours).

Details

Goes all in with a pair of 10s or higher, or with a pair of 7s or higher if there are 6 or fewer players, or with any cards if you have less than 2 big blinds. With AK or AQ, all in with probability 75%. If nobody's raised yet, ... and if there are 3 or fewer players left behind you, then go all in with any pair or any ace. ... and there's only 1 or 2 players behind you, then go all in with any cards.

When this function is called from tourn1(), cards1[2,1] is always less than or equal to cards1[1,1]. If the player in the big blind seat does not have enough chips to pay the big blind, then blinds1 is still the amount that the big blind would have been. If only 2 players are left, then tourn1() uses the convention that the "dealer" is the big blind in determining dealer1.

Value

integer indicating the number of chips you are betting. 0 means fold.

References

Schoenberg, F. (2011). An Introduction to Probability with Texas Holdem Examples. Taylor and Francis, New York.

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
35
##---- 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(numattable1, crds1, board1,  round1, currentbet, mychips1, pot1,
    roundbets, blinds1, chips1, ind1, dealer1, tablesleft){
    ## if pair of 10s or higher, all in for sure, no matter what.
    ## if AK or AQ, all in with probability 75%.
    ## if pair of 7s or higher and there are 6 or fewer players 
    ##      at your table (including you), then all in. 
    ## if your chip count is less than twice the big blind, go all in with any cards.
    ## if nobody's raised yet:
    ##     ... and if there are 3 or fewer players left behind you,
    ##              then go all in with any pair or any ace.
    ##     ... and there's only 1 or 2 players behind you,
    ##              then go all in with any cards.    
    a1 = 0
    x = runif(1)               ## x is a random number between 0 and 1.
    y = max(roundbets[,1])     ## y is the maximum bet so far.
    big1 = dealer1 + 2
    if(big1 > numattable1) big1 = big1 - numattable1
    z = big1 - ind1
    if(z<0) z = z + numattable1 
    ## the previous 4 lines make it so z is the number of players left to act behind you.
    if((crds1[1,1] == crds1[2,1]) && (crds1[2,1] > 9.5)) a1 = mychips1
    if((crds1[1,1] == 14) && (crds1[1,2]>11.5) && (x<.75)) a1 = mychips1
    if((crds1[1,1] == crds1[2,1]) && (crds1[2,1] > 6.5) && (numattable1 < 6.5)) a1 = mychips1
    if(mychips1 < 2*blinds1) a1 = mychips1
    if(y <= blinds1){
	if((z < 3.5) && ((crds1[1,1] == crds1[2,1]) || (crds1[1,1] == 14))) a1 = mychips1
	if(z < 2.5) a1 = mychips1
    }
    a1
  } ## end of xena

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