## NA25 SC – Lab 7 – Monte Carlo simulation

We use the game tree to calculate the exact probability of getting a Royal Match starting from a single, “fresh” shoe with exactly one deck of 52 cards, namely:

4/52        → Probability of getting a King (Kx) as player’s first card of some suite x

(1 – 1/51)        → Probability of not getting a Queen (Qx) of same suit x as dealer’s hole card

1/50        → Probability of getting Queen (Qx) as player’s second card of the same suit

We have to multiply these probabilities. Furthermore, we have to multiply the result by two since there are two winning pathways. See Figure 1.

Monte Carlo simulation is an alternative approach that similarly uses game theory. It’s a powerful tool with the advantage that it can evaluate complex situations in which exact probabilities may not be known or they are problematic to assess. Its chief downside is the error is proportional to 1/√N where N is the number of simulations. The Monte Carlo algorithm pseudocode for Royal Match is given below.

 Zero the count Create a one-deck shoe. Do N times: Initialized the shoe. Draw cards from the shoe: One for YOU One for DEALER One for YOU If YOU have a Royal Match, increment the count by one. End-Do P = count / N odds = (1-P) / P

Figure 2. Monte Carlo algorithm for Royal Match

Part I – Answer these questions.

There are two kinds of royal matches: the Easy Match and the Royal Match. We are concerned only with the Royal Match, that is, s uited King and Queen.

Put the answers in the shell.

1. Go to the Wizard of Odds and get the exact probability for the Royal Match. What is it?
2. Does the combinatorial calculation for Royal Match agree with the Wizard of Odds? Show the math.
3. Is the Royal Match a fair bet? If yes, why? If no, why not?
4. What is the appropriate Royal Match payout for a \$5 side bet if it is fair?
5. If you estimate the Royal Match probability to the accuracy reported by the Wizard of Odds, what’s the order of number of games you will need to simulate? For example, if you needed one place of accuracy or 0.1 = 1/10 = 1/√100, that is, O(100) simulations.

Part II – Estimate the Royal Match odds using Monte Carlo simulation.

1. Open NetBeans and Charlie.
1. Open the log4j.properties file and comment out  this line:

log4j.rootLogger = DEBUG, FILE, stdout

This disables part of the logging which speeds up the simulations.

2. Clean and rebuild Charlie.
1. Create a new Java Maven project called, “SideBetOdds”.
1. Copy-paste the Charlie dependency entry in the MyCharliePlugins pom.xml to this project’s pom.xml. (It may also be necessary to copy-paste the sl4j dependency.)
2. Copy-paste the log4j dependency from the Charlie pom.xml to the pom.xml of this project.
1. Add to the SideBetOdds project a new Java class, RoyalMatch.java.
1. Use Monte Carlo simulation for 100,000 games to estimate the probability of winning the Royal Match.
2. Output the probability and the odds as:

Royal Match prob = 0.###### odds = ###:1

where “#” is a digit.

Note: Verify the output is correct based on what you know about the Royal Match.

3. Copy-paste the output to a file, royal-match-output.txt.

Part II – Estimate the Exactly 13 odds using Monte Carlo simulation.

Exactly 13 wins if the first two player cards are exactly 13, e.g., 6+7, 5+8, etc. (According to the Wizard of Odds, Aces count as one.) As you might imagine we really need Monte Carlo simulation because the combinatorics are not easily analyzed in this case.

1. Create a new Java class called, Exactly13.java.
1. Use Monte Carlo simulation for 100,000 simulations to estimate the probability of winning Exactly 13. Use the Royal Match algorithm as a guide.
2. Output the probability and the odds as:

Exactly 13 prob = 0.###### odds = ###:1

where “#” is a digit.

Note: Verify the probability makes sense and whether it is a fair bet according to the Wizard of Odds.

3. Copy-paste the output to a file, exactly13-output.txt.

Deliverables

1. Write in the assignment shell answers to all the questions: Part I.1-5. 