Design a game of Nim in Python

Assignment Help Python Programming
Reference no: EM132295775

Assignment -

Task - In this assignment, your task in to design a game of Nim in Python. In this game "Two players take turns removing objects from distinct heaps or piles. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap/pile. The goal of the game is to avoid taking the last object."

In your implementation of the game, there will be 3 piles of objects. At the start of the game, each of the three piles will be initialized by a random number of objects. Random number should be between 5 and 15. The players will take turn picking up objects from the piles. A player can even pick up all items from a single pile. The player that picks up last object (across all piles) loses.

You should use functions in the program. Functions must follow a good programming style, that is, any well-defined task which needs to be executed often, can be moved into its own function.

Following is a sample run of the program. You should follow same display style. You have to handle invalid inputs as well, as demonstrated by several examples in the sample run. IN the given example, initially the game starts with randomly chosen number of objects (7, 13, 9). The program prompts both players to select a pile and choose how many objects to remove.

Task 1 -

Draw a flowchart that presents the steps of the algorithm required to perform the task specified. You can draw the flowcharts with a pen/pencil on a piece of paper and scan it for submission. Please ensure that the scanned file and your handwriting are clear and legible. However, it is preferable to draw flowcharts using a drawing software.

Task 2 -

Select three sets of test data that will demonstrate the 'normal' operation of your program; that is, test data that will demonstrate what happens when a VALID input is entered. Select two sets of test data that will demonstrate the 'abnormal' operation of your program.

Set it out in a tabular form as follows. It is important that the output listings (i.e., screenshots) are not edited in any way.

Task 3 -

Implement your algorithm in Python. Comment on your code as necessary to explain it clearly. Run your program using the test data you have selected and complete the final column of test data table above.

Attachment:- Assignment File.rar

Verified Expert

This project is about how the playing the Nim game.In this application three types of piles are there and play the two players player 1, player 2 .First randomly given the values to the three piles. And then choose the any one of the pile if you enter the wrong pile it will shows. The error message otherwise ask the how many objects you want to remove then player enter the. Number if you enter the wrong value it will shows the error message. For every step decrease the Values of the piles. Suppose one of the pile is empty but you try to remove the values from that file. Then it will show the some error message. And lastly who picked the last object that player is looser another player is winner.

Reference no: EM132295775

Questions Cloud

Define complications of cance and side effects of treatment : Write a paper (1,250-1,750 words) describing the approach to care of cancer. In addition, include the following in your paper: Describe the diagnosis.
What role did the united states play in bringing an end : What were the United States' motivations in their actions and what impact did they have on the people of Guatemala?
Different snack products in a large food products company : Eve supervises a team of marketing analysts who work on different snack products in a large food products company. The marketing analysts have recently
What is your field of study or profession : Imagine you are training a new employee or colleague. What is your field of study or profession?
Design a game of Nim in Python : In this assignment, your task in to design a game of Nim in Python. Draw a flowchart that presents the steps of the algorithm required to perform the task
Relevant hypotheses and develop research model : From the literature review, formulate the relevant hypotheses and develop a research model/framework for your topic.
Illustrate your knowledge about the us electorate : The function and purpose of caucuses and primary elections in political campaigns, particularly in the presidential election process
Describe a method for providing both the patient and family : Describe a method for providing both the patient and family with education and explain your rationale. Provide a teaching plan (avoid using terminology).
What roles did black slaves play in the civil war : What roles did Southern women play in the war effort on the Confederate side during the Civil War? How did the war affect each group?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd