Question
Write a python program for a two-player rolling dice game (namely, P1 and P2). Each player has a counter to record their scores (initially 0).
Write a python program for a two-player rolling dice game (namely, P1 and P2).
Each player has a counter to record their scores (initially 0). Each time, a player would roll two dice. The sum of the two dice would be added to the corresponding players counter. If the player rolls doubles (i.e. the two dice have the same number), then the player can continue to roll the dice. Otherwise, it would be the other players turn. When the input is 0, print the players scores. Sample Test case 1: Input 12 31 23 0
Expected output P1:8 P2:4 Detailed explanation: Player 1 rolls the dice 1 and 2. The counter of Player 1 becomes 3. Player 2s turn. Player 2 rolls the dice 3 and 1. The counter of Player 2 becomes 4. Player 1s turn. Player 1 rolls the dice 2 and 3. The counter of Player 1 becomes 8. Input 0 means the end of the input and print the values of the counters. Sample Test case 2: Input 11 34 25 61 34 0
Expected output P1:16 P2:14 Detailed explanation: Player 1 rolls the dice 1 and 1. The counter of Player 1 becomes 2. As it is a double, still Player 1s turn. Player 1 rolls the dice 3 and 4. The counter of Player 1 becomes 9. Player 2s turn. Player 2 rolls the dice 2 and 5. The counter of Player 2 becomes 7. Player 1s turn. Player 1 rolls the dice 6 and 1, The counter of Player 1 becomes 16. Player 2s turn. Player 2 rolls the dice 3 and 4. The counter of Player 2 becomes 14. Input 0 means the end of the input and print the values of the counters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started