## Transcribed Text

Description
The game Monopoly is played on board with 40 squares, set up as shown below
GO
A1
CC1
A2
T1
RR1
B1
CH1
B2
B3
JAII
H2
C1
T2
UT1
H1
C2
CH3
C3
RR4
RR2
G3
D1
CC3
CC2
G2
D2
G1
D3
G2J
F3
UT2
F1
F1
RR3
E3
E2
CH2
El
FP
Players begin the game on the GO square. On each turn, the player rolls two 6-sided dice. The sum of the
dice determines the number of squares they advance (in clockwise direction) on that turn.
Without any further rules. we would expect players to visit each square with equal probability However
landing on G2J (go to jail), CC (community chest) and CH (chance) changes this distribution. When
a
player lands on G2J, they must immediately move tothe JAIL square.
At the beginning of the game, the CC and CH cards are shuffled When player lands on CC or CH they
take card from the top of the respective pile and, after following the instructions. returned to
the
bottom of the pile. There are 16 cards each pile but for this assignment are only concerned with
cards
that order movement Any card not concerned with movement will be ignored and the player will remain
on the CC/CE square. The relevant card: are:
Community Chest (2/16)
Advance GO
2. Goto JAIL
Chance(10/16)
Advance GO
2. GotoJAIL
3. Goto( C1
4. Goto E3
5. GotoH2
6. GotoRi
7. Goto next RR (railroad)
8 Goto next RR
9 Goto next UT (utility)
10. Goback 3 squares
In
addition to G2J and CC/CH if player rolls doubles con three consecutive turns, they proceed directly
to
jail.
A double" is : roll where the two dice are equal, such as rolling 2 fives or sixes.
The goal of this assignment is to estimate the long- term prohabilities of landing on each square That is to
compute for each square the probabilty that the player will end turn that square if they play the game for
infinitely many turns.
This assignment is based on Project Euler exercise
Questions
Use R to find answers to all of the following questions (that is. don't do any by hand by point-and-click)
Save your code in an script.
1.
Write function simulate _monopoly() that simulates turns by player in game of Monopoly
using two d-sided dice The inputs yoyr function should ben and d. The output of your
function
should bez length n+ vector of positions, encoded as numbers from to 39
2. Writeafunction est imate monopoly< that uses your simulation toestimate the long term probabilitie
of ending turn on each Monopoly square. What are the most likely squares to end turn on if you
play Monopoly with 6-sided dice? What you play with 4-sided dice? Display graphically the long-term
probabilities for 3. 4.5. and 6-sided dice.
3.
Usse 000 simulations with n = 10. 000 turns each to estimate the standard error for the long-term
probability of ending turn jail.
4.
Use the non-parametric bootstrap with = 1,000 samples from simulation of 10,000
turns
to
estimate the standard error for the long-term probability of ending turn jail.
(a) How does the bocestrap estimate compare to the simulation estimate? Which do you think is more
accurate? Explain
(b) Which faster to compute: the bootstrap estimate or the simulation estimate? Explain why there
difference.
5.
Display graphically the standard errors for the long-term probabilities for 3, 4.5. and 6-sided dice (use
the same settings you used in question 2). Discuss why some probabilities have much larger standard
errors than others
6. What happens to the standard errors for the long-term probability estimates as n increases? Why does
this happen?

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

s1 <- c("GO","A1","CC1","A2","T1","RR1","B1","CH1","B2","B3","JAIL","C1","UT1","C2","C3","RR2","D1","CC2","D2","D3")

s2 <- c("FP","E1","CH2","E2","E3","RR3","F1","F2","UT2","F3","G2J","G1","G2","CC3","G3","RR4","CH3","H1","T2","H2")

squares <- c(s1,s2)

CHcard <- function(x,i,deck) {

drawn <- deck[(i %% 16)+1]

if (drawn<=6) {c(0,10,11,24,39,5)[drawn]}

else if (drawn==7 | drawn==8) {(ceiling(0.1*x+0.5)*2-1)*5 %% 40}

else if (drawn==9) {if (x>12) {12} else {28}}

else if (drawn==10) {(x-3) %% 40}

else {x}

}

CCcard <- function(x,i,deck) {

drawn <- deck[(i %% 16)+1]

if (drawn<=2) {c(0,10)[drawn]}

else {x}

}

next_real <- function(x,cc.i,ch.i,cc.deck,ch.deck) {

if (x==7 | x==22 | x==36) {CHcard(x,ch.i,ch.deck)}

else if (x==2 | x==17 | x==33) {CCcard(x,cc.i,cc.deck)}

else if (x==30) {10}

else{x}

}

roll <- function(d) {

rr <- floor(runif(6,min=1,max=d+1))

add<-c(rr[1]+rr[2],rr[3]+rr[4],rr[5]+rr[6])

check <-c(rr[1]==rr[2],rr[3]==rr[4],rr[5]==rr[6])

if (sum(check)==3) {0}

else {add[check==FALSE][1]}

}

simulate_monopoly <- function(n,d){

seq <- c(0)

CC.i <- 1

CH.i <- 1

CCdeck <- sample(1:16)

CHdeck <- sample(1:16)

for (i in 2:(n+1)){

if (roll(d)==0) {seq[i] = 10}

else {

next_tntve = (seq[i-1] + roll(d)) %% 40...