Question: Use and edit the code below to repeat the snakes and ladder game for a single player and work out how many turns it takes

Use and edit the code below to repeat the snakes and ladder game for a single player and work out how many turns it takes on average to reach the 100th square. Repeat this simulation 500 times and plot the distribution of the number of turns taken to reach the 100th square. Explain what you observe in the distribution briefly
set.seed(42)
# Game parameters
max_turns <-500
max_position <-100
n_sides_die <-10
position <-4
positions_over_time <- numeric(max_turns)
# define the snakes and ladders keys on the board (from==to)
ladders <- list('1'=38,'4'=14,'9'=31,'21'=42,'28'=84,'36'=44,'51'=67,'71'=91,'80'=100)
snakes <- list('15'=6,'48'=26,'49'=11,'56'=53,'62'=19,'64'=60,'87'=24,'93'=73,'95'=75,'98'=78)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!