Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the following program in C: CS 153 Program - Chutes and Ladder:s This program implements a single-player version of chutes and ladders. The game

Write the following program in C:

image text in transcribed

image text in transcribed

CS 153 Program - Chutes and Ladder:s This program implements a single-player version of chutes and ladders. The game board is a 10 x 10 grid of squares numbered one through 100. The game is played by moving a token from square to square according to the throw of a die ADDERS The player starts with a token in the the imaginary space left of square 1 (lower left) and then rolls a single die to move the token by the number of squares indicated by the die roll following the route marked on the gameboard The route is from the bottom to the top of the playing area, passing once through every square If a move puts the token on the lower-numbered end of squares connected by a ladder, move the token up to the higher-numbered square If a move lands on the higher-numbered square of a pair connected by a chute, move the token down to the lower- numbered square The player must roll the exact number to reach the final square to win the game. If a number is rolled that would take the player beyond the final square, the player remains on their current square For a history of the game see the Wikipedia article: http://en.wikipedia.org/wiki/Snakes and_ladders. Here is sample output from one run of the program Roll: 6 You advance to square 6 Roll: 3 Roll: Roll: 6 You advance to square 26 You advance to square 90 You advance to square 12 Roll: 2 Roll: 4 Roll: 1 You advance to square 28 Great! You land on a ladder You advance to square 94 You advance to square 13 and climb to square 84 Roll: 1 Roll: 3 You advance to square 95 You advance to square 16 Oh No! You land on a chute Roll: 4 You advance to square 88 Roll: 1 and slide to square 6 You advance to square 96 Oh No! You land on a chute Roll: 4 Roll: 4 You advance to square 92 and slide to square 75 You advance to square 10 Roll: 1 Roll: 5 Roll: 6 You advance to square 93 Oh No! You land on a chute You advance to square 80 You advance to square 16 Oh No! You land on a chute Great! You land on a ladder and climb to square 100 and slide to square 73 and slide to square 6 Roll: 1 You reached the goal in 29 moves Roll: 6 You advance to square 74 You advance to square 12 Details: Even though the board is 2D in conception, you can represent it as a 1D array of 101 cells (cell 0 is not used). The location of the user's token is contained in a variable. No token needs to be put in the 1D array. Each cell of the array contains either 0 (which means it is an ordinary square) or an integer (which means that the square is the start of a chute or of a ladder). If the player lands on a square containing an integer, the player's location is changed to that integer. For example, say the player is on square 13 and rolls a 3. This moves the player to square 16, which is the beginning of a chute. The array contains a 6 in cell 16, so the player's location is changed to 6

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

Step: 3

blur-text-image

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

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago

Question

2. What should an employer do when facing an OSHA inspection?

Answered: 1 week ago