Question: Homework Assignment 1 Your first assignment is to write a program to play the following game, described in exercise 5 in Section 1.13.3, which the
Homework Assignment 1 Your first assignment is to write a program to play the following game, described in exercise 5 in Section 1.13.3, which the user plays against the computer. Hint: I suggest that you also do Problem 2 in Section 1.13.3 before attempting this problem (P.51). Do not submit Problem 2, however. You will also need the suggestion at the beginning of Problem 3 and, perhaps, some ideas from that problem description. Exercise 3. Write a program to play the following game, which the user plays against the computer. This game is played on an imaginary game board that has numbered spaces arranged in a circle. For example, here is what a game board with 12 spaces might look like. 11 10 When the program starts, the user is asked to specify how many spaces there are on the game board. There must be at least five spaces. The computer then randomly selects two spaces (excluding space numbers and 1): One of the selected spaces is The Goal. The other is The Pit. The computer announces the two special spaces. Play then starts from space #0: Each player, in tum, "rolls" a pair of dice and "moves" to another space by advancing N spaces (where N is the number that came up on the dice). For example, using the sample game board with 12 spaces, if the user rolled a 10 (6 plus 4) on her first tum and a 7+4) on her second tum, then she would land on space #5. That's where she would start on her next tum. . The user and the computer take tums rolling the dice and moving around the board. Each move is displayed on the screen (as text, not szaphics eg., "You are The game continues until one player lands on The Goal (and wins the game) on The Pit (and loses the game). The computer announces the outcome of cach game and keep track of cach player's wins and losses. The user can choose single play (user must press Enter for each roll of the dice) or continuous play (dice are automatically rolled and play continues until someone wins) After each game the user can choose to quit or play another game
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
