Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please, I need help with program c++. This is a chutes and ladders program. The code must be a novel code to the specifications of

Please, I need help with program c++. This is a chutes and ladders program. The code must be a novel code to the specifications of the problem statement. Thank you very much.

Assignment Overview

This program will implement a variation of the game chutes and ladders or snakes and ladders: https://en.wikipedia.org/wiki/Snakes_and_Ladders#Gameplay. Just like in the original game, landing on certain squares will jump the player ahead or behind. In this case, you are trying to reach to bottom of the board rather than the top. Two variations in this game is that landing on another player is not permitted and that a player must have an exact roll to land on the final square to win. There can be 2-4 players.

The purpose of the assignment is to learn to use functions in a program, and how to use 1D arrays. You do NOT have to pass arrays to a function for this program.

Problem Statement

The program runs on a 40 square (8 columns and 5 rows) grid, with all players starting off the board, so a roll of one will put a player in the first square. The user will choose how many players will be playing. If there are fewer than 2 players or more than 4 players, the user is prompted again. The player pieces are labeled with character a, b, c, and d, in that order. Therefore, a game with 2 people would use pieces a and b.

Next, the program asks the user if the game should be run in debug, power, or regular mode (D, P, or anything else, case insensitive). If D is entered, set the random seed to 10 (srand(10)) and generate random player rolls. If P is entered, set the random seed to 10 and users get to state what their roll is, including going backwards! If anything else is entered, use the time seed and generate random player rolls.

During the game, the users are presented with two options: (R)oll and (Q)uit. Any other option other than Ror Q (case insensitive) should prompt the user again. R will roll the dice, and Q will stop the game. Please see the sample output for the formatting. A roll can be any value of 1 to 6. After a roll, the following may occur:

The square has a chute or ladder

Output what occurred and move the player to the end of the chute or ladder

This precedes checking if another players is already in the square

There is another player in the space,

Output which player you would have landed on and skip the current players turn. This should be done AFTER a chute or ladder.

The roll would place the player past the last square

Output that an exact roll is needed, and skip the current players turn (see the example output for formatting)

The square is blank

Move the player to the square

The square is blank and is the last square

More the player to the square and end the game since they won.

At the beginning of each turn, print the game board again. The following are the starting game board, and after placing one player that rolled a 6. So, the player starts at the top left.

| | | | # | 1 | a | 2 | |

| | | | 1 | $ | | | |

| | # | | 3 | | | | |

| | | % | 2 | | | $ | |

| | | | % | 3 | | | |

Landing on a chute or ladder

This program will permit some flexibility on what is output when this occurs. You may be creative on what happened to a player, but there must be at least 2 random results for both a chute or a ladder (4 total).

Chute or ladder locations

The game must have the following chutes and ladders (indexed starting at 0, from the top and left)

Ladder (takes player away the goal)

Square 11 (row 1, column 3) climbs to square 4 (row 0, column 4), and is displayed as 1 on the game board.

Square 27 (row 3, column 3) climbs to square 6 (row 0, column 6), and is displayed as 2 on the game board.

Square 36 (row 4, column 4) climbs to square 19 (row 2, column 3), and is displayed as 3 on the game board.

Chute (takes player towards the goal)

Square 3 (row 0, column 3) drops to square 17 (row 2, column 1), and is displayed as # on the game board.

Square 12 (row 1, column 4) drops to square 30 (row 3, column 6), and is displayed as $ on the game board.

Square 26 (row 3, column 2) drops to square 35 (row 4, column 3), and is displayed as % on the game board.

Since they do not change over the course of the game these are constants.

Functions

The following are the minimum number of functions you must create for the game. You may add more (and may need to due to coding style requirements of a maximum of 50 lines or 2 pages, with comments and whitespace included), but these functions MUST work as described. There are no return or parameter types stated here, you must decide on these yourself.

_____ print_menu(___)

print the (R)oll and (Q)uit menu, and return the option selected

_____ move(___)

try to move a current player position to a new position based on the rules given (ignoring the other players). It should be calling has_chute_or_ladder(), activate_ladder(), and activate_chute()

_____ get_mode(___)

Asks what mode the game should be in, and return the mode

_____square_symbol(____)

Returns the board symbol to be used at that location

_____ activate_ladder(____)

Print out a random message on what occurred to the player that landed on a ladder

_____ activate_chute (____)

Print out a random message on what occurred to the player that landed on a chute

_____ has_chute_or_ladder(___)

Returns whether the player landed on the START of chute, ladder or a normal square, and also return where the chute or ladder would lead to.

int main()

Mostly drives the program, but also holds the player list and game board.

Formatting

For each of the following event output the stated text.

The board is printed before each turn and has a line between the board and the players turn

Getting the player count: Please, enter how many players:

Getting an invalid player count: Please enter 2 to 4 players:

Printing the mode menu:

Choose which mode to play in

(D)ebug mode

(P)ower mode

Anything else will be regular mode

Enter Mode:

Printing the menu (where X is substituted with the current players letter:

----Current player is X----

(R)oll

(Q)uit

Getting an invalid menu option;

Invalid option

(R)oll

(Q)uit

After a normal roll(substitute a X with the value): Rolled a X

After a power roll(substitute a X with the users input value): Roll: X

After rolling past the end: Rolled past the end of the board. You need an exact roll.

After someone wins (substitute X with the users letter): "Player X won."

When quitting: Quitting...

Requirements

The players positions and letters MUST be stored in an array

The board MUST be in an array

You may NOT have corrupted memory with the game ends. This means you tried to put a value outside an array. MSVS will tell you when you end.

Since you do NOT have to pass arrays into functions, main may be up to, but no larger than, 100 lines (including whitespace and comments)

IF you decide to jump ahead and pass in arrays, main must be less than 60 lines. (including whitespace and comments)

All other functions must be under 50 lines, or two pages, including whitespace and comments

You should be able to get an exact match for all the described outputs at this time. This should match down to the character (ignoring trailing spaces)

Sample Output of the program (user input in bold italics)

The text file debug.txt shows a debug run

The text file power.txt shows power mode run

The text file normal.txt shows a normal run

Additional Comments

The functions must be written as described.

Vectors are not allowed.

Strings are not allowed with the exception of Cstrings.

Sample Program in Debug Mode

-----Chutes and ladders----- 1,2 3 go up, and #, $, and ^ go down Please, enter how many players: 2 Choose which mode to play in (D)ebug mode (P)ower mode Anything else will be regular mode Enter Mode: d | | | | # | 1 | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is a---- (R)oll (Q)uit r Rolled a 6 | | | | # | 1 | a | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is b---- (R)oll (Q)uit r Rolled a 4 Chute: Slippery | | | | # | 1 | a | 2 | | | | | | 1 | $ | | | | | | b | | 3 | | | | | | | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is a---- (R)oll (Q)uit r Rolled a 3 | | | | # | 1 | | 2 | | | a | | | 1 | $ | | | | | | b | | 3 | | | | | | | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is b---- (R)oll (Q)uit r Rolled a 6 | | | | # | 1 | | 2 | | | a | | | 1 | $ | | | | | | # | | 3 | | | | b | | | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is a---- (R)oll (Q)uit r Rolled a 3 Ladder: Climbing | | | | # | a | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | b | | | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is b---- (R)oll (Q)uit r Rolled a 1 | | | | # | a | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | b | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is a---- (R)oll (Q)uit r Rolled a 3 | | | | # | 1 | | 2 | a | | | | | 1 | $ | | | | | | # | | 3 | | | | | | b | | % | 2 | | | $ | | | | | | % | 3 | | | | ----Current player is b---- (R)oll (Q)uit r Rolled a 4 | | | | # | 1 | | 2 | a | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | b | | $ | | | | | | % | 3 | | | | ----Current player is a---- (R)oll (Q)uit r Rolled a 1 | | | | # | 1 | | 2 | | | a | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | b | | $ | | | | | | % | 3 | | | | ----Current player is b---- (R)oll (Q)uit r Rolled a 6 | | | | # | 1 | | 2 | | | a | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | $ | | | | | b | % | 3 | | | | ----Current player is a---- (R)oll (Q)uit r Rolled a 4 Chute: Slippery | | | | # | 1 | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | a | | | | | b | % | 3 | | | | ----Current player is b---- (R)oll (Q)uit r Rolled a 4 | | | | # | 1 | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | a | | | | | | % | 3 | | b | | ----Current player is a---- (R)oll (Q)uit r Rolled a 5 | | | | # | 1 | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | $ | | | | | | a | 3 | | b | | ----Current player is b---- (R)oll (Q)uit r Rolled a 6 Rolled past the end of the board. You need an exact roll. | | | | # | 1 | | 2 | | | | | | 1 | $ | | | | | | # | | 3 | | | | | | | | % | 2 | | | $ | | | | | | a | 3 | | b | | ----Current player is a---- (R)oll (Q)uit r Rolled a 4 Player a won. 

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

Students also viewed these Databases questions