Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dr. Nim : We re going to create a Dr. Nim spinoff game. In this game, you have a random number of marbles (between 12

Dr. Nim: Were going to create a Dr. Nim spinoff game. In this game, you have a random number of marbles (between 12 and 31). Play occurs in rounds between 2 players: the human user and the computer. In each round, the player can select 1-3 marbles to remove. The player who gets the last marble wins the game.

Our game will have two players Player 1 (you) and the computer. Player 1 will select between 1-3 marbles to remove. The computer will randomly select between 1-3 marbles to remove during its turn.

1. Create a function called showMarbles. This function will print the board with the current number of marbles. An example of what this functions output will look like is given below.

Example: Assuming my game randomly started with 15 marbles on the board:

O O O O O O O O O O O O O O O

2. Create a function called player1Move. This function will ask the user to pick a number of marbles to remove from the board between 1 and 3. You should verify that the user enters in a valid number of marbles to remove. The function will then subtract the chosen number of marbles from the current marble count. An example of this functions output is given below.

How many marbles do you want? Pick between 1-3: 4

Invalid selection. Try again.

How many marbles do you want? Pick between 1-3: 3

3. Create a function called computerMove. This function will allow the computer to randomly select a number of marbles from the board. Your function should handle 2 cases:
a. In the case that there are 4 or more marbles on the board, the computer will choose between 1-3 marbles to remove from the board.
b. In the case that there are less than 4 marbles on the board, the computer will choose the current number of marbles on the board.

The function should deduct the computers randomly selected number of marbles from the current number of marbles on the board. The function should also output how many marbles the computer chose to remove from the board.

In python 3.7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions