Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 Here is a picture of the official game board. 99 96 94 95 7 93 83 84 8.8 82 87 90 85 89

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Part 1 Here is a picture of the official game board. 99 96 94 95 7 93 83 84 8.8 82 87 90 85 89 78 73 79 74 17 72 1:62 64 51 49 63 65 66 67 50 59 58 57 54 53 55 51 57 42- 47 43 45 48 44 50 38 36 32 131 37 35 35 33 34 21 22 23 24 25 26 27 29 30 20 15 17 13 17 In the Rmd file, create a single list object called board where you store the features of the game board in R. You will need to figure out how to represent and store the features of the game board in R. You'll need to keep track of chutes, ladders, and the dimensions of the board.Part 2 In the script file, create a function called show_board () that takes one argument board (the object you created in part 1). The function will then produce a plot showing the board. The plot will produce a square grid with the spaces properly numbered. Note that the numbers reverse directions each row. Chutes will be represented with red arrows, and ladders should be represented with green arrows (lud = 2). You may alternatively consider red and blue arrows (for colorblind accessibility). Try to maintain the aspect ratio for your board (Le., each tile should be a square). 100 99 98 97 96 95 94 93 92 91 81 82 85 87 8 8 89 90 80 79 77 76 74 72 71 61 62 63 -64 65 66 68 69 70 59 58 57 50 52 51 41 43 46 47 48 49 50 40 39 37 36 35 34 33 32 21 20 23 25 27 28 20 30 20 18 17 16 15 13 12 2 3 7 8 10 You should be able to achieve this using base graphics in R. You are not limited to using only the following functions, but I was able to create my game board with only: plot . new (), plot . window(), segments(), arrows (), and text (). The function show_board () must be flexible enough to produce boards with different specifications, as seen in Part 3. You will not be given a board specification that is not rectangular. The smallest possible board size that might be tested is 2 x 2, and the largest that might be tested is 12 x 12. In the Rid file, call the show_board() function to produce the plot of the game board.Part 3 This part is to test that your function is flexible to represent different boards. Create another object in the Rad file called miniboardl to represent another board with the following properties: . Dimensions: 6 col x 7 row . ladders: 1 to 23, 9 to 27, 20 to 31, 33 to 41 . chutes: 16 to 6, 30 to 18, 35 to 24, 40 to 26 In the Rid file, call the show_board () function to produce the plot of the miniboardl. Create another object in the Rid file called miniboard2 to represent another board with the following properties: . Dimensions: 7 col x 9 rows . ladders: 9 to 22, 13 to 30, 24 to 37, 29 to 41, 33 to 39, 43 to 54 . chutes: 16 to 3, 31 to 15, 35 to 21, 62 to 48 In the Rand file, call the show_board () function to produce the plot of the miniboard2. Create another object in the Rad file called miniboard3 to represent another board with the following properties: . Dimensions: 8 col x 9 rows . ladders: none . chutes: none In the Rind file, call the show_board () function to produce the plot of the miniboard3.Part 4 Create a function play_solo () that will simulate a game of chutes and ladders for one player on the full 10 x 10 board from parts 1 and 2. For each game, a player starts at position 0. You must land exactly on 100 to win-if you go over, you don't move and take another turn. The function will accept the following arguments: board to represent the board (the same argument used in show_board ()) . verbose with default value FALSE to represent whether the function should display every move to the screen The function will output the following values in a list: turna: how many turns it took to complete a game . chute_tally: a vector of length j with the count of how many times each chute was used. j is the number of chutes that exist in the board. If a chute is never used in the game, the tally for that chute is 0. Number the chutes and ladders in order of their starting square. . ladder_tally: a vector of length k with the count of how many times each ladder was used. k is the number of ladders that exist in the board. . move log: a vector containing a record or log of all the spaces a player landed on. If a player rolls over 100 and doesn't move, record the same position in consecutive turns (e-g., 99, 99, . .. )- The spinner has values 1 through 6 and each number shows up with equal probability. You can use the following function to simulate a spin.spin Bet . seed (10) > play_solo(board, TRUE) Turn 1 Start at 0 Spinner: 3 Turn ends at: 3 Turn 2 Start at 3 Spinner: 1 Landed on: 4 Ladder! Turn ends at: 14 Turn 3 Start at 14 Spinner : 2 Landed on: 16 Chute! Turn ends at: 6 Turn 4 Start at 6 Spinner: 4 Turn ends at: 10 Turn 5 Start at 10 Spinner: 6 Landed on: 16 Chute! Turn ends at: 6 Turn 6 Start at 6When verbose = FALSE, it will only return the contents of the list: > Bet . seed (10) > play_solo (board, FALSE) $turns [1] 18 $chute_tally [1] 2 0 0 0 0 0 0 0 0 0 $ladder_tally [1] 01 10 0 0 0 01 $move_log [1] 3 14 6 10 6 31 33 35 37 42 48 54 57 63 65 70 75 100 To demonstrate that your play_solo () function works, produce the verbose output for a game with set . seed (5) which has a total of 28 moves. If you use the same random seed as me, you should get the following output for the sequence of spins. set . seed (5) replicate (28, sample (6,1) ) [1] 2 3 1 3 1 1 5 6 3 3 6 2 5 4 2 5 3 1 6 4 3 2 5 2 2 3 1 2 If you are not getting the same results for set . seed (5), double check your RStudio Global Options. Make sure you have Restore .Rdata into workspace at startup unchecked and restart RStudio.Part 5 - Monte Carlo Study After you finish programming play_solo (), you will use it to perform a Monte Carlo study of the game Chutes and Ladders. 8 We wish to learn the distribution of how many turns it takes to complete a game. We also want to learn which chutes are used most frequently, and which ladders are used most frequently. Simulate 10,000 solo games. (Make sure verbose = FALSE!) Do not reset the seed from Part 4. . Keep track of how many turns it took to complete the game. Also keep track of the chute and ladder tallies. . Create a histogram (breaks = 50) of the turns. . Find the minimum number of turns. How many times out of 10,000 did a game finish with the minimum number of turns? . Find the maximum number of turns. . What is the median number of turns? . What is the mean number of turns? . What proportion of games take 100 or more turns to complete? . What proportion of games take 10 or fewer turns to complete? . What proportion of games utilize ladder 9 (the shortcut to win on space 80)? . Create a barplot of the relative frequency of how often each chute is utilized. (Number the chutes in order based on their starting square. The chute with lowest starting number, 16 to 6, is chute 1. The chute going from 98 to 78 is chute 10.) . Create a barplot of the relative frequency of how often each ladder is utilized. (Number the ladders in order based on their starting square. The ladder with lowest starting number, 1 to 38, is ladder 1. The Ladder going from 80 to 100 is ladder 9.) [A Monte Carlo study like this has already been performed and the results are published here: http://datagenetics. com/blogovember12011/. Take note one of the chutes (snakes) is different - our chute goes from 47 to 26, while theirs goes from 48 to 26. Also, the author numbers the chutes in reverse order, while I have numbered them in ascending order.]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Vector Optimization And Monotone Operators Via Convex Duality Recent Advances

Authors: Sorin Mihai Grad

1st Edition

3319089005, 9783319089003

More Books

Students also viewed these Mathematics questions

Question

How have social changes affected businesses?

Answered: 1 week ago

Question

2. How do I perform this role?

Answered: 1 week ago