Rules of the Wordle Game
The aim of the game is to guess a hidden target 5-letter word within 6 attempts. The rules of the game are simple, and are given below but I suggest you just play the version available at the New York Times website first to understand the game (https://www.nytimes.com/games/wordle/index.html).This is a single player game where the player plays against the computer by making guesses of 5-letter words.
An English word consisting of five letters is selected at random (by the computer) from a list of words, but kept hidden from the human player. The player tries to guess the 5-letter word. The player is allowed to make 6 guesses in total to discover the target word. The player is given feedback after each attempt they make. The feedback is as follows;
There are three colours that the cells containing the letters can be; green, yellow, or grey.
1. Green means the letter is contained in the word and is in that position.
2. Yellow means the letter is contained in the word but not in that position.
3. Grey means the letter is not contained in the word.
Detail of Implementation
You should decide what to do if the user does not enter five letters (or how to force the user to only submit words of 5 letters). For example, if the user enters only 4 letters or instead enters numbers (do you issue a warning message? Or do you prevent this from occurring in the first place?). The five letters should also be an English word (how will you handle guesses that are not English). You will need to obtain a list of 5-letter English words.
The player can only make guesses which are 5-letter English words. You can implement this by having a file containing a large number of five letter words (search on the internet for data which you can store in a file. What format will you use?).
Think about how you will obtain the input from the player (e.g. via a virtual keyboard or via the physical keyboard).
The game can complete in one of two ways. Either the player guesses the correct target word within 6 guesses (a win), or the player makes a total of 6 guesses and does not correctly guess the target word (a lose).
Basic Framework of the Game
You should consider the following parts to help you in your software design.
1/ The Initial set up.
· displaying the interface and picking a target word for the player to guess.
2/ Obtaining the player input (5 letter word) and supplying feedback.
· How to obtain the input from the player?
· Deciding what colours to display the cells containing the letters (green, yellow, or grey).
· Updating the display according to the player’s guess.
3/ Game Termination
· Terminate the game (either the word is guessed correctly, or the player has used all of their 6 attempts).
· You could ask the player if they want to play again.
Hints
As we are implementing this on a laptop you can enter the text via a text field (which takes its input from the keyboard) rather than having a virtual keyboard like the New York Times website version.
Plan out your interface. It is tempting just to start to write the code. However, you should pause and think before you start coding. Ask yourself where will the buttons and labels sit on your interface? It is probably best to plan this out beforehand using a pencil and paper rather than trying to struggle with the coordinates while you are programming. Do you display the correct word at the end of a game if it was not guessed correctly?