In this project, you simulate the play of a popular childrens game: Chutes and Ladders as shown in the picture below. see image.
The Chutes and Ladders game is played on a 100 square game board. Each square on the board is numbered 1 through 100. There can be as many players as desired but for the project, each of your team members will be a player in a game. Each player starts off the board at a figurative square 0. Each player rolls a single die with 1 through 6 face values and advances to the number of spaces shown on the die. For example, if the player is at position 2 and rolls a 5, the player moves to position 7. When any one of the players lands exactly on the square 100, the player wins, and the game is over.
There are 2 rules to the player movement.
(1)If the player lands on a slide (chutes), the player slides down. If the player lands on a ladder, the player climbs up. See the picture for the square where a slide or a ladder is, and the table below. see image.
For example, if the player lands on square 1, the player advances to square 38. If the player lands on square 98, the player slides down to square 78.
(2)The player must land exactly on square numbered 100 to win. If the player rolls a die that would advance to a square beyond square 100, the player stays put at its place. For example, the player at square 97, the player must roll exactly a 3 to win. A roll between 4 and 6 would make the player stay put at the current square, and the player loses a turn.
Like project #1, the provided classes are skeleton that you will need to fill in the blank spaces. You are required to fill in the missing parts so that the code for the game is complete and runs properly.
The simulation is split into the following classes:
(1)Die class (Die.hpp) allows a player to roll the die, which generates a number between 1 and 6, inclusive, randomly using the math librarys rand(). Client of the Die class can get the die face value via the accessor: getFaceValue(). This class is ready for use in your program. No change is needed.
(2)GameBoard represents the gameboard numbering 1 to 100. TO DO: you need to implement a storage to store each square on the board, and the following methods:
(3)Player class (Player.hpp and Player.cpp) represents a player in the game. It contains the player name, the players current position, and a die.
RollDieAndMove - Each player has its own die. The player rolls the die and advances to the new square based on the face value of the die. The method must make sure that the players position is inside the gameboard. If the player rolls the die that moves her/him past the square 100, s/he must stay put at the current square, and lose a turn.
TO DO: you need to implement the following methods:
(4)ChutesAndLaddersGame class that simulates the Chutes and Ladders game. The game starts and runs until a player reaches the winning square 100.
TO DO: you must use ArrayQueue to store the players, and implement the following items/methods:
(5)PlayChutesAndLaddersGame is the main test driver. The driver uses the assert macro to test whether the code works or not.
Because the provided code is only a template, PlayChutesAndLaddersGame will fail immediately with runtime errors. As you add functionality and fix any bugs that may arise, PlayChutesAndLaddersGame will be able to run further and further. You should run PlayChutesAndLaddersGame and observe the runtime errors to help you solve problems in your code. When the files are working completely as intended, PlayChutesAndLaddersGame will run to completion with no runtime errors.
Finally, the skeleton code contains a README.md file with a brief description of the project.