de24af86722268013b9f4ca29c6219e1.ppt
- Количество слайдов: 9
Stat 35 b: Introduction to Probability with Applications to Poker Outline for the day: 1. Collect HW 3, midterm, hand out hw 4. Final exam is Wed Sept 2! No class Sept 7 & 9. 2. Project B teams 3. Project B example 4. Bayes Rule 5. Gold vs Farha Computer Project B will be due this Saturday at 8 pm! u
Proj. B example (ZELDA) See www. stat. ucla. edu/~frederic/35 b/sum 09/project. Bexamples. txt zelda = function(numattable 1, crds 1, board 1, round 1, currentbet, mychips 1, pot 1, roundbets, blinds 1, chips 1, ind 1, dealer 1, tablesleft){ a 1 = 0 ## how much I'm gonna end up betting. Note that the default is zero. a 2 = min(mychips 1, currentbet) ## how much it costs to call if(round 1 == 1){ ## pre-flop: ## AK: Make a big raise if nobody has yet. Otherwise call. ## AQ: call a small raise, or make one if nobody has yet. ## AJ, AT, KQ, KJ, QJ: call a tiny raise. ## A 9, KT, K 9, QT, JT, T 9: call a tiny raise if in late position (within 2 of the dealer). ## Suited A 2 -AJ or 22 -99: call a small raise. ## TT-KK: make a huge raise. If someone's raised huge already, then go all in. ## AA: make a small raise. If there's been a raise already, then double how much it is to you. a 3 = 2*blinds 1+1 ## how much a tiny raise would be a 4 = 4*blinds 1+1 ## how much a small raise would be a 5 = max(8*blinds 1, mychips 1/4)+1 ## how much a big raise would be a 6 = max(12*blinds 1, mychips 1/2)+1 ## how much a huge raise would be a 7 = dealer 1 - ind 1 if(a 7 < -. 5) a 7 = a 7 + numattable 1 ## your position: a 7 = how many hands til you're dealer if((crds 1[1, 1] == 14) && (crds 1[2, 1] == 13)){ a 1 = max(a 2, a 5) }
if((crds 1[1, 1] == 14) && (crds 1[2, 1] == 12)){ if(a 2 < a 4){ a 1 = a 4 } else if(a 2 > a 5){ a 1 = 0 } else a 1 = a 2 } if(((crds 1[1, 1] == 14) && ((crds 1[2, 1] < 11. 5) && (crds 1[2, 1] > 9. 5))) || ((crds 1[1, 1] == 13) && (crds 1[2, 1] > 10. 5)) || ((crds 1[1, 1] == 12) && (crds 1[2, 1] == 11))){ if(a 2 < a 3) a 1 = a 2 } if(((crds 1[1, 1] == 14) && (crds 1[2, 1] == 9)) || ((crds 1[1, 1] == 13) && ((crds 1[2, 1] == 10) || (crds 1[2, 1] == 9))) || ((crds 1[1, 1] == 12) && (crds 1[2, 1] == 10)) || ((crds 1[1, 1] == 11) && (crds 1[2, 1] == 10)) || ((crds 1[1, 1] == 10) && (crds 1[2, 2] == 9))){ if((a 2 < a 3) && (a 7<2. 5)) a 1 = a 2 } if((crds 1[1, 2] == crds 1[2, 2]) && (crds 1[1, 1] == 14) && (crds 1[2, 1] < 11. 5)){ if(a 2<a 4) a 1 = a 2 ## Note: this trumps the previous section, since it comes later in the code. }
if((crds 1[1, 1] == crds 1[2, 1])){ ## pairs: if(crds 1[1, 1] < 9. 5){ if(a 2 < a 4) a 1 = a 2 } else if(crds 1[1, 1] < 13. 5){ if(a 2<a 5) a 1 = a 5 else a 1 = mychips 1 } else { if(a 2 < blinds 1 +. 5) a 1 = a 4 else a 1 = min(2*a 2, mychips 1) }} } if(round 1 == 2){ ## post-flop: ## If there's a pair on the board and you don't have a set, then check/call up to small bet. ## Same thing if there's 3 -of-a-kind on the board and you don't have a full house or more. ## If you have top pair or an overpair or two pairs or a set, make a big bet (call any bigger bet). ## Otherwise, if nobody's made even a small bet yet, then with prob. 20% make a big bluff bet. ## If you're the last to decide and nobody's bet yet, then increase this prob. to 50%. ## If you have an inside straight draw or flush draw then make a small bet (call any bigger bet). ## If you have a straight or better, then just call. ## Otherwise fold. a 5 = min(sum(roundbets[, 1]), mychips 1) ## how much big bet would be (prev round's pot size) a 6 = min(. 5*sum(roundbets[, 1]), mychips 1) ## how much a small bet would be x = handeval(c(crds 1[1: 2, 1], board 1[1: 3, 1]), c(crds 1[1: 2, 2], board 1[1: 3, 2])) ## what you have x 1 = handeval(c(board 1[1: 3, 1]), c(board 1[1: 3, 2])) ## what's on the board y = straightdraw 1(c(crds 1[1: 2, 1], board 1[1: 3, 1]))
z = flushdraw 1(c(crds 1[1: 2, 2], board 1[1: 3, 2])) topcard 1 = max(board 1[1: 3, 1]) a 7 = runif(1) ## random number uniformly distributed between 0 and 1 a 8 = (1: numattable 1)[roundbets[, 1] == roundbets[ind 1, 1]] ## others who can still bet with you ## The next 5 lines may seem weird, but the purpose is explained in the next comment: a 9 = a 8 - dealer 1 for(i in 1: length(a 9)) if(a 9[i]<. 5) a 9[i] = a 9[i] + numattable 1 a 10 = ind 1 - dealer 1 if(a 10 <. 5) a 10 = a 10 + numattable 1 a 11 = 2*(a 10 == max(a 9)) ## So a 11 = 2 if you're last to decide; otherwise a 11 = 0. if((x 1 > 1000000) && (x < 3000000)){ if(a 2 < a 6) a 1 = a 2 } else if((x 1 > 3000000) && (x < 6000000)){ if(a 2 < a 6) a 1 = a 2 } else if(x > 1000000 + 15^3*topcard 1){ a 1 = max(a 5, a 2) } else if((a 2 < a 6) && ((a 7 <. 20) || ((a 7 <. 50) && (a 11>1)))){ a 1 = a 6 } if((y == 4) || (z == 4)) a 1 = max(a 6, a 2) if(x > 4000000) a 1 = a 2 }
if(round 1 == 3){ ## after turn: ## If there's a pair on the board and you don't have a set, then check/call up to small bet. ## Same thing if there's 3 -of-a-kind on the board and you don't have a full house or more. ## Otherwise, if you have top pair or better, go all in. ## If you had top pair or overpair but now don't, then check/call a medium bet but fold to more. ## If you have an inside straight draw or flush draw then check/call a medium bet as well. ## Otherwise check/fold. a 6 = min(1/3*sum(roundbets[, 1: 2]), mychips 1) ## small bet (1/3 of prev round's pot size) a 5 = min(. 75*sum(roundbets[, 1: 2]), mychips 1) ## medium bet (3/4 of prev round's pot size) x = handeval(c(crds 1[1: 2, 1], board 1[1: 4, 1]), c(crds 1[1: 2, 2], board 1[1: 4, 2])) ## what you have x 1 = handeval(c(board 1[1: 4, 1]), c(board 1[1: 4, 2])) ## what's on the board y = straightdraw 1(c(crds 1[1: 2, 1], board 1[1: 4, 1])) z = flushdraw 1(c(crds 1[1: 2, 2], board 1[1: 4, 2])) topcard 1 = max(board 1[1: 4, 1]) oldtopcard 1 = max(board 1[1: 3, 1]) if((x 1 > 1000000) && (x < 3000000) && (a 2 < a 6)) a 1 = a 2 if((x 1 > 3000000) && (x < 6000000)) && (a 2 < a 6)) a 1 = a 2 if(x > 1000000 + 15^3*topcard 1) a 1 = mychips 1 if((x > 1000000 + 15^3*oldtopcard 1) && (a 2 < a 5)) a 1 = a 2 if((y == 4) || (z == 4)){ if(a 2 < a 5) a 1 = a 2 } }
if(round 1 == 4){ ## after river: ## If there's a pair on the board and you don't have a set, then check/call up to small bet. ## Same thing if there's 3 -of-a-kind on the board and you don't have a full house or more. ## Otherwise, if you have two pairs or better, go all in. ## If you have one pair, then check/call a small bet. ## With nothing, go all-in with probability 10%; otherwise check/fold. a 6 =. 45+runif(1)/10 ## random number between. 45 and. 55 a 5 = min(a 6*sum(roundbets[, 1: 3]), mychips 1) ## small bet~ 1/2 of pot size; varies randomly x = handeval(c(crds 1[1: 2, 1], board 1[1: 5, 1]), c(crds 1[1: 2, 2], board 1[1: 5, 2])) x 1 = handeval(c(board 1[1: 5, 1]), c(board 1[1: 5, 2])) ## what's on the board if((x 1 > 1000000) && (x < 3000000) && (a 2 < a 5)) a 1 = a 2 } else if((x 1 > 3000000) && (x < 6000000)){ if(a 2 < a 5) a 1 = a 2 } else if(x > 2000000){ a 1 = mychips 1 } else if(x > 1000000){ if(a 2 < a 5) a 1 = a 2 } else if(runif(1)<. 10){ a 1 = mychips 1 } } round(a 1) } ## end of zelda
Bayes’ Rule Say B 1, B 2 , Bn are disjoint events and that exactly one of them must occur. Suppose you want P(B 1 | A), but you only know P(A | B 1 ), P(A | B 2 ), etc. Suppose you also know P(B 1), P(B 2), …, P(Bn). Bayes’ Rule: If B 1 , …, Bn are disjoint events with P(B 1 or … or Bn) = 1, then P(Bi | A) = P(A | Bi ) * P(Bi) ÷ [ ∑P(A | Bj)P(Bj)]. Why? Recall: P(X | Y) = P(X & Y) ÷ P(Y). So P(X & Y) = P(X | Y) * P(Y). P(B 1 | A) = P(A & B 1 ) ÷ P(A) = P(A & B 1 ) ÷ [ P(A & B 1) + P(A & B 2) + … + P(A & Bn) ] = P(A | B 1 ) * P(B 1) ÷ [ P(A | B 1)P(B 1) + P(A | B 2)P(B 2) + … + P(A & Bn)P(Bn) ] …. Gold vs. Farha.
Gold vs. Farha Gold: 10 u 7 • Farha: Qu Q Flop: 9 u 8 7 Who really is the favorite (ignoring all other players’ cards)? Gold’s outs: J, 6, 10, 7. (4 + 3 + 2 = 13 outs, 32 non-outs) P(Gold wins) = P(Out or Jx [x ≠ 10] or 6 x or 10 y [y≠Q, 9, 8] or 7 z [z≠Q]) = [choose(13, 2) + 4*28 + 4*32 + 3*24 + 2*30] ÷ choose(45, 2) = 450 ÷ 990 = 45. 45%. • What would you guess Gold had? Say he’d do that 50% of the time with a draw, 100% of the time with an overpair, and 90% of the time with two pairs. (and that’s it) Using Bayes’ rule, P(Gold has a DRAW | Gold raises ALL-IN) =. [P(all-in | draw) * P(draw)] [P(all-in | draw) P(draw)] + [P(all-in | overpair) P(overpair)] + [P(all-in | 2 pairs) P(2 pairs)] = [50% * P(draw)] ÷ [50% * P(draw)] + [100% * P(overpair)] + [90% * P(2 pairs)] .
de24af86722268013b9f4ca29c6219e1.ppt