LEARNING OBJECTIVES:
- Practice working with loops, files, and dictionaries
- Practice working with and completing existing programs
In this assignment, you will be working on graphical or “GUI” version of Wordle! While much of the program is already complete, your job will be to understand the existing program and functions, and use those to complete the full version of not just Wordle…but SUPER Wordle. Instead of only 5 letter words, Super Wordle will allow you to pick words from length 2 to 15 (but still only allow you six guesses). You’ll need to download all 3 files below.
Template File | Ex7 Module File | Wordle Word List File |
---|
Note: Depending on your browser, you may need to right click on the wordlist button and select “Download linked file…” or “Save linked file as…”. Make sure to save it as
NWL2023.txt
.
PLEASE NOTE: While you only have to write new code in the parts that are marked
TODO
inexercise_7.py
, you’ll need to understand the other functions inexercise_7.py
andcs110_ex7.py
in order to know how to use them to complete the assignment. You can search for theTODO
tags using the File menu then “Search” in IDLE. THIS MEANS YOU WILL NEED TO LOOK AT THE EXISTING CODE AROUND THE TODOs to see what is done already and what you'll need to fill-in. DON'T JUST START WRITING CODE. First, understand what's there THEN start editing. To that effect, the documentation for all the functions across the two files is available below:
Template Docs | Ex7 Module Docs |
---|
Activity 1. Adding a difficulty selector
Find the get_difficulty
function. Complete the TODOs inside of the function’s body to make it behave as the documentation explains. Note, instead of using our usual input
function, the template uses a fancy version (simpledialog.askstring
) which presents as a pop-up window and returns whatever the user typed in as a string. Remember, you only need to take care of the TODOs.
Activity 2. Reading in the words for the game
Adapt your code from the tutorial to finish the implementation of the read_in_words
function. Note that this function behaves the same as the tutorial, except it has an additional argument that specifies how many letters should be in words it adds to our word list.
Activity 3. Generating hints
Adapt your code from the tutorial to finish the implementation of the generate_hint
function.
Activity 4. Play the game!
At this point, your Wordle game should function as you might expect (like normal Wordle) as long as you enter a difficulty of 5. Try it out and make sure things are working! If they aren’t, go back to the three functions you worked on. Add print
statements to help you debug.
Activity 5. Extending to Super Wordle
Your final task is to complete the “abstraction” process to make Super Wordle work with any difficulty entry from 2 to 15. Search through the rest of the .PY file and complete the remaining TODOs which ask you to consider how to abstract their respective functions. Including the one found inside of generate_hint
, there are 7 TODOs that ask you to do this. Keep in mind that depending on which function you’re working on, you might have direct access to a variable like num_letters
, you might need to find the length of a variable like guess
or solution
, or you might need to access the "num_letters"
key of the GAME_DATA
dictionary.
Checklist. Before You Submit
Before you submit, make sure you’ve tested that your program does the following:
- When you run it, you get a popup window asking for you to enter a difficulty rating
- if you enter something that isn’t an integer your program should stop
- if you enter a number bigger than 15 or less than 2, your program should stop
- Reads in a list of
n
-letter words from any given file name- Only allows the user to enter
n
letter words
- Only allows the user to enter
- Does not print out anything to the Interpreter window except:
- (Optional) print out the solution to the puzzle in the interpreter window
- If a user hits ENTER and hasn’t entered
n
letters don’t accept it as a guess (you’ll see a message printed to the interpreter) - If a user hits ENTER and has entered an INVALID word don’t accept it as a guess (you’ll see a message printed to the interpreter)
- You do not need to worry about the case where the user enters the same word multiple times
- After each guess, Wordle responds with the correct hint and moves to the next line
- Guesses currently being entered are black text on a white background
- Previous guesses are rendered in white text
- The squares for letters in a previous guess are colored thusly:
- Completely correct letters will have a green background
- Partially correct letters will have a yellow background
- Letters that don’t appear will have a grey background
- The user can only make 6 valid guesses (the game will be unplayable after that)
- If the user guesses correctly, they should see a popup message
Credits
This assignment is obviously inspired by the original Wordle now owned by the New York Times.
The word list we’re using is from the 2023 North American Scrabble Championship which is supported by NASPA.
What to Submit
Before you submit, make sure to go through the checklist to make sure everything is good-to-go. Once it is, submit only your exercise7.py
file to Canvas by the deadline.
Submission Details
Remember, close IDLE before you submit to ensure that you’ve saved your latest work. Once you’ve successfully submitted you should receive feedback from the autograder in 30 or so minutes. If you fail one of the checks, you’re welcome to resubmit (up to the Canvas resubmit limit for that assignment). If you’re confused on how to fix one of the checks, then bring your submission and the test results to office hours!