This code accompanies the paper “when to hold ‘em” by Kaity Parsons, Peter Tingley and Emma Zajdela.

We first show the calcualtion from section 5. These can be done by hand without too much difficulty, but we will include them here for completeness.

This solves the indifference equations for a general bet size a.

HalfRoundCutoffValues = Solve[2(y1−x1)==a(1−y1) &&1−x2==x2−y1 &&(2+a)x1==a(1−x2), {x1,x2,y1}]

This substitutes a couple epcific bet sizes. You can change the 1 or 2 to any positive number to see the cutoffs for that bet size.

HalfRoundCutoffValues/.{{a->1}}
HalfRoundCutoffValues/.{{a->2}}

P is the general payout function, in term of the cutoffs and the bet sizes.

P=−x1 y1+(1+a)x1(1−y1)+(x2−x1)(1−x1−x2)−(1−x2)y1−(1+a)(1-x2) (x2−y1)

“Payout” below is the payout at the Nash equilibrium, as a function of the bet size a.

Payout=Simplify[P/.HalfRoundCutoffValues]

This substitures to find the payout at a = 1, a = 2. Change the 1 or 2 to any positive nunber to see the payout for that bet size.

Payout/.{{a->1}}
Payout/.{{a->2}}

We now show calculations refered to in section 6. We also go a little further, working out the solution for all a and b, not just when a and b are similar.

We first consider the case a <= b

This solves the indifference equations for equilibrium L (so, in the case b >= a). If a and b are too far apart the answer can become invalid, since we assume y1 > x1 in setting up the equations. We will address that below.

LeftCutoffValues= Solve[-y2+(1+a)(1-y2)==1 && y1+(1-y3)==-(1+b) y1+(1+b)(1-y3) &&-(1+b) y1-(x3-y1)+(y3-x3)+(1+b)(1-y3)==-y2-(1+a)(x3-y2)+(1+a)(1-x3) &&-y2-(1+a)(x4-y2)+(1+a)(1-x4)==-(1+b)y1-(y3-y1)-(1+b)(x4-y3)+(1+b)(1-x4) && (x2-y1)-(1+b)(x3-x2)-(1+b)(1-x4)==-(x3-y1)-(1-x4)&&-x1-(x4-x3)==(1+a)x1-(1+a)(x4-x3) && (x3-x2)-(1-x4)==(1+b)(x3-x2)-(1+b)(1-x4),{x1,x2,x3,x4,y1,y2,y3}]

This lets you choose some bet values. Make sure to choose b >= a or your answer will be wrong.

LeftBetValues={{a->1,b->2}};
LeftCutoffValues/.LeftBetValues

This defines functions giving P1’s expected payout as a function of their hand if they commit to using each of the three possible behaviors:
PF corresponds to passing then, if P2 bets, folding. 
PC corresponds to passing then, if P2 bets, calling. 
B corresponds to betting. Since P2 cannot raise, there is no more choice.

PF[h_]=Piecewise[{{-1,h≤y1},{-1+2(h-y1),y1<h≤y3}, {-1+2(y3-y1),  h>y3}}]/.LeftCutoffValues/.LeftBetValues

PC[h_]= Piecewise[{{-(1+b)+b(y3-y1)+(2+2b)h,h≤y1},{-(1+b)+b(y3-y1)+(2+2b)y1+2(h-y1),y1<h≤y3}, {-(1+b)+b(y3-y1)+(2+2b)y1+2(y3-y1)+(2+2b)(h-y3),  h>y3}}]/.LeftCutoffValues/.LeftBetValues

B[h_]= Piecewise[{{y2- (1+a)(1-y2), h<y2},{y2- (1+a)(1-y2)+ (2+2a)(h-y2), h>=y2} }]/.LeftCutoffValues /.LeftBetValues

This plot shows that P1’s strategy
B with hand h<=x1 or with hand x3<=h<=x4
PC with hand x2<=h<=x3 or hand x4<=h<=1,
PF with hand x1<=h<=x2
has the property that, for any hand, they are using one of the behaviors with a maximal possible payout.

Plot[{PF[h],PC[h], B[h]}, {h,0,1}, GridLines->{{x1,x2,x3,x4},{}}]/.LeftCutoffValues/.LeftBetValues

This defines functions giving P2’s expected payout as a function of their hand if they commit to using each of the possible behaviors:
FP = fold if P1 bets, and pass if  P1 passes. 
FB = fold if P1 bets, and bet if  P1 passes. 
CP = call if P1 bets, and pass if  P1 passes. 
CB = call if P1 bets, and bet if  P1 passes.

FP[h_]=Piecewise[{{-1,h≤x1},{-1+2(h-x1),x1<h≤x3}, {-1+2(x3-x1), x3< h<=x4}, {-1+2(x3-x1)+2(h-x4), h>x4} }]/.LeftCutoffValues/.LeftBetValues
FB[h_]=Piecewise[{{-(x1+x4-x3)+(x2-x1)-(1+b)(x3-x2+1-x4),h≤x2},{-(x1+x4-x3)+(x2-x1)-(1+b)(x3-x2+1-x4) +(2+2b)(h-x2),x2<h≤x3},
{-(x1+x4-x3)+(x2-x1)-(1+b)(x3-x2+1-x4) +(2+2b)(x3-x2),x3<h≤x4}, {-(x1+x4-x3)+(x2-x1)-(1+b)(x3-x2+1-x4) +(2+2b)(x3-x2)+(2+2b)(h-x4),x4<h}
}]/.LeftCutoffValues/.LeftBetValues
CP[h_]=Piecewise[{{-(1+a)(x4-x3+x1)-(1-x4+x3-x1)+(2+2a)h,h≤x1},{-(1+a)(x4-x3+x1)-(1-x4+x3-x1)+(2+2a)x1+2(h-x1),x1<h≤x3}, {-(1+a)(x4-x3+x1)-(1-x4+x3-x1)+(2+2a)x1+2(x3-x1)+(2+2a)(h-x3),x3<h≤x4}, {-(1+a)(x4-x3+x1)-(1-x4+x3-x1)+(2+2a)x1+2(x3-x1)+(2+2a)(x4-x3)+2(h-x4),x4<h}}]/.LeftCutoffValues/.LeftBetValues
CB[h_]=Piecewise[{{-(1+a)(x4-x3+x1)-(1+b)(1-x4+x3-x2)+(x2-x1)+(2+2a)h,h≤x1},
{-(1+a)(x4-x3+x1)-(1+b)(1-x4+x3-x2)+(x2-x1)+(2+2a)x1,x1<h<=x2},
{-(1+a)(x4-x3+x1)-(1+b)(1-x4+x3-x2)+(x2-x1)+(2+2a)x1+(2+2b)(h-x2),x2<h≤x3},
{-(1+a)(x4-x3+x1)-(1+b)(1-x4+x3-x2)+(x2-x1)+(2+2a)x1+(2+2b)(x3-x2)+(2+2a)(h-x3),x3<h≤x4},
{-(1+a)(x4-x3+x1)-(1+b)(1-x4+x3-x2)+(x2-x1)+(2+2a)x1+(2+2b)(x3-x2)+(2+2a)(x4-x3)+(2+2b)(h-x4),x4<h}
}]/.LeftCutoffValues/.LeftBetValues

This plot shows that P2' s strategy
FB with hand h <= y1 
FP with hand y1 <= h <= y2 
CP with hand y2 <= h <= y3
CB with hand y3<=h<=1
has the property that, or any hand, they are using one of the behaviors with a maximal possible payout.

Plot[{FP[h], FB[h],CP[h],CB[h]}, {h,0,1}, GridLines->{{y1,y2,y3},{}}]/.LeftCutoffValues/.LeftBetValues

We have now established that this is a Nash equilibrium. You should be able to convince yourself that this works provided b >= a and the bluff cutoffs satisfy x1 <= y1.

This gives the payout at equilibrium.

Payout=-x1 y2+(1+a)x1(1-y2)+(x2-x1)y1-(1+b)(x3-x2)y1+(x3-x1)(y3-y1)-(x3-y1)^2+(x2-x1)(1-y3)+(1+b)(x3-x2)(1-y3)-(x4-x3)y2+(1+a)(x4-x3)(1-x4-x3+y2)-(1+b)(1-x4)y1-(1-x4)(y3-y1)-(1+b)(1-x4)(x4-y3)/.LeftCutoffValues/.LeftBetValues

We have now found the equilibrium provided the order of the cutoffs is as shown in the picture, so
x1<=y1, y1<=x2, y1<=y2, x2<=x3, y2<=x_3, x3<=y3, y3<=x4. The calucation below checks these graphically

D1=(x4-y3)/.LeftCutoffValues;
D2=(y3-x3)/.LeftCutoffValues;
D3=x3-y2/.LeftCutoffValues;
D4=x3-x2/.LeftCutoffValues;
D5=y2-y1/.LeftCutoffValues;
D6=x2-y1/.LeftCutoffValues;
D7=y1-x1/.LeftCutoffValues;
Solve[D1==0, {a}]
Solve[D2==0 , {a}]
Solve[D3==0 , {a}]
Solve[D4==0, {a}]
Solve[D5==0 , {a}]
Solve[D6==0 , {a}]
Solve[D7==0 , {a}]
Plot3D[D1,{b,0,4}, {a,0,b}]
Plot3D[D2,{b,0,4}, {a,0,b}]
Plot3D[D3,{b,0,4}, {a,0,b}]
Plot3D[D4,{b,0,4}, {a,0,b}]
Plot3D[D5,{b,0,4}, {a,0,b}]
Plot3D[D6,{b,0,4}, {a,0,b}]
Plot3D[D7,{b,0,4}, {a,0,b}]

These all are clearly positive except for D3 and D7 (this can also be shown algebraically). In fact, D3 is also positive, the flat area in the graph is an artifact, as shown by the following graph with restricted domain:

Plot3D[D3,{b,0,4}, {a,0,Min[b,0.3]}]

It can happen that D7 is negative, so y1 < x1, and that case is handled below. Notice that the relative position of x2 and y2 are not fixed. Changing the order of these two variables does not change the equations, so we do not consider it a different case.

We now consider the equilibrium R, so the case a >= b. We use the notation from the paper, except that x’1,x’2,x’3 are renamed simply x1,x2,x3.

This solves the indifference equations for equilibrium R, so in the case a >= b. It becomes invalid if b is very small, and we address that case below. We first find cutoffs as functions of bet sizes.

RightCutoffValues=Solve[-y2+(1+a)(1-y2)==1 && 
y1+(1-y3)==-(1+b) y1+(1+b)(1-y3) &&
-(1+b) y1-(y3-y1)-(1+b)(x3-y3)+(1+b)(1-x3)==-y2-(1+a)(x3-y2)+(1+a)(1-x3) &&(x2-y1)-(1+b)(x3-x2)==-(x3-y1)&&
-x1-(1-x3)==(1+a)x1-(1+a)(1-x3) && 
b (x3-y3)==b(y3-x2),
{x1,x2,x3,y1,y2,y3}]

This lets you choose bet sizes and dispalys the corresponding cutoffs. Make sure a >= b or else the calculation will give an incorrect answer. Some values appear to give problems for technical reasons. For instance, setting a=1,b=2 gives an error because some denominators are zero, by if you substitue before solving for the cutoffs there is no problem.

RightBetValues={{a->1, b->1.999999}};
RightCutoffValues/.RightBetValues

This defines functions that give P1' s expected payout as a function of their hand if they commit to using each of the three possible behaviors :
  PF corresponds to passing then, if P2 bets, folding. 
  PC corresponds to passing then, if P2 bets, calling. 
  B corresponds to betting. Since P2 cannot raise, there is no more choice.

PF[h_]=Piecewise[{{-1,h≤y1},{-1+2(h-y1),y1<h≤y3}, {-1+2(y3-y1),  h>y3}}]/.RightCutoffValues/.RightBetValues

PC[h_]= Piecewise[{{-(1+b)+b(y3-y1)+(2+2b)h,h≤y1},{-(1+b)+b(y3-y1)+(2+2b)y1+2(h-y1),y1<h≤y3}, {-(1+b)+b(y3-y1)+(2+2b)y1+2(y3-y1)+(2+2b)(h-y3),  h>y3}}]/.RightCutoffValues/.RightBetValues

B[h_]= Piecewise[{{y2- (1+a)(1-y2), h<y2},{y2- (1+a)(1-y2)+ (2+2a)(h-y2), h>=y2} }]/.RightCutoffValues /.RightBetValues

This plot shows that P1' s strategy
B with hand h <= x1 or with hand x3 <= h 
PF with hand x1 <= h <= x2
PC with hand x1 <= h <= x3 
has the property that, or any hand, they are using one of the behaviors with a maximal possible payout.

Plot[{PF[h],PC[h], B[h]}, {h,0,1}, GridLines->{{x1,x2,x3},{}}]/.RightCutoffValues/.RightBetValues

This defines functions that give P2’s expected payout as a function of their hand if they commit to using each of the possible behaviors:
FP = fold if P1 bets, and pass if  P1 passes. 
FB = fold if P1 bets, and bet if  P1 passes. 
CP = call if P1 bets, and pass if  P1 passes. 
CB = call if P1 bets, and bet if  P1 passes. 
Note that these function are different from in the b>=a case.

FP[h_]=Piecewise[{{-1,h≤x1},{-1+2(h-x1),x1<h≤x3}, {-1+2(x3-x1), x3< h} }]/.RightCutoffValues/.RightBetValues
FB[h_]=Piecewise[{{-(x1+1-x3)+(x2-x1)-(1+b)(x3-x2),h≤x2},{-(x1+1-x3)+(x2-x1)-(1+b)(x3-x2) +(2+2b)(h-x2),x2<h≤x3},
{-(x1+1-x3)+(x2-x1)-(1+b)(x3-x2) +(2+2b)(x3-x2),x2<h}
}]/.RightCutoffValues/.RightBetValues
CP[h_]=Piecewise[{{-(1+a)(1-x3+x1)-(x3-x1)+(2+2a)h,h≤x1},{-(1+a)(1-x3+x1)-(x3-x1)+(2+2a)x1+2(h-x1),x1<h≤x3}, {-(1+a)(1-x3+x1)-(x3-x1)+(2+2a)x1+2(x3-x1)+(2+2a)(h-x3),x3<h}}]/.RightCutoffValues/.RightBetValues
CB[h_]=Piecewise[{{-(1+a)(1-x3+x1)-(1+b)(x3-x2)+(x2-x1)+(2+2a)h,h≤x1},
{-(1+a)(1-x3+x1)-(1+b)(x3-x2)+(x2-x1)+(2+2a)x1,x1<h<=x2},
{-(1+a)(1-x3+x1)-(1+b)(x3-x2)+(x2-x1)+(2+2a)x1+(2+2b)(h-x2),x2<h≤x3},
{-(1+a)(1-x3+x1)-(1+b)(x3-x2)+(x2-x1)+(2+2a)x1+(2+2b)(x3-x2)+(2+2a) (h-x3), x3<h}
}]/.RightCutoffValues/.RightBetValues

This plot shows that P2' s strategy
FB with hand h <= y1 
FP with hand y1 <= h <= y2 
CP with hand y2 <= h <= y3
CB with hand y3 <= h <= 1
has the property that, or any hand, they are using one of the behaviors with a maximal possible payout.

Plot[{FP[h], FB[h],CP[h],CB[h]}, {h,0,1}, GridLines->{{y1,y2,y3},{}}]/.RightCutoffValues/.RightBetValues

This gives the payout to P2 of this Nash equilibrium, which is valid in some region including all cases a = b and a slightly bigger, but not b slightly bigger.

Payout=-x1 y2+(1+a)x1(1-y2)+(x2-x1)y1-(1+b)(x3-x2)y1-(1-x3)y2-(1+a)(x3-y2)(1-x3)+(1+b)(x3-x2)(1-y3)-(1+b)(x3-y3)^2+(x2-x1)(1-y3)-(y3-y1)(x3-y3-y1+x1)/.RightCutoffValues/.RightBetValues

This has found the equilibrium provided the order of the cutoffs is as shown in the picture, so
x1 <= y1, y1 <= x2, y1 <= y2, x2 <= y3, y2 <= y3, y3<=x3. The calucation below checks these graphically

Eq1=x3-y3/.RightCutoffValues

D1=x3-y3/.RightCutoffValues;
D2=x3-y2/.RightCutoffValues;
D3=y3-x2/.RightCutoffValues;
D4=y2-y1/.RightCutoffValues;
D5=x2-y1/.RightCutoffValues;
D6=y1-x1/.RightCutoffValues;
Solve[D1==0, {a}]
Solve[D2==0 , {a}]
Solve[D3==0 , {a}]
Solve[D4==0, {a}]
Solve[D5==0 , {a}]
Solve[D6==0 , {a}]
Plot3D[D1,{a,0,4}, {b,0,a}]
Plot3D[D2,{a,0,4}, {b,0,a}]
Plot3D[D3,{a,0,4}, {b,0,a}]
Plot3D[D4,{a,0,4}, {b,0,a}]
Plot3D[D5,{a,0,4}, {b,0,a}]
Plot3D[D6,{a,0,4}, {b,0,a}]

These are all clearly positive except D6. Note that the relative positions of x2, y2 and of y3,y2 are free; these do not change the equations so, although the pictures look a little different, we don’t consider these different cases. There is however a difference case for when D6 is negative.

As above, the two types of Nash equilibrium (L) and (R) do not cover all cases: when a and b are too far appart, it can happen that at equilibrium P1 bluffs with better hands than P2 bluffs with, and the equations. We now solve for when that happens, and find the corresponding equilibria.

We first consider L (b>a). We need to solve for where P1 starts wanting to bluff more often than P2. If a is similar to b then, by direct calculation, P1 bluffs less often than P2. Hence if there is a problematic region there has to be a values 0<a<b where x1 =y1 (the bluff cutoffs coincide). So, we solve the indifference equations for when these two values coincide, looking for a as a function of b:

Solve[-y2+(1+a)(1-y2)==1 && y1+(1-y3)==-(1+b) y1+(1+b)(1-y3) &&-(1+b) y1-(x3-y1)+(y3-x3)+(1+b)(1-y3)==-y2-(1+a)(x3-y2)+(1+a)(1-x3) &&-y2-(1+a)(x4-y2)+(1+a)(1-x4)==-(1+b)y1-(y3-y1)-(1+b)(x4-y3)+(1+b)(1-x4) && (x2-y1)-(1+b)(x3-x2)-(1+b)(1-x4)==-(x3-y1)-(1-x4)&&-x1-(x4-x3)==(1+a)x1-(1+a)(x4-x3) && (x3-x2)-(1-x4)==(1+b)(x3-x2)-(1+b)(1-x4)&& x1==y1,{a,x1,x2, x3,x4,y1,y2,y3}]

Since (1/2) (3 b+(Sqrt[b]) (Sqrt[4+5 b]))> b,  the only solution is a= (1/2) (3 b-(Sqrt[b]) (Sqrt[4+5 b])). For b≤1, this is negative, so in those cases this equalibrium works for all a<=b. For b>=1 one can directly check that in the limit as a->0 the bluff cutoffs do in fact reverse. Then the equilibrium does look different, and the following calculates the cutoff values:

This solves the new indifference equations, which are valid for a<=(1/2) (3 b-(Sqrt[b]) (Sqrt[4+5 b]))

LeftCutoffVals2=Solve[-y2+(1+a)(1-y2)==1-x1+y1 && y1+(1-y3)==-(1+b) y1+(1+b)(1-y3) &&-(1+b) y1-(x3-y1)+(y3-x3)+(1+b)(1-y3)==-y2-(1+a)(x3-y2)+(1+a)(1-x3) &&-y2-(1+a)(x4-y2)+(1+a)(1-x4)==-(1+b)y1-(y3-y1)-(1+b)(x4-y3)+(1+b)(1-x4) && (x2-x1)-(1+b)(x3-x2)-(1+b)(1-x4)==-(x3-x1)-(1-x4)&&-x1-(x4-x3)==(1+a)x1-(1+a)(x4-x3) && (x3-x2)-(1-x4)==(1+b)(x3-x2)-(1+b)(1-x4),{x1,x2,x3,x4,y1,y2,y3}];

This lets you substitute and see the actual cutoff values. Make sure a>=b≥(1/8) (8 a+(a^2)+(a^3)-(a^(3/2)) (Sqrt[16+17 a+2 (a^2)+(a^3)])), or else it will give somethng incorrect.

This substitues a particular pair a and b that is in this range.

LeftBetVals2={{a->1/10,b->10}};
LeftCutoffVals2/.LeftBetVals2
{{{x1->0.03319345279529047`,x2->0.25798015154829856`,x3->0.2804588214235994`,x4->0.9775213301246996`,y1->0.02454107913525984`,y2->0.051739225552395546`,y3->0.9705507050376905`}}}

This solves for the cutoff where the equilibrium R (where a>=b) becomes invalid because b is too small. This time b=0 will always be invalid, since then P2 will never want to bluff, and b=a it will always be valid. So, we must again look for a values between 0 and b where x1=y1. The system below finds these:

Solve[-y2+(1+a)(1-y2)==1 && 
y1+(1-y3)==-(1+b) y1+(1+b)(1-y3) &&
-(1+b) y1-(y3-y1)-(1+b)(x3-y3)+(1+b)(1-x3)==-y2-(1+a)(x3-y2)+(1+a)(1-x3) &&(x2-y1)-(1+b)(x3-x2)==-(x3-y1)&&
-x1-(1-x3)==(1+a)x1-(1+a)(1-x3) && 
b (x3-y3)==b(y3-x2) && x1==y1,
{b,x1,x2,x3,y1,y2,y3}]

The cutoff is b>= (1/8) (8 a+(a^2)+(a^3)-(a^(3/2)) (Sqrt[16+17 a+2 (a^2)+(a^3)])). This is a fairly serious restriction for  small values of a. For instance, if a=0.1, then the equilibrium R is only valid for 0.084735<=b<=0.1. We now solve for the new cutoffs for values of b<a where R is invalid:

RightCutoffValues2=Solve[-y2+(1+a)(1-y2)==1-2(x1-y1) && 
y1+(1-y3)==-(1+b) y1+(1+b)(1-y3) &&
-(1+b) y1-(y3-y1)-(1+b)(x3-y3)+(1+b)(1-x3)==-y2-(1+a)(x3-y2)+(1+a)(1-x3) &&(x2-x1)-(1+b)(x3-x2)==-(x3-x1)&&
-x1-(1-x3)==(1+a)x1-(1+a)(1-x3) && 
b (x3-y3)==b(y3-x2),
{x1,x2,x3,y1,y2,y3}];

This lets you substitue bet sizes to see the actual cutoffs. Make sure you chooses values where b<=a and b<=(1/8) (8 a+(a^2)+(a^3)-(a^(3/2)) (Sqrt[16+17 a+2 (a^2)+(a^3)])).

This substitues a particular pair a and b that is in this range.

RightBetValues2={{a->3,b->0.626136}};
RightCutoffValues2/.RightBetValues2