Question: Write a Python program that plays Take-1-2-3 with the user. Start with a reasonable random number of stones in the pile, say, 8 to 12.

 Write a Python program that plays Take-1-2-3 with the user. Start

Write a Python program that plays Take-1-2-3 with the user. Start with a reasonable random number of stones in the pile, say, 8 to 12. Let the human player go first. Prompt the human player to make a move; accept only valid input (1, 2, or 3, but not exceeding the total remaining number of stones in the pile); explain invalid input attempts until the player makes a valid move. When it is the computer's turn and it is in an unsafe position, it should take the number of stones to move to a safe position. If the computer is in a safe position, it should take randomly 1, 2, or 3 stones. You might want to implement the "human's move and the computer's move in separate functions that return the number of stones taken. Declare a winner when there are no stone left in the pile. Write a Python program that plays Take-1-2-3 with the user. Start with a reasonable random number of stones in the pile, say, 8 to 12. Let the human player go first. Prompt the human player to make a move; accept only valid input (1, 2, or 3, but not exceeding the total remaining number of stones in the pile); explain invalid input attempts until the player makes a valid move. When it is the computer's turn and it is in an unsafe position, it should take the number of stones to move to a safe position. If the computer is in a safe position, it should take randomly 1, 2, or 3 stones. You might want to implement the "human's move and the computer's move in separate functions that return the number of stones taken. Declare a winner when there are no stone left in the pile

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!