Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
ML3 - Wordle
Summary:
There is a popular new game called Wordle in which the player attempts to guess a five
letter word using deduction and hints. Here, we will make a version of it using arrays and
functions using our MATLAB knowledge. I recommend starting early, as this game will take
some time to get the logic worked out correctly. For this assignment, each function needs to
be a separate file.
Skills to be Obtained:
● Implement looping, branching, arrays, and functions in Matlab
● Use functions that are separate files from the main script
● Read csv files
● Install a plugin from the Mathworks website (cprintf)
Details:
The game will require the player to determine a Northeastern-themed five letter word. To
crack the code, enter a five-letter word (all capital letters). Players get up to six (6) guesses to
match the five letter word before they lose. If the five letters entered are correct and in the
correct order, then the player has won. But they must meet both conditions (letters and order).
The starting word is chosen randomly from the list below and imported from a .csv file
that you will make. To make a .csv file, put the words into a spreadsheet program (excel, google
sheets, etc.) and put each word in its own cell. Then, use save as to make a .csv (comma
delimited) file. Import it into Matlab and double click on the array to see if it imported correctly.
Word list - please use all UPPERCASE letters:
● CABOT
● LIGHT
● SMITH
● LASER
● DRAFT
● SKILL
● ARRAY
● SMILE
● HAPPY
● HUSKY
● NORTH
● CIVIL
● DAVIS
● BREAK
● GREEN
● RYDER
● SNELL
● SPARK
● CURRY
● DODGE
Bring the .csv file into Matlab. Choose one of the words randomly and this word is the code
word the player will need to guess to win the game. I recommend outputting the word to the
user while troubleshooting, but in the final version, do not give the word to the player!
Once the code word is chosen, ask the player for their first five-letter guess. After each
guess, have the program send the player’s guess and the code word to a function that will
determine what information to give the player. In the function, print the guessed word with the
following conditions for each letter
1.) The letter is not in the code word at all = black text color
2.) The letter is in the word but not in the right spot (right letter + wrong place) = magenta text
color
3.) The letter is in the word in the correct location (right letter + right place) = green text color.
An example for the code word LEAVE is seen below. This function does not need to return
anything to the main script. We will use the ‘cprintf’ plugin to print colors other than black in the
output. This will need to be downloaded as a toolbox and installed. Please see the Appendix
for full details.
Print: Please enter your guesses as a sequence of five capital letters.
Guess 1. L A S E R
L A S E R
Guess 2. L L A M A
L L A M A
Guess 3. L E E D S
L E E D S
Guess 4. L E A V E
L E A V E
Print: You guessed the word. You win!
The most difficult thing about programming this game will be coding the logic that
determines which letters are correct. When a guess is entered, the function should determine if
letters are in the 1) correct location or 2) wrong location 3) not in the word at all. This logic is
complicated to get correct because there can be repeated letters in the guess and/or code word.
For example, in the game shown above, the 2nd guess contains two L’s. The first L is the match
for right letter/right loc. The second L does not get counted as a match because the L in the
secret word has already been accounted for. I highly recommend writing pseudocode for the
logic before you start coding!