R function Function is a wrapper that allows us to write code in modules Back to Handout Homework: Create a function for drunken sailor – Inputs: Number of steps, probability for step up – Output: path of the sailor Evaluate the function, print and plot the path – 25 steps with prob.3 and 32 steps with prob.8
Counting cards Basic counting rule: – +1 for 2-6 – 0 for 7-9 – -1for 10-A We only start playing when the count becomes high (typically 17)
Homework Modify the R code to use soft 17. – Always stop if 18 or higher – Stop on 17 unless there is A counted as 11 (in which case dealer hit himself/herself) What do you expect to happen?
Counting cards Basic counting rule: – +1 for 2-6 – 0 for 7-9 – -1for 10-A We will again use R to compute the probability of dealer going bust. – We only start playing when the count becomes 17 R code available in resource section of sakai
Estimated Results – Count +17 Quote from wikipedia: – “Another aspect of the probability of card counting is that, at higher counts, the player's probability of winning a hand is only slightly changed and still below 50%. The player's edge over the house on such hands does not come from the player's probability of winning the hands. Instead it comes from the increased probability of blackjacks, increased gain and benefit from doubling, splitting and surrender, and the insurance side bet, which becomes profitable at high counts.” 1718192021BJbust Only +170.1380.1320.1280.198.064.0620.278 plain0.1460.1380.1350.1760.0740.0480.283