BlackJack is a classic Casino card game. A detailed explanation is given here. When the game starts you (the player) have two cards in front of you and the dealer has one, all visible. You now have to decide to either take another card or not. Your clearly should do whatever gives you the better chance of winning. Say you have a King and a 3, for a total of 13, and the dealer shows an 8. Write a simulation that finds the probabilities of either taking another card or staying, and then winning the game. To simplify you will only take one more card, if any.
Use the following dealer rules: dealer takes another card if his total is at most 15 (“stay on 16”). An Ace counts as 11 if that puts the dealer to 16-21, otherwise it counts as 1.
Here is the answer:
take.one.card.or.stay(you=13, dealer=8, B=1e4)
## Stay Take Card
## 0.1705 0.2957
so the probability of winning when taking a card is about 30% but when staying it is only 17%, so you should take a card!
Use your routine to find the answer when you have a 10 and the dealer shows a 7.
Say the floor in your house is made of square tiles of one foot by one foot. You have a stick that is 0.5 feet long. If you drop the stick on the floor, what is the probability that it will land entirely within one tile? For example, in the following picture the red stick is entirely inside a tile but the blue one is not. Write a simulation routine in R to find the answer.