Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED TO USE MATLAB FORMAT with proper programming standards. Wordle is a word-guess game where a player attempts to guess a 5-letter English word

I NEED TO USE MATLAB FORMAT with proper programming standards.

Wordle is a word-guess game where a player attempts to guess a 5-letter English word in 6 tries or fewer. The player starts the game with a 5-letter guess. The code compares the guess to the solution word. If a letter in the guess is in the exact location in the solution, the code indicates that letter is in the correct spot by leaving the letter in the word. If a letter in the guess is present in the solution but in a different location, the code indicates that letter is in the word but not in the correct spot by replacing the letter with a *. And if a letter is not present in the solution at all, the code indicates that by replacing the letter with a -. See the example below. Guess 1: movie Result 1: **--* >>> M, O, E are in the solution but in different places. I, E are not in the solution. Guess 2: paint Result 2: ***-t >>> P, A, I are in wrong places. T is in the correct place. N is not in the solution. Guess 3: cycle Result 3: cycle >>> All letters in the correct place - the guess matches the solution in six or fewer attempts. For this problem, we have to will write own Wordle game. The games code will be a no-input, no-output function that displays game information to the Command Window for the player.

Your game code will A. Need to call a provided UDF to obtain a 5-letter solution word from a pre-defined dictionary (using wordle_dictionary.p, which is explained below). Words from the dictionary will be lowercase and will have no repeating letters. a. Use 2002 as the dictionary key value. B. Ask the user to input a 5-letter guess. If the input is not exactly 5 characters, the code must continue asking the user for a valid entry until a 5-character input is provided. a. The game play does not end if a player guesses an invalid guess (neither a planned stop nor an unplanned stop with a MATLAB error). b. You do not need to check for real words or for non-letter characters. c. You will use the input command to ask for the word. Use the format CHAR = input(PROMPT,'s'), where PROMPT is your text that the player sees, s allows the player to enter text without quotemarks, and CHAR is the character array containing the characters of the guess. See help below for working with character arrays. C. Allow the user a maximum of 6 valid guesses. The code must keep asking the player to enter a guess until either the solution word is guessed correctly or the guess limit is met. a. A guess only counts towards the limit if it is a valid guess with exactly 5 characters. Invalid guesses (see Part B) do not count as part of the 6 guesses. b. Stop the game if the solution is not found within the guess limit (i.e., the player makes 6 incorrect but valid guesses). c. Stop the game when the player guesses the solution word correctly within the guess limit. D. Display appropriate information for each guess. a. Display the guess number for every valid guess. b. Display the guess word so it is aligned over the solution information (follow the pattern in the example in the problem introduction). i. A found letter in the correct location displays the letter. ii. A found letter in the incorrect location displays a * character. iii. A letter not in the solution displays as a - character. iv. Your code only needs to work for guesses with 5 unique letters (i.e., no repeated letters). Remember that the solution word also has 5 unique letters. You are not responsible for any extra logic needed to check words with repeated letters. c. If the player uses 6 valid guesses without correctly guessing the solution word, display an indication that the word was not guessed within the limit and display the solution word. d. If the player guesses the solution, display an indication that the guess is correct. To make your code function properly, you need to work with character arrays. You have made character (char) arrays if you use single quotes around text characters (e.g., var = 'Test 1'). You can use indexing and replacement techniques to find and replace characters inside a char array. You can use logical operators with characters in char arrays. You can use array size commands (length, numel, size, etc.) on char arrays as well. Run the following code in MATLAB to see what happens: txt_var = 'Test 1'; % define txt_var as char array txt_var(1:4) = 'QUIZ' % replace first 4 characters of txt_var length_check = numel(txt_var) == 6 % check that txt_var is 6 characters (1=true) if length_check % if length_check is true txt_var(6) = '2' % replace the 6th character with 2 end You have been provided a file named wordle_dictionary.p, which you will use the obtain the solution word. Here is% Function Call % todaysword = wordle_dictionary(key) % % Inputs % key = an integer between 100-999999 (inclusive) % % Outputs % todaysword = 5-letter character array that is a 5-letter lowercase English word

The output word will have 5 unique letters (i.e., no repeated letters). Character arrays are case sensitive and wordle_dictionary outputs lowercase letters only. The dictionary will choose a word from among 1562 words. Changing the key value will change the word. For this assignment, call the dictionary function with the key value 2002.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Whats My Comfort with Change?

Answered: 1 week ago

Question

What is the difference between accrual and deferral accounting?

Answered: 1 week ago