Create a simulation of the children board game

Assignment Help Other Subject
Reference no: EM132438184

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

Part 1 -

Attached a picture of the official game board.

Figure out how to save and store the features of the gameboard 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.

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.

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

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.

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

Attachment:- R Programming Assignment Files.rar

Reference no: EM132438184

Questions Cloud

Difference in mean cost of textbooks for math : Find a 95% confidence interval for the difference in mean cost of textbooks for math and sociology students. Round to the nearest tenths.
What is the probability that the ball chosen from box a : What is the probability that the ball chosen from box A is labeled 1 if exactly two balls numbered 1 were selected?
Estimate the requested probabilities : Then use the normal distribution to estimate the requested probabilities.
Contrast brittle and plastic deformation : Contrast brittle and plastic deformation. Describe and diagram the differences among an anticline, a syncline, and a monocline.
Create a simulation of the children board game : In this assignment, you will create a simulation of the children's board game, Chutes and Ladders. How to save and store the features of the gameboard in R
Imply that y should tend to increase or decrease : As x increases from 3 to 25 months, does the value of r imply that y should tend to increase or decrease? Explain your answer.
Documentary the true cost : Which of the 9 planetary boundaries are currently being exceeded by the fashion industry? How? Which of the social foundation boundaries are being exploited?
Write down the probability distribution of repayment : Write down the probability distribution of your repayment. Compute the expected value of your repayment or the "mean repayment".
Determining the population standard deviation : How large a simple random sample has to be taken so that the margin of error is no more than ±5 ml? Assume that the population standard deviation is 20 ml.

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd