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