Lingo Gameplay Explanation

To see how the computer displays the status for a given guess, suppose the computer has chosen the secret word guava. Normally the user doesn’t know the secret word ahead of time, but let’s just assume it’s guava here as an example to illustrate how the game works.

We begin playing with the initial guess spray. Notice that there is only one letter in the guess that’s also in the secret target word (the letter a). After making a guess the status message will specify two things:

  • which letters are exactly correct (we’ll call these "exact matches")

  • which are somewhere in the target word, but currently in the wrong place (we’ll call these "inexact matches")

The status message indicates the guesser’s progress by UPPER-CASING all the exact matches, leaving the inexact matches in lower-case, and replacing all the wrong letters with dashes (i.e. letters that were guessed but don’t appear anywhere in the secret target word). So, in the current guava/spray case, where the letter a of our guess is an inexact match, we’d receive the status message:

---a-

Since we don’t know the word yet, we make another guess: arrow. Again, the only correct letter is the a, but now it’s in a different wrong place. So the status message we would receieve is:

a----

Our next guess is again. This time the guessed word has two a 's, as does the secret target word. The first guessed a is an inexact match (it’s in the wrong position) and will appear as lower case, but the second guessed a is an exact match (it’s in the correct position as the third character) and should show up as an UPPERCASE letter in the status. There is also a correctly guessed g but it is in the wrong position and will appear as lower case. Since neither the i nor the n appear in the target word, the status of this guess is the following:

agA--

Our next guess is games. While we already know there are no s 's i nthe word (because of our previous guess of spray), we can use games to see whether or not the target words contains an e or an m, and also to help find the exact position fo the g and the other a that we already know about. The status message, now that we have the g in the right position but the a still in the wrong position is as follows:

Ga---

Note: We the users/guessers know that the target word contains an a as the third letter. But Lingo status messages don’t aggregate all the information we’ve receieved so far! The status messages only tell us about the exact and inexact matches were from the immediately preceding guess.

Here is the remainder of our guava example as it might appear in a game:

Enter a 5 letter word: spray
- - - a -
Enter a 5 letter word: arrow
a - - - -
Enter a 5 letter word: again
a g A - -
Enter a 5 letter word: games
G a - - -
Enter a 5 letter word: curve
- U - V -
Enter a 5 letter word: suave
- U A V -
Enter a 5 letter word: guava
You won in 7 turns!

Handling user input

The user is only allowed to guess valid 5-letter words. If the user enters a word that is not 5 exactly letters long they should be warned: Invalid input. Enter a word with 5 characters. Try again…​ and prompted for another guess. There’s one exception to this rule: the user can enter QUIT in all CAPS. This should be considered a valid input and it ends the game. If the user enters a 5 letter word that’s not in our approved list of valid words then they should be warned: [your guess] is not a valid word. Try again…​ and prompted for another guess.

Below are a few sample runs of the full game to help make things clear. If you aren’t sure about how the game should behave in any particular case don’t hesitate to ask us!

Lingo Sample Runs

Example One

$ python3 lingo.py
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Welcome to Lingo!
  Each turn you will try to guess the secret word
  If you guess the word, you win
  If you guess some letters in the word, lingo will display:
    guessed letters in the correct position in upper case
    guessed letters in the incorrect position in lower case
Good Luck!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

word: - - - - -
Guess a 5 letter word: stack

word: s - a - k
Guess a 5 letter word: model

word: - - - - l
Guess a 5 letter word: lakes

word: l A k - S
Guess a 5 letter word: walks

word: - A L K S
Guess a 5 letter word: balks
You guessed the word balks in 5 tries
Congratulations!

Example Two

$ python3 lingo.py
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Welcome to Lingo!
  Each turn you will try to guess the secret word
  If you guess the word, you win
  If you guess some letters in the word, lingo will display:
    guessed letters in the correct position in upper case
    guessed letters in the incorrect position in lower case
Good Luck!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

word: - - - - -
Guess a 5 letter word: grumble
Invalid input. Enter a word with 5 characters. Try again...
Guess a 5 letter word: wee
Invalid input. Enter a word with 5 characters. Try again...
Guess a 5 letter word: wawas
wawas is not a valid word. Try again...
Guess a 5 letter word: stack

word: - - - - -
Guess a 5 letter word: model

word: - o - - L
Guess a 5 letter word: funny

word: - u - - -
Guess a 5 letter word: cloud

word: - l O U -
Guess a 5 letter word: ghoul
You guessed the word ghoul in 5 tries
Congratulations!

Example Three

$ python3 lingo.py
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Welcome to Lingo!
  Each turn you will try to guess the secret word
  If you guess the word, you win
  If you guess some letters in the word, lingo will display:
    guessed letters in the correct position in upper case
    guessed letters in the incorrect position in lower case
Good Luck!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

word: - - - - -
Guess a 5 letter word: stack

word: S - - - -
Guess a 5 letter word: model

word: - - d e -
Guess a 5 letter word: sends

word: S E - D S
Guess a 5 letter word: QUIT
The word you were trying to guess was: seeds
Better luck next time!