Create a simulation of childrens board game-chutes & ladders


Assignment Case Scenario: Chutes and Ladders

In this assignment, you will create a simulation of the children's board game, Chutes and Ladders.

The game is simple. Players spin a spinner with number 1 through 6. Players move their piece that many spaces.

Some spaces have ladders, and the player moves to a new location on the board. If you land at the bottom of a ladder, you move to the top of the ladder. Some spaces have chutes (slides) which causes the player to move backward. If you land at the top of a chute, you move to the bottom of the chute.

The first player to land exactly on space 100 wins the game.

Encouragement: The task at first can seem daunting (especially because the instructions themselves are so long!). Break it down into smaller pieces that you can handle.

Encouragement: The more you practice coding, the better you will be at coding. Time spent thinking and writing code is not wasted, even if you are unable to fully achieve all the requirements.

Advice: Follow the strategies I've laid out on writing functions given in lecture.

Assignment Part 1:

Attached a picture of the official game board.

Figure out how to save 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.

In the Rmd file, create a single object called board where you store the features of the game board in R.

Assignment 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 (lwd = 2).

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 20 x 20.

In the Rmd file, call the show_board() function to produce the plot of the game board.

Assignment Part 3:

Create another object in the Rmd file called mini-board to represent the board pictured attached.

In the Rmd file, call the show_board() function to produce the plot of the miniboard.

(This part is to test that your function is flexible to represent different boards.)

Assignment Part 4:

Create a function play_solo() that will simulate a game of chutes and ladders for one player.

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:

- turns: 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.

- 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.

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.

Assignment Part 5 - Monte Carlo Study

After you finish programming play_solo(), we will use it to perform a Monte Carlo study of the game Chutes and Ladders.

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!)

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 bar plot 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 bar plot 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.)

Attachment:- R Programming.rar

Request for Solution File

Ask an Expert for Answer!!
Other Subject: Create a simulation of childrens board game-chutes & ladders
Reference No:- TGS03033463

Expected delivery within 24 Hours