Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Assignment 1
CSSE1001/CSSE7030
1 Introduction
The word-guessing game Wordle1 has recently gained huge popularity, and despite being fairly
simple, was recently sold to the New York Times for an undisclosed price “in the low seven
figures”. Once a day, players have up to six attempts to guess a word. After each guess, players
receive the following feedback:
• Letters from the guess that are in the answer and in the correct position are coloured green;
• Letters from the guess that are in the answer but not in the correct position are coloured
yellow; and
• Letters from the guess that are not in the answer are coloured grey.
Figure 1 demonstrates a partially and fully completed game of Wordle, where the answer is ‘ulcer’.
(a) A partially completed game. (b) The game is solved in three guesses.
Figure 1: Guess letters are coloured according to the rules, and keyboard letters are coloured
according to current known information.
1https://www.powerlanguage.co.uk/wordle/
1
In this assignment you will implement a modified text-based version of Wordle. CSSE7030 stu-
dents will also implement a simple solver to assist the user in making guesses during the game.
You are required to implement a number of functions as per Section 5 of this document.
2 Getting Started
Download a1.zip from Blackboard — this archive contains the necessary files to start this as-
signment. Once extracted, the a1.zip archive will provide the following files:
a1.py This is the only file you will submit and is where you write your code. Do not make
changes to any other files.
a1 support.py Do not modify or submit this file, it contains functions to help you implement
your tasks. You do not need to read or understand the code itself, but you should read
the docstrings in order to get an idea of how the functions work. This file also contains
some constants that will be useful in your implementation. In addition to these, you are
encouraged to create your own constants in a1.py where possible.
vocab.txt This is the file containing the entire vocabulary of valid guesses, including potential
answers.
answers.txt This is a reduced version of vocab.txt, from which answers will be randomly
chosen for each round. Separating answers from the greater vocabulary ensures all answers
are commonly known words, while allowing players to guess uncommon words.
examples/ This a folder containing example text file outputs from a working assignment 1 so-
lution. The purpose of these files is to help you analyse the formatting requirements (e.g.
amount of whitespace) of the output. Note that while you should be able to replicate the
CSSE1001 example exactly, those completing the CSSE7030 task may find their solution
produces different guesses to the CSSE7030 example while still being correct. However, all
other aspects of your ouptut should match the file (e.g. formatting).
NOTE: You are not permitted to add any import statements to a1.py. Doing so will result in
a deduction of up to 100% of your mark.
3 Gameplay
This section provides an overview of gameplay. For exact prompts and outputs, see Figure 2, and
Sections 5 and 6. When your program is run, the user should be prompted for their first guess.
When prompted for an input, users may do one of four (or five for CSSE7030 students) things:
1. Enter a guess. Guesses must be 6 letters long and exist in the known vocabulary. After a
valid guess is entered, all previous guesses should be displayed with their information, before
the user is prompted for their next guess.
2. Enter either ‘k’ or ‘K’. After displaying the keyboard information (see Section 5.8), the user
should be re-prompted for their guess.
3. Enter either ‘q’ or ‘Q’. The user is opting to quit the game, and the program should termi-
nate.
4. Enter either ‘h’ or ‘H’. The help message “Ah, you need help? Unfortunate.” should be
printed, and the user should be re-prompted for their guess.
2
5. CSSE7030 students only : Enter either ‘a’ or ‘A’ to have the solver make the next guess. See
Section 6 for more details.
If the user does not enter input that matches any of the above cases, it is assumed they have
entered an invalid guess. In this case, the user should be informed of the way in which their guess
is invalid (see Fig. 2 for the exact text you must match), before being reprompted for their guess.
The user continues until either:
• They win the round by guessing the word correctly within 6 guesses.
• They lose the round by entering 6 consecutive non-winning guesses.
• They quit the game by entering ‘q’ or ‘Q’.
At the end of a round, the user is informed of their outcome, along with their stats, before being
prompted for whether they would like to play again. At this prompt, the user can either:
1. Enter either ‘y’ or ‘Y’ to play another round, in which case another word is chosen from
the answers and another round commences with this new answer. You must not select the
same word twice.
2. Enter anything else, in which case the game ends and the program terminates.
Figure 2 shows example gameplay for a fully functioning CSSE1001 Assignment 1. Here, the
user opts to play two rounds, and then quit. If they had lost a round, the lose text should read
“You lose! The answer was: {answer}” with the correct answer substituted for {answer}. If you
have correctly handled the random selection of answer words, you should have the same first two
answer words, and be able to replicate this output exactly. You should also test your program
with other inputs.
4 Valid and invalid assumptions
In implementing your solution, you can assume that:
• All words (answers and full vocabulary) have exactly six letters. Any guess that does not
contain exactly six letters is invalid.
• All answers will consist of six unique letters. No duplicate letters appear in answers.
• Your program will not be tested with guesses containing uppercase letters.
• A guess is valid if it is present in vocab.txt.
• Your program will not be tested for more rounds than there are available answers.
You must not assume that:
• All valid guesses may only contain unique letters. While answers will not contain duplicate
letters, a valid guess could include duplicate letters.
• Guesses will only be valid 6 letter words. Your program will be tested with invalid words,
such as those containing special characters (e.g. non-letter characters) and words of incorrect
length. These situations must be handled as specified in Section 3.
• The vocab.txt and answers.txt files used in grading your assignment will be identical to
the ones given to you for development purposes. We may choose to mark your assignment
using new words in the contents of these files, though the file names and structure will stay
consistent.
3
Figure 2: Basic gameplay demonstration. Blue text is program output. Black text is user input.
5 Implementation
This section outlines the functions you are required to write. You are awarded marks for the
number of tests passed by your functions when they are tested independently. Thus an incom-
plete assignment with some working functions may well be awarded more marks than a complete
assignment with faulty functions. Your program must operate exactly as specified. In particu-
lar, your program’s output must match exactly with the expected output. Your program will be
marked automatically so minor differences in output (such as whitespace or casing) will cause
tests to fail resulting in a zero mark for that test.
4
Each function is accompanied with some examples for usage to help you start your own testing.
You should also test your functions with other values to ensure they operate according to the
descriptions.
Note: If you are using an IDE other than IDLE, the squares may render as a different size. Your
solution is correct if and only if it passes the tests of gradescope.
Also note: IDLE 3.9 will not run a solution to this assignment. If you are using IDLE to develop
you should use IDLE 3.10.
5.1 has won(guess: str, answer: str) -> bool
Returns True if the guess guess matches answer exactly. Otherwise, returns False.
Precondition: len(guess) == 6 and len(answer) == 6
5.1.1 Example usage
5.2 has lost(guess number: int) -> bool
Returns True if the number of guesses that have occurred, guess number, is equal to or greater
than the maximum number of allowed guesses (in our case, six). Otherwise, returns False.
5.2.1 Example usage
5.3 remove word(words: tuple[str, ...], word: str) -> tuple[str, ...]
Returns a copy of words with word removed, assuming that words contains word exactly once.
5.3.1 Example usage
5
5.4 prompt user(guess number: int, words: tuple[str, ...]) -> str
Prompts the user for the next guess, reprompting until either a valid guess is entered, or a selection
for help, keyboard, or quit is made. Returns the first valid guess or request for help, keyboard, or
quit. Note that the processing of the guess once it has been entered does not need to be handled
in this function; it will be handled in functions defined later in this section. The returned string
must be lowercase.
5.4.1 Example usage
5.5 process guess(guess: str, answer: str) -> str
Returns a modified representation of guess, in which each letter is replaced by:
• A green square if that letter occurs in the same position in answer;
• A yellow square if that letter occurs in a different position in answer; or
• A black square if that letter does not occur in answer.
While answers must contain 6 unique letters, guesses may contain duplicate letters. If duplicate
letters exist in the guess, only one can have a non-black square. If the letter doesn’t exist in the
answer, all occurrences of said letter in guess are given black squares. If the letter does exist in
answer, the non-black square is allocated as follows:
1. If one of the occurrences is in the correct position, it receives a green square and all other
occurrences receive a black square.
2. Otherwise, if no occurrences are in the correct position, the first occurrence of the letter in
guess receives a yellow square and all other occurrences receive a black square.
Precondition: len(guess) == 6 and len(answer) == 6
See a1 support.py for constants containing the required square characters.
5.5.1 Example usage