The Ploy of the Jailer
Summary:
You have been captured and thrown in jail! Your jailer, a gambler and a hobby dragon breeder, is bored with his job, so he makes you an offer; Beat him at his own game and you go free. If you lose, you will be dragon food. Since you are a first-time offender, he is willing to stack the game in your favor – what a nice jailer.
Skills to be Obtained:
Details:
To decide your fate, you will play a board game on a simple board: a track with 20 sequential spaces numbered from 1 to 20. The “zero” space is marked “start,” and your token is placed on it. The jailer has one silver coin and places it on a random nonzero space. The jailer then gives you two gold coins, and you are allowed to place them on any two nonzero spaces that you want except that all coins must be placed on different spaces.?Once placed, the coins may not be moved.
After the three coins are placed, you roll a fair, six-sided die and move your token forward the corresponding number of spaces. If, after moving the token, it lands on a space with one of your gold coins on it, you have instantly won your freedom. On the other hand, if, after moving the token, it lands on the space with the jailer’s silver coin on it, you have instantly lost and become dragon food. If you land on a space with no coins, you roll again and continue moving forward. If your token gets past space 20, move your piece back onto the board by subtracting 20 from your current space number (the next spot after 20 is spot 1); with your next roll of the die, you again proceed across the board, with the coins in the same location. Your token moves across the board as many times as needed until it lands on a space with a coin. Once you enter your location, the code should run continuously until you win or lose!
In this assignment, you will develop codes that allow a user to play this game against the computer; the player is the accused and the computer is the jailer. When run, the computer should:
1) welcome the player to the game;
2) announce which space the jailer has randomly chosen for the silver coin;
3) ask the player which two spaces they would like to place their gold coins on;
4) run the game as described above, moving the token random numbers of spaces as with the roll of a six-sided die, each time printing to the screen the location of the token and checking to see if the token has landed on the silver coin, a gold coin, or off the end of the board;
5) if the token passes 20, subtract 20 from the position number (the next spot after 20 is spot) or end the game if it lands on a coin;
6) display a game-over message appropriate to whether the player has won (freedom!) or lost (dragon!);
7) at the start of each round (a round is every time the player passes 20, not every turn), announce the round number. When you reset the token, use the remaining movement to continue moving the player (if they landed on space 22, then would end on space 2 instead).
Do not try to solve this homework all at once - start with pseudocode!?A smart strategy in writing a computer program of any complexity is to start small and only get more complex as needed. You may even find it useful to write a few really small programs; each one does just a piece of the overall game, and once you’ve got it working, you can copy-and-paste that code into the final program. Also, it is best to plan your work with pseudocode. If you ask the first year center for help, they will ask to see your pseudocode.
After you have completed the program, play the game. Play at least twice—once with the jailer winning and once with the player winning. Take a screenshot of the program’s results for each of these cases and include it in the report.
Submission Requirements:
For this homework, please submit a report to Canvas. The report should include an introduction to the problem and your approach (including any extra work you added to your assignment), your pseudocode, screenshots of both results (jailer wins and player wins), and a replication of your code (copy/paste into the report or screenshots of your code). Your code should be in an Appendix (which never count toward page limits!). If you choose to partake in one or more of extended work options listed on the next page, be sure to note that in the report! Please also submit the fully commented .cpp file to your Canvas submission.
This homework is due at 11:59 pm on the due date listed on Canvas. Please include both the report and the .cpp file of your program. For the report, please submit it as a .pdf.
Extended Work (+2 Extra Credit/options):
?Though not required, you may perform one or more of the following extended work options for 2 extra credit points apiece. Submit each completed task as its own properly labeled code?AND pseudocode in the submission although you may include them all in one report?with clearly labeled sections (If you want to submit multiple reports, that is okay too.):
Uh-oh, the jailer caught you cheating at chess and is changing the rules so you’re more likely to lose the game. There are now two silver coins and one gold coin. Moreover, the jailer will randomly pick up one of his coins before each of your moves and place it at a new random