This package lets you play a version of the WORDLE game in R. You can either play interactively in the console, or programmatically to explore different solvers (for example).
Players must attempt to correctly guess a five-letter word in (at most) six attempts.
After each guess, the letters are coloured to indicate how well the guess matches the target word.
Green letters are in the word and in the right position (but may be repeated elsewhere). Yellow letters are present (at least once) somewhere in the target word.
Each guess must be a valid word.
To play a game in the console, call the play_wordler()
function.
You can emulate the original game’s Hard mode by passing
hard_mode=TRUE
.
First, initialise a new game.
This returns a list which represents the game state. We’ll have a look at the items in this list after we’ve made a few guesses.
Use have_a_guess()
to submit a guess of the target word.
We’ll make a few guesses below.
game <- have_a_guess("SQUID", game, allowed_words = c(wordle_answers, wordle_allowed))
game <- have_a_guess("VIDEO", game, allowed_words = c(wordle_answers, wordle_allowed))
The allowed_words
argument is a character vector used to
validate the guesses. The guess must be present in this vector to be
permitted. If the guess is not in allowed_words
, a message
is displayed and you can have another go.
Now let’s look what’s happening in the game object.
We have an item which represents whether the game is over, or still in play.
This is set to TRUE
if either the word is correctly
guessed, or all guesses are used.
The game_won
item indicates if the target word has been
guessed correctly.
The number of guesses made so far is held in the
guess_count
item.
The word we’re trying to guess is held in the target
item.
The list of guesses so far is available in the guess
item.
game$guess
#> [[1]]
#> [1] "S" "Q" "U" "I" "D"
#>
#> [[2]]
#> [1] "V" "I" "D" "E" "O"
#>
#> [[3]]
#> [1] "_" "_" "_" "_" "_"
#>
#> [[4]]
#> [1] "_" "_" "_" "_" "_"
#>
#> [[5]]
#> [1] "_" "_" "_" "_" "_"
#>
#> [[6]]
#> [1] "_" "_" "_" "_" "_"
The assess
item is a list holding the assessments of
each guess.
game$assess
#> [[1]]
#> [1] "not_in_word" "not_in_word" "in_word" "not_in_word" "not_in_word"
#>
#> [[2]]
#> [1] "not_in_word" "not_in_word" "not_in_word" "in_word" "not_in_word"
#>
#> [[3]]
#> [1] "not_in_word" "not_in_word" "not_in_word" "not_in_word" "not_in_word"
#>
#> [[4]]
#> [1] "not_in_word" "not_in_word" "not_in_word" "not_in_word" "not_in_word"
#>
#> [[5]]
#> [1] "not_in_word" "not_in_word" "not_in_word" "not_in_word" "not_in_word"
#>
#> [[6]]
#> [1] "not_in_word" "not_in_word" "not_in_word" "not_in_word" "not_in_word"
At any time, we can print the status of the game as follows.
print(game)
#>
#> S Q U I D
#> V I D E O W E R T Y U P
#> _ _ _ _ _ A F G H J K L
#> _ _ _ _ _ Z X C B N M
#> _ _ _ _ _
#> _ _ _ _ _
A vector of letters known to not be in the target word is available.
A vector of letters known to be in the target word is available.
A vector of letters known to be in the right position in the target word is available.