Question Details

(Solved by Expert Tutors) Python 3Write a Python program to play a simplified version of


Write a Python program to play a simplified version of

the Nim game. Generate a pile of between 15 and 21 inclusive matchsticks using the random number generator. Allow the human player to go first and remove from 1 to 3 sticks. Then allow the computer to generate a random number between 1 and 3 inclusive and remove that many matchsticks(exception example: if the number is 3 and there are only 2 matchsticks left, then only remove 1 matchstick). Playalternates until 1 matchstick is left and the losing player removes it. Declare the winner and ask if the user would like to play another game.
Validate the input and write the following functions:
-computer_play(pile) ?figures out how many sticks the computer will remove and returns the number of sticks to remove
-player_play(pile) ?solicits input from the user as to how many sticks to remove, validates the input, and returns the number of sticks the player wants to remove
-print_gameboard(pile) ?prints a vertical bar for each matchstick on one line with one space between each matchstick.
-main () ?main function which allows the user to play the game as many times as desired; validates all input
Please go to the web site, http://www.archimedes-lab.org/game_nim/play_nim_game.html, and play the game to learn it?s rules.

 


Solution details:

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Apr 19, 2020

EXPERT

Tutor

ANSWER RATING

YES, THIS IS LEGAL

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now