Assignment 1
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Assignment 1
Introduction
Assignment Overview
The assignment is an individual assessment. It contributes 30% of your inal marks. The assignment consists of a programming exercise and a skill-based test (viva).
The due date for the programming exercises is on 28th March 2023, 11.59 pm (Sydney time). The skill-based test will be held on weeks 7-8, refer to your own timetable for assessment time.
This is an assignment, and staf are not permitted to give guidance on your code or how to solve the
speciic problem. That is the purpose of the assessment that you are required to perform to achieve the grade.
You may ask clariication questions about the assignment description. This is often necessary to implement functionality that is otherwise ambiguous.
If you have a question to ask on Ed please search before asking. However, remember that you should not be posting any assignment code publicly, as this would constitute academic dishonesty. Also, do not wait too long before starting. This assignment needs time and sustained efort.
Late submissions are not accepted unless an approved special consideration is granted.
The minimum requirement for the viva is passing at least ive testcases.
Restrictions
You cannot use for, in, lambda, global, classes, and all standard imported modules except numpy , math and
random .
A submission containing a ile longer than 3000 lines or larger than 500kB will not be accepted. To check the ile sizes of your iles, use the bash command ls -s --block-size=KB in the terminal.
Programming Exercises
All submissions must be made via Ed, including any supporting documentation that is produced during the planning of the program design such as lowcharts, pseudocodes, and UML class diagrams.
To make a submission, you will need to press the "Mark" button. You may submit as many times as you wish before the due date.
After each submission, you will be able to view all the previous submissions and their iles in the code submission section.
The following rules apply to your submission:
Your submission must be able to compile and run within the Ed environment provided. Only the iles given in the scafold codes will be started by the auto-marker.
The marking system will automatically check your code against the public test cases.
Ensure that you have submitted your codes with the correct ile names. The auto-marker will only start the iles that are speciied in the question.
The Python version that is presently being used on the Ed system:
$ python3 --version
Python 3.10.8
Help and feedback
You are encouraged to ask questions about the assignment during the Helpdesk and on the Ed discussion board; however, remember that you should not be posting any assignment code publicly, as this would constitute academic dishonesty.
Skill-based test
The maximum duration of the test is exactly 20 minutes. You will be asked questions to demonstrate, debug, trace and explain your work during the session. There will be sample questions provided for you to prepare and practice for the session. The examiner may ask questions that will not be included in this list of sample questions.
You must have your webcam turned on AND must be able to share your computer screen (to demonstrate your Ed submission) during the session. All sessions will be recorded and kept for documentation purposes in accordance with the university requirements regarding oral examinations.
Marking Criteria
Your marks for the assignment will be determined based on the number of test cases passed for each question as well as your performance during the skills-based test according to the following weights:
Automatic Tests (10/30)
Your marks for this component will be the ratio of the number of test cases passed to the sum
of all the public test cases administered. There will be public, hidden, and private test cases administered on your submission. The private test cases will only be applied after the deadline and will be diferent from the examples given. There will be public test cases available for feedback purposes - to allow you to test the conformance of your program with respect to the description but these do not test all the functionalities described in the assignment. It is important that you thoroughly test your own code.
Public testcases are the testcases that you can see in your submission before the due date.
Skills-based Test (20/30)
The examiner may ask you questions that require you to write, explain, trace and debug your codes. Marks will be awarded for each question based on the following descriptors:
No marks:
The candidate is unable to answer the question or the response is mostly incoherent.
Partial marks:
The candidate can respond to the question but after multiple attempt probes or some programming terminologies used in their explanation are incorrect.
Full marks:
The candidate is able to correctly respond to the question using the correct programming terminologies in their explanation.
Student Declaration
By submitting this assignment, you declare the following:
I declare that I have read and understood the University of Sydney Student Plagiarism: Coursework Policy
and Procedure, and except where specically acknowledged, the work contained in this assignment/project is my own work and has not been copied from other sources or been previously submitted for award or assessment.
I understand that failure to comply with the Student Plagiarism: Coursework Policy and Procedure can lead to severe penalties as outlined under Chapter 8 of the University of Sydney By-Law 1999 (as amended). These penalties may be imposed in cases where any signicant portion of my submitted work has been copied without proper acknowledgement from other sources, including published works, the Internet, existing programs, the work of other students, or work previously submitted for other awards or assessments.
I realise that I may be asked to identify those portions of the work contributed by me and required to demonstrate my knowledge of the relevant material by answering oral questions or by undertaking supplementary work, either written or in the laboratory, in order to arrive at the nal assessment mark.
I acknowledge that the School of Computer Science, in assessing this assignment, may reproduce it entirely, may provide a copy to another member of faculty, and/or communicate a copy of this assignment to a plagiarism checking service or in-house computer program, and that a copy of the assignment may be maintained by the service or the School of Computer Science for the purpose of future plagiarism checking.
Assignment Overview
Your task is to create a program that is a text-based version of the Mousehunt game. In this game, the Kingdom is overrun by mice. Users play the role of a hunter to help the King eradicate the mice. The King rewards successful hunters with recognition (in terms of points) and gold in return for successful hunts. Although the actual game is rather complex, to make it a reasonable scope for Assignment 1, you will only be creating a simpliied version of the game:
A single player game desktop version of the game that contains:
one location e.g. Meadow
one mouse e.g. Brown
three types of traps e.g. High Strain Steel Trap, Hot Tub Trap, Cardboard and Hook. The type of trap in this assignment does not have any efect on the hunt outcome in Assignment 1. one type of cheese e.g. Cheddar.
These are the features that your game must have:
1. Game Title
The is the irst thing that players see when the game is loaded. It should include details of the team behind the game. See 1. Game Title for more details about this feature.
2. Set hunter name
After the game title, the game must prompt the user to provide a in-world name. It must meet the game requirements, otherwise the game will set a default name. See 2. What's ye called? for more details about this feature.
3. Game Tutorial
After players have set up their name, the game introduces players to the basics of the game particularly the conditions that players must fulill to successfully catch a mouse. See 4. The Training for more details on this feature. The game also makes sure that players understand the basics before starting the game by automatically repeating the game tutorial until players opt to proceed. See 5. The Training Again.
4. Cheese Shop
The game must allow players to buy cheese to replenish their supply during the hunt. There will only be Cheddar in Assignment 1. Players can view their inventory, what their in-game character is carrying while in the Cheese Shop. All hunters typically have a mouse trap, cheese and gold in the inventory. See 6. PIAT The Cheese Shop for more details about this feature.
5. Game Menu
Players must be allowed to decide what they want to do in the game: quit game, buy cheese or join the hunt.
6. The Hunt
This is where the players attempt to catch a mouse. The game must periodically check with
players if they want to persevere in their hunt if they are consistently unsuccessful in their hunt. See 7. PIAT The Hunt for full details about this feature.
Log of Fixes
A log of ixes made to Assignment 1. These consist of:
Buggy test cases.
Typos in the question description.
The question description lacking suicient detail.
If the example output in the question description and the output checked by test cases don't match, only the test cases will be changed to make it match .
Anything important in this log will be highlighted in a warning callout that looks like this.
Hopefully this does not happen, but any extreme issues addressed in this log will be highlighted in an error callout .
Pinned Extreme Issues
10th March
11:26PM: Fixed a bug that allowed some test iles to be overidden. For those who have inished the assignment, please resubmit your code as you may have unintentionally done this.
Pinned Fixes
2nd March
9:38AM: Added a statement that lowcharts must be submitted, else you cannot be marked on it.
5:06PM: Added a statement that lowcharts should ideally be neither overly-complicated (list out every single detail), yet not be overly-simple (have little to no detail). It is okay to simplify/summarise some details, but the lowchart needs to be able to represent your code.
7:35PM: Added the following statement in 6: The Cheese Shop:
You must utilise the if __ name__ == __main__ expression which will determine if it runs your code. If you do not use this, you will likely not pass any of the test cases that test your functions alone. This has been provided to you in the code scafold.
3rd March
11:19PM: In the mandatory section in the Slide Submission, it stated A PDF file containing all the flowcharts for question 4 to question 7 . This has been changed to A PDF file containing all the flowcharts for question 4, 5 and 6 .
Fixes
28th Feb
1:43PM: Fixed the output of Example 2 - starts with a number in 2. What's ye called? The output
originally had hwich is less than 10 but has been ixed to be between 1 to 9 characters .
7:26PM: Fixed the wording of explanations in Scenario 1, 2 and 3 in 4. The Training.
7:30PM: Fixed the output of Sample Input/Output - Valid Command in 4. The Training. It
originally had the line Excellent choice . but has been ixed to Larry: Excellent choice . .
7:43PM: Added a Scenario 4 in 4. The Training. It shows what happens when a player has a trap
but does not sound the horn.
1st March
1:01PM: Fixed a bug when buying either 0 cheese or negative cheese, the test cases checked if
the message printed was Must purhcase a positive amount of cheese . . This has been ixed to the check the correct message of Must purchase a positive amount of cheese . .
1:12PM: Fixed an inconsistency where when buying cheese for test cases in 6. PIAT: The Cheese
Shop, the specs have the output State [cheese quantity]: but the test cases checked the output State [cheese_type quantity]: . The test cases have been ixed to match the specs i.e. the test cases check State [cheese quantity]: is outputted when buying cheese.
8:59PM: Fixed test case 6: top tier window shopper [previva] that still checked if the output
message is State [cheese_type quantity]: when buying cheese. This has been ixed to check if the output message is State [cheese quantity]: .
9:04PM: Fixed second output example under 2. View Inventory in 6. PAIT: The Cheese Shop that
still had a State [cheese_type quantity]: . This has been ixed to State [cheese
quantity]: .
9:08PM: Fixed one of the hidden tests for 6. PAIT: The Cheese Shop.
9:15PM: Fixed output of test cases in 7. PIAT: The Hunt as it did not it the description. The
description has Caught a Brown mouse! , but the test cases tested Caught a brown mouse! . The test cases have been ixed to check Caught a Brown mouse! .
9:18PM: Fixed output of test cases in 7. PIAT: The Hunt as it did not it the description. When
asking What's ye name, Hunter? , it did not check if the input was on a newline. This has been ixed such that you must have a newline such that they enter their name on a newline.
2nd March
12:25AM: Made it explicit in the description that the 5 consecutive fails occur regardless of the validity of the command or the amount of cheese you have. If you didn't catch a mouse 5 times, you will be prompted if you want to continue.
12:52PM: Fixed an inconsistency where when buying cheese for test cases in 7. PIAT: The Hunt, the specs have the output State [cheese quantity]: but the test cases checked the output State [cheese_type quantity]: . The test cases have been ixed to match the specs i.e. the test cases check State [cheese quantity]: is outputted when buying cheese.
4:26PM: Provided annotations of the image in 1. Game Title for further clariication of what the
value each variable stores.
5:52PM: Fixed code snippet in hard coding section in Submission slide that had a spare closing
parantheses int(input())) .
3rd March
11:05PM: Added a Scenario 3 in Section 1. Buy Cheese in Slide 6. PIAT: The Cheese Shop which
shows output when an invalid purchase is made.
5th March
8:46PM: In Slide 3. Functions, the question description had is_valid_one_word , which is not
consistent with either the scafold given or the test cases. The description was edited for the function name to be is_one_word .
7th March
7:34PM: Fixed a private test case in 7. PAIT: The Hunt that still tested the output Caught a brown mouse! . This has been ixed to check the output Caught a Brown mouse! .
10:36PM: In Slide 7. PAIT: The Hunt, an extra line was added about the trap kept at the end of
the training module. It has been made explicit that only the last training session matters. Added the line: The trap is reset each time the player retakes the training module .
8th March
1:37PM: Fixed another code snippet in hard coding section in Submission slide that had a spare
closing parantheses int(input())) .
14th March
12:18PM: Fixed output snippet in Slide 7. PIAT: The Hunt that had a gap after Do you want to
continue the hunt? and Sound the horn to call for the mouse . . . . This has been ixed to have no gap.
1. Game Title (1 mark)
This question requires contents from Week 1 and Week 2.
Write your solutions for this question in q1 . py .
Display the title of the game, its logo and credits. There must be a new line separating the title, logo and credits as shown in the igure below:
In your program, you must initialise the following four (4) variables to store the relevant values.
title to the title of the game.
logo to the logo (mice art) of the game.
author to the author of the game.
credits to the credits of the game.
In q1 .py , you've been provided the author , as well as an uninished credits as a format string. You've also been provided the ASCII art of the mice art.
This is an example output when the program is executed.
$ python3 q1 .py
Mousehunt
____ ()()
/ @@
`~~~~~\_ ;m__m ._>o
Inspired by Mousehunt© Hitgrab
Programmer - An INFO1110/COMP9001 Student
Mice art - Joan Stark
Copyright symbol: https://www.ascii-code.com/CP1252/169
2. What's ye called? (1 mark)
This question requires contents from Week 2.
Write your solutions for this question in q2 . py .
Upon loading the game, the player will be asked to provide their name and taught the basics of mouse hunting by Larry, the instructor.
Larry can only pronounce names that meet all the following requirements:
Must have a length between 1 to 9 characters (inclusive).
Must start with an alphabetical character. In the case of an empty string, it trivially does not start with an alphabetical character so it fails this requirement.
Must be a single word i.e. no spaces between characters. You can assume that words that start or end with a space are not a single word. In the case of an empty string, it is not a single word as it isn't word at all, so it also fails this requirement.
Write Python statements to:
1. Assign the value provided by the user to variable name .
2. Assign the result of checking that name has a length between 1 to 9 characters (inclusive) to variable is_valid_length .
3. Assign the result of checking that name starts with an alphabetical character to variable
is_valid_start .
4. Assign the result of checking that name is a single word to variable is_one_word .
5. Assign the result of checking that name fulils all the requirements given to is_valid_name . You must use all the previous variables in this statement.
The program must display the results of Larry's internal thoughts as he works out whether the new Hunter name is pronounce-able. These are example outputs when the program is executed. Note that the user inputs are prepended by # and should not appear in your program.
Example 1 - valid name
$ python3 q2 .py
Larry: What's ye name, Hunter?
#info1110
Larry: Is 'info1110' a name I can pronounce?
It has a length of 8 which is between 1 to 9 characters? True!
It starts with an alphabet? True
It is a single word? True
Larry: I can pronounce this name --- True
Example 2 - starts with a number
$ python3 q2 .py
Larry: What's ye name, Hunter?
#12coolio
Larry: Is '12coolio' a name I can pronounce?
It has a length of 8 which is between 1 to 9 characters? True!
It starts with an alphabet? False
It is a single word? True
Larry: I can pronounce this name --- False
Example 3 - 12 characters
$ python3 q2 .py
Larry: What's ye name, Hunter?
#supercoooool
Larry: Is 'supercoooool' a name I can pronounce?
It has a length of 12 which is between 1 to 9 characters? False!
It starts with an alphabet? True
It is a single word? True
Larry: I can pronounce this name --- False
3. Functions (2 marks)
This question requires contents from Week 3.
Write your solutions for this question in name . py .
In this question, you are required to work with functions.
In the last question, you took in a name from user input, assigned boolean values to some variables dependent on the name, and used it to output a few lines to determine if Larry can pronounce the
name.
This question is a bit diferent. You only have one task, and that is to implement and write your own functions to determine if Larry can pronounce the user's name.
You should not be taking in input, nor producing any output anywhere in your code. Each function takes in a parameter name , and you will need to implement the correct logic for each function to return True or False depending on the conditions speciied below. That is all.
Please read carefully .
Implement the function is_valid_length which has one parameter, name , and returns True if name has a length between 1 to 9 characters (inclusive). Otherwise, the function should return
False .
Implement the function is_valid_start which has one parameter, name , and returns True if name starts with an alphabetical character. Otherwise, the function should return False .
Implement the function is_one_word which has one parameter, name , and returns True if name is a single word. Otherwise, the function should return False . We have already deined what is a single word, but we will recite here. It is a single word if it has no spaces between characters. You can assume that words that start or end with a space are not a single word. In the case of an empty string, it is not a single word as it isn't word at all.
Please remember that the three functions do not overlap. As an example, you should not be testing in the is_valid_ length function if name starts with an alphabetical character. These functions are completely separate from each other and have no knowledge of each other.
Write a function called is_valid_name which has one parameter, name , and returns True if Larry can pronounce name , that is, it has a length of between 1 to 9 characters (inclusive), it starts with an alphabetical character and is one word. Otherwise, the function should return False . You may have noticed that you have implemented the 3 requirements for Larry to pronounce the name as separate
functions above. We recommend that you use the 3 functions above for the implementation of this function. Apart from making the solution simpler, it will also make the code more readable and
reusable, as well as prevent code duplication/logic.
Below are some examples of the values returned by each function with the following arguments:
is_valid_length('abcdefghijkl')
is_valid_length('123')
-> returns False
-> returns True
is_valid_start(' . . . ') -> returns False
is_valid_start('info1110/comp9001 is the best!') -> returns True
-> returns False
-> returns True
Remember that these three functions do not overlap. That is why as an example, can accept a name with multiple spaces.
is_valid_start
is_valid_name('__two_cents__ ')
is_valid_name('g8rthunt')
-> returns False
-> returns True
It is only the is_valid_name function that each requirement must be satisied for the function to return True .
DO NOT hard code for
2023-03-28