Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program in C Language CS 153 Program - Chutes and Ladders This program implements a single-player version of chutes and ladders. The game board is

Program in C Language

image text in transcribedimage text in transcribed

CS 153 Program - Chutes and Ladders 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 LADDERS 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.oro/wiki/Snakes and ladders. Here is sample output from one run of the program Roll: 6 You advance to duare 6 Roll: 3 Roll: 6 Roll: You advance to square 26 You advance to square 9o 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 9.4 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 sqre 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 souare 10 Roll: 1 Roll: 5 Roll: You advance to square 93 Oh No! You land on a chute You advance to square 80 You advance to aquare 16 Oh No! You land on a chute Great! You land on a ladder and climb to square 100 You reached the goal in 29 and slide to square 73 and slide to square 6 Roll: 1 Roll: You advance to square 74 moves! 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 players 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 CS 153 Program - Chutes and Ladders 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 LADDERS 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.oro/wiki/Snakes and ladders. Here is sample output from one run of the program Roll: 6 You advance to duare 6 Roll: 3 Roll: 6 Roll: You advance to square 26 You advance to square 9o 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 9.4 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 sqre 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 souare 10 Roll: 1 Roll: 5 Roll: You advance to square 93 Oh No! You land on a chute You advance to square 80 You advance to aquare 16 Oh No! You land on a chute Great! You land on a ladder and climb to square 100 You reached the goal in 29 and slide to square 73 and slide to square 6 Roll: 1 Roll: You advance to square 74 moves! 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 players 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_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

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

=+ a. How does this change affect the incentives for working?

Answered: 1 week ago