Question
Wordle is a word game where the player attempts to guess a5-letter English word. Each incorrect guess receives feedback inthe form of colored tiles indicating
Wordle is a word game where the player attempts to guess a5-letter English word. Each incorrect guess receives feedback inthe form of colored tiles indicating how closely the letter matchesthe target word. This image shows a game with 4 guesses (arise,route, rules, rebus) for the target word, rebus.Guessed letters that exactly match the target word are marked greenwhile letters that are in the target word (but not in the rightposition) are marked yellow. Letters that aren't in the target wordare marked gray.
This result is typically expressed using apattern of square emojis: each square correspondsto a letter.
If you're having issues viewing the these emojis (e.g., they allappear as white boxes), please make a post on the message board sothat staff can help you get it fixed!
Absurdle is a variant of Wordle developed byqntm:
Wordle picks a single secret word at the beginning of the game,and then you have to guess it. Absurdle gives the impression ofpicking a single secret word, but instead what it actually does isconsider the entire list of all possible secret words whichconform to your guesses so far. Each time you guess, Absurdleprunes its internal list as little as possible, attempting tointentionally prolong the game as much as possible.
By completing this assignment, students will be able to:
Implement a well-designed Java class to meet a givenspecification.
Use sets and maps to create and manipulate nested collections ofdata.
Follow prescribed conventions for code quality, documentation,and readability.
A game of Absurdle
Suppose the Absurdle manager only knows the following 4-letterwords.
ally, beta, cool, deal, else, flew, good, hope,ibex
public String record(String guess)
The client calls this method to record a guess. Using the givenguess, this method determines the next set of words underconsideration and returns the pattern for the guess. Throws anIllegalStateException if the set of words is empty, and throws anIllegalArgumentException if the guess does not have the correctlength. Assume the guess contains all lowercase letters.
Implementation guidelines
Use TreeSet and TreeMap implementations for all sets and maps inthis assignment. When working with strings in this assignment, usethe length and charAt methods; don't call toCharArray as it willcreate an unnecessary extra char[] data structure.
patternFor(String word, String guess)
We can't use a char[] pattern because of limitations in the chartype for tiles. Your tiles must be stored asstrings!
If you want to run the code in jGRASP for debugging purposes,the tiles may or may not display correctly. In this case, you maywant to temporarily change the strings to other characters so thatit's easier to read.
record(String guess)
For each call to record, construct a Map to associate patternswith target word sets and use it to find all pick the patternassociated with the largest number of target words. When there aremultiple patterns that have the same largest number of targetwords, pick the pattern that appears first in the sorted order,i.e. the pattern that appears earliest when iterating over theTreeMap. The associated target words becomes the dictionary for thenext call to record.
It's necessary to construct a new Map on each call to recordbecause the patterns depend on the given guess!
Development strategy
Implement the constructor and the words method first. Then,implement and test the patternFor static method. If your patternFormethod is not working, your record method also will not work!
AbsurdleMain has two constants that you will want to change:
DICTIONARY_FILE represents the name of the file containing thelist of initial words. By default, it reads from dictionary1.txt,which contains the official list of 2309 5-letter words used inWordle. When testing, it may be easier to use the dictionary2.txtfile that only contains 9 4-letter words.
SHOW_COUNT is false by default; set it to true to see the numberof words under consideration.
---------------------------------------------
import java.util.*;
public class AbsurdleManager {
// TODO: Your Code Here
// The comment for this method is provided. Do notmodify this comment:
// Params:
// String word -- the secret word trying to beguessed. Assumes word is made up of only
// lower case letters and is the same length as guess.
// String guess -- the guess for the word.Assumes guess is made up of only
// lower case letters and is the same length asword.
// Exceptions:
// none
// Returns:
// returns a string, made up of gray, yellow,or green squares, representing a
// standard wordle clue for the provided guessmade against the provided secret word.
public static String patternFor(String word, Stringguess) {
}
}
Step by Step Solution
3.39 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
implement the AbsurdleManager class based on the given requirements Heres the complete implementation java Copy code import javautil public class Absu...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started