FIT9136 Algorithms and Programming Foundations in Python Assignment 1
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
FIT9136 Algorithms and Programming Foundations in Python
Assignment 1
1. Key Information
This assignment will develop your skills in designing, constructing, testing, and documenting a small Python program according to specific programming standards. This assessment is related to the following learning outcome (LO): ● LO1: Apply best practice Python programming constructs for solving computational problems |
|
Your task |
This assignment is an Individual task where you will write Python code for a simple application whereby you will be developing a simple dice rolling game as per the specification. |
Value |
15% of your total marks for the unit. |
Due Date |
Friday, 26 August 2022, 4:30 PM (AEST) |
Submission |
● Via Moodle Assignment Submission. ● FIT GitLab check-ins will be used to assess the history of development ● Turnitin will be used for similarity checking of all submissions. |
Assessment Criteria |
The following aspects will be assessed: 1. Program functionality in accordance to the requirements 2. Code Architecture and Adherence to Python coding standards 3. The comprehensiveness of documented code and test strategy |
Late Penalties |
● 10% deduction per calendar day or part thereof for up to one week ● Submissions more than 7 calendar days after the due date will receive a mark of zero (0) and no assessment feedback will be provided. |
Support Resources |
See Moodle Assessment page and Section 7 in this document |
Feedback |
Feedback will be provided on student work via ● general cohort performance ● specific student feedback ten working days post submission |
For this assignment, you will write a Python program that will allow a user (player) to play a dice-rolling game. This section specifies the required functionality of the program. Only a text interface is required for this program; however, bonus marks will be given if the program would be easy to follow with clear information/error messages for the player.
The aim of the Dice Rolling Game is for a player to roll 2-6 dice multiple times in each game. Victory is achieved when the median value is the same as the mean value in a result list of the dice rolls for all rounds of the game.
The game starts by letting the player choose a number of dice to play with and also choose the type of dice that they want to use. The player rolls the dice multiple times and based on the results, either wins or loses. Your task is to write functions to display the main menu, a game menu, as well as other functionalities to check the game history and the win/lose status. Read the following rules and requirements for each function carefully and attempt to implement them.
This function will display the main menu when the program is started and has three options as outlined below:
1. Start Game: This option would display the game menu function when the player inputs 1.
2. Game History: This option displays the game history function when the player inputs 2.
3. Exit Program: The program will terminate when player inputs 3.
Players are only expected to input digits 1, 2, or 3 to select the respective main menu option. Hence, other inputs made by the player should be properly handled with an error message followed by displaying the main menu so that the player can enter the accepted input. You
may use strings like e.g. “-----------main menu------------” in your menu to distinguish the main
menu and game menu in the instance.
This function will display the game menu, with a possible 5 options as shown below:.
1. Select the Number of Dice: The number of dice can be selected every time a player rolls a dice. The number of dice ranges from 2 to 6.
Input validation should be in place to ensure that the dice number is valid and invalid inputs are handled with an error message.
2. Select the Type of Dice: There are three types of dice (i.e., 6, 8, or 9) all of which have 6 faces. If the dice type is selected as
○ 6, the dice will have values 1, 2, 3, 4, 5, or 6.
○ 8, the dice will have values 2, 2, 3, 3, 4, or 8.
○ 9, the dice will have values 1, 1, 1, 1, 5, 9.
Once the user inputs a type of dice, the type can not be changed until the next game. (Means the option will be locked)
Input validation should be in place to ensure that the dice type is valid and invalid inputs are handled with an error message.
3. Roll Dice: This option invokes the Roll dice function and displays the result of rolling dice in the command line.
4. Check Win/Lose: This option invokes the check win/lose function and displays a string indicating whether the player won or lost a game given the rolling results.
5. Exit Game: This option stops the game and exits to the main menu. Before finishing each round of the game, the result must be saved.
This function rolls the dice given the player’s input for the number and type of dice. Two positional arguments are necessary here to record the number and type of dice.. The function returns a tuple of integers each of which represents the dice number. For example, if a player inputs 3 and 6 for the number and type of dice, this function will return a tuple of
3 integers (e.g. (6, 2, 3)). Note that each number will be within the range of the dice type. Note:
● The bonus mark will be granted if this function also returns a visualised string dice as shown below:
The top left image visualised the output (9,9,9) and the bottom left image visualised the output (3,3,3). You will only receive the bonus mark if you show the dice results in a row (similar to the left example images). No bonus mark will be granted if you display the result vertically (similar to the image in right). A sample code to generate a dice string is provided in the “A1_student_template.ipynb” file.
This function checks the win/lose status for the dice results of the player rolled. The function should have a list type positional argument dice_result_list. For example, if the data in dice_result_list \ look like [(1, 6), (1, 2, 5), (3, 4, 5, 6), (1, 1, 1, 6)], this means player play four rounds (2 dice, 3 dice, 4 dice, 4 dice) in the game and each tuple is the result of a dice roll.
Once the function gets a result list of the dice rolls for all rounds of the game, it needs to find the middle value (median) and mean value (average) of this list. Note that you need to
● sort the list in ascending order In order to get the median value of a list
● use int() function to typecast floats to integers of all resulting numbers.
If the middle value is the same as the mean value, the function will return the “win” string, otherwise, return the “lose” string. If the number of rolls for any particular game is over 10 times, return the “lose” string.
For example, given dice_result_list= [(1, 6), (1, 2, 5), (3, 4, 5, 6), (1, 1, 1, 6)], the median value which is 3. If there are two median values, use the average of these two values as the median value. We find that for this example the mean value is also 3, so return “win”.
This function displays all the games’ history. It has one positional argument games_result_list. The information in this list will need to be printed out. For each game, show dice rolling times, the number of dice in each round, and the win or lose result. For example, “Dice rolling times: 3, Number of dice: 3, Result: win”. The final result should be sorted based on dice rolling times in ascending order. Please make sure to format your strings so it is in a clear and readable format.
The main control logic is implemented in this function. This function has no positional argument and no return. A game_result_list needs to be defined to record all the game history. Each game result needs to be saved into this list. You can use your preferred format to save all the data, but all the printed messages should follow the format explained in the games history function. Use infinite loops to handle the main menu and game menu function. If a user exits one game, the main menu function should keep running until the user inputs the command to exit the program. Similarly, once a user starts a game, the game menu should continue until the user inputs the command to exit the game. Users should be able to perform all the functions listed in the menu. Except for previously listed functions, you can create extra functions if you consider it necessary. And, all the control logic like
“if-else” or “while loop” is written in this function. Add validation to make sure the input for the main menu and game menu is correct.
Do not forget to test this function after finishing.
3. Do and Do NOT
● If any exception/errors happen when running each function, you will lose 50% of allocated function logic marks. For example, if the main menu function returns any error, then the maximum mark you can get is 5% instead of 10% in the function logic.
● Add correct validation and output messages to make your code more user-friendly to users.
● Run the test function at the end of your file to show that your program works correctly.
● This is an individual assignment and must be completed on your own. You must attribute the source of any part of your code that you have not written yourself. Please note the section on Academic Integrity in this document.
● The assignment must be done using the Jupyter Notebook, Python Version 3.9.
● The Python code for this assignment must be implemented according to the PEP 8-Style Guide for Python Code.
● The allowed libraries are random and math. You will receive penalties if you use any other libraries.
● Commenting on your code is an essential part of the assessment criteria. In addition to inline and function commenting on your code, you should include comments at the beginning of your program file which specify your name, Student ID, the creation date, and the last modified date of the program, as well as a high-level description of the program.
● This assignment cannot be completed in a few days and requires students to apply what we learn each week as we move closer to the submission date. Please remember to show your progress weekly to your tutor.
● You must keep up to date with the Moodle Ed Assignment 1A forum where further clarifications may be posted (this forum is to be treated as your client).
● Please be careful to ensure you do not publicly post anything which includes your reasoning, logic or any part of your work to this forum, doing so violates Monash plagiarism/ collusion rules and has significant academic penalties. Use private posts or email your allocated tutor to raise questions that may reveal part of your reasoning or solution.
The assignment must be submitted by Friday, 26 August 2022, 4:30 PM (AEDT).
The following files are to be submitted and must exist in your Group FITGITLAB server repo:
● A Jupyter notebook file (i.e., .ipynb file) that you created to implement your assignment (i.e, code and documentation). Name the file ass1_studentID.ipynb
● A PDF file. Use Jupyter Notebook to export a PDF file (Read the instruction provided on Week 2 Applied Class Activities, section 2.2. “How to Export a Jupyter Notebook to a PDF file?”. Note, The pdf file cannot be an image pdf file. Make sure all the text in the pdf file can be selected and copied). Name the file ass1_studentID.pdf
Do not zip these files into one zip archive, submit two independent files. The .ipynb file must also have been pushed to the FIT GitLab server with an appropriate history as you developed your solutions (a minimum of four pushes, however, we would strongly recommend more than this). Please ensure your committed comments are meaningful. Do not need to push the PDF file to the FIT GitLab server.
● No submissions will be accepted via email,
● Please note we cannot mark any work on the GitLab Server, you need to ensure that you submit correctly via Moodle since it is only in this process that you complete the required student declaration without which work cannot be assessed.
● It is your responsibility to ENSURE that the submitted files are the correct files. We strongly recommend after uploading a submission, and prior to actually submitting in Moodle, that you download the submission and double-check its contents.
● Please carefully read the documentation under the “Special Consideration” and "Assignment Task Submission" on the Moodle Assessments page which covers things such as extensions, correct submission, and resubmission.
● Please note, if you need to resubmit, you cannot depend on your tutors' availability, for this reason, please be VERY CAREFUL with your submission. It is strongly recommended that you submit several hours before due to avoid such issues.
● Marks will be deducted for any of these requirements that are not strictly complied with.
5. Academic Integrity
Students are expected to be familiar with the University Academic Integrity Policyand are particularly reminded of the following:
Students are responsible for their own good academic practice and must:
● undertake their studies and research responsibly and with honesty and integrity;
● credit the work of others and seek permission to use that work where required;
● not plagiarise, cheat or falsify their work;
● ensure that their work is not falsified;
● not resubmit any assessment they have previously submitted, without the permission of the chief examiner; appropriately acknowledge the work of others;
● take reasonable steps to ensure that other students are unable to copy or misuse their work; and
● be aware of and comply with University regulations, policies and procedures relating to academic integrity.
and Section 2.9:
Unauthorised distribution of course-related materials: Students are not permitted to share, sell or pass on to another person or entity external to Monash:
2.9.1 any course material produced by Monash University (such as lecture slides, lecture recordings, class handouts, assessment requirements, examination questions; excluding Handbook entries) as this is a breach of the Copyright Compliance Policy and such conduct may be a copyright law infringement subject to legal action; or
2.9.2 any course-related material produced by students themselves or other students (such as class notes, past assignments), nor to receive such material, without the permission of the chief examiner. The penalties for breaches of academic misconduct include
● a zero mark for the assessment task
● a zero mark for the unit
● suspension from the course
● exclusion from the University.
Where a penalty or disciplinary action is applied, the outcome is recorded and kept for seven years, or for 15 years if the penalty was excluded.
2022-08-12