Implementation of a simple word-guessing game
-
Random Word Selection:
From the providedwords.txtfile a word is randomly selected.- It is in lowercase.
- It is 4 to 7 characters long.
- It contains only alphabetic characters (
a-z).
-
Guessing:
Allows the player to guess the word, with the number of allowed attempts equal to the length of the word. -
Initial Hint:
Before the first guess, the length of the word is disclosed. -
Feedback After Each Guess:
After each guess, the following hint is provided:- If a guessed letter exists in the word, it is displayed it in the correct position(s).
- Otherwise an underscore (
_) is displayed - Example: If the word is "sweet" and the guess is "ethos", the feedback is
s_eet.
-
Handling Invalid Guesses:
If the player's guess has a wrong length, it is not evaluated but still count as an attempt. -
Game End Conditions:
- If the user successfully guesses the word within the allowed attempts, a congratulatory message is displayed.
- Otherwise the correct word is revealed.
-
Replay Option:
After the game ends, the player may play again.
Example:
Welcome to the word guessing game!
Try to guess the word. It's 4 characters long.
You may guess up to 4 times. Good Luck!
1. Enter your guess: pear
__re
2. Enter your guess: ware
__re
3. Enter your guess: more
__re
4. Enter your guess: wire
_ire
Sorry, you did not guess the word. The word was 'tire'.
Play again? (yes/no):
WebApp Example:
The app is currently deployed on a linux server as a docker container. The instructions directory contains more details about the deployment workflows.
