Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ive asked this question before but the coding was wrong, please answer with original coding The beloved word-guessing game WORDLE is back! And you get

Ive asked this question before but the coding was wrong, please answer with original coding

The beloved word-guessing game WORDLE is back! And you get to implement it.

You will write all of your code in a python script named wordle.py. We have given you an empty file named wordle.py to get you started.

Command line arguments

Your program should take two command line arguments:

  • word bank : the file name of the word-bank file
  • guesses allowed: the maximum number of guesses allowed

For example:

python wordle.py wordle-answers-alphabetical.txt 6

This tells the program to use wordle-answers-alphabetical.txt as the word bank, and 6 as the maximum number of guesses allowed.

The word bank file contains a list of 5-letter words, each word on its own line. We have provided you with a file called wordle-answers-alphabetical.txt that you can use to play the game.

The player can guess up to the maximum number of guesses. For example, classic WORDLE gives you 6 guesses.

Playing the game

  • The program picks a random word from the word bank that the player will guess
  • For each attempt:
    • The program prompts the player with the text: "Guess # {attempt}: " where {attempt} is the round the player is on.
    • The player guesses a word
    • The program shows the player the result of their guess, using the following characters:
      • A ! indicates that the letter matches the answer exactly
      • A ? indicates that the letter is in the answer, but it is in the wrong position.
      • A * indicates that the letter is not anywhere in the answer
      • See the examples below
    • If the guess is correct or the number of allowed attempts has been exceeded, the program concludes
      • Otherwise the user is prompted for a new guess
    • At the end of the game, if the last guess is correct, the program displays Way to go!, otherwise Maybe next time. The answer is {answer}.
      • where {answer} is the secret word chosen from the word bank.

Important notes on the rules

The logic for scoring a guess differs slightly from the original WORDLE game. The primary difference is in how duplicate letters are handled.

For this project, use the logic described above. Note that if a guess contains two occurrences of the same letter, and one of them is in the right place, then the second occurrence will still show ?. For example:

Secret: topaz
Guess: tooth
Result: !!??*

The first t and o match the secret word exactly, so they are replaced with !. the second o and t are not exact matches, but because t and o are present in the secret word somewhere else (the locations matched by the first t and o), they are replaced with ?. Finally, the h does not match the secret word at all, so it is replaced with *.

Examples

Here is an example showing the program being run from the command line.

$ python wordle.py wordle-answers-alphabetical.txt 6 Guess # 1: alien ***** Guess # 2: tours *???* Guess # 3: proud *??!* Guess # 4: forum *??!* Guess # 5: occur !!!!! Way to go!

The secret word was occur. alien matches none of the letters anywhere, so it was completely replaced with *****. For tours, the o, u, and r match, but not in those positions, so they are replaced with ?; the t, and s dont match at all, so they are replaced with *, resulting in *???*. Etc.

Another example:

$ python wordle.py wordle-answers-alphabetical.txt 6 Guess # 1: tooth ?**?* Guess # 2: train ?*?** Guess # 3: attic ???*? Guess # 4: catch ?!??* Guess # 5: pacts *!!?* Guess # 6: match *!??* Maybe next time. The answer is facet.

And another:

$ python wordle.py wordle-answers-alphabetical.txt 2 Guess # 1: maybe **??* Guess # 2: beany !***! Maybe next time. The answer is buggy.

In this example, the player passed 2 on the command line, indicating that only 2 guesses should be allowed. After those guesses, the game is over.

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

=+1. How can the process of movie utilization be described?

Answered: 1 week ago