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.
First, load the package.
library(wordler)
To play a game in the console, call the play_wordler()
function.
# Commented out so vignette can be generated
#play_wordler()
First, initialise a new game.
<- new_wordler() 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.
<- 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)) game
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.
<- have_a_guess("DONKY", game, allowed_words = c(wordle_answers, wordle_allowed))
game #> Your word isn't in the list of valid words. Try again.
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.
$game_over
game#> [1] FALSE
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.
$game_won
game#> [1] FALSE
The number of guesses made so far is held in the guess_count
item.
$guess_count
game#> [1] 2
The word we’re trying to guess is held in the target
item.
$target
game#> [1] "EVERY"
The list of guesses so far is available in the guess
item.
$guess
game#> [[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.
$assess
game#> [[1]]
#> [1] "not_in_word" "not_in_word" "not_in_word" "not_in_word" "not_in_word"
#>
#> [[2]]
#> [1] "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 P
#> _ _ _ _ _ A F G H J K L
#> _ _ _ _ _ Z X C V B N M
#> _ _ _ _ _
#> _ _ _ _ _
A vector of letters known to not be in the target word is available.
$letters_known_not_in_word
game#> [1] "S" "Q" "U" "I" "D" "O"
A vector of letters known to be in the target word is available.
$letters_known_in_word
game#> [1] "V" "E"
A vector of letters known to be in the right position in the target word is available.
$letters_known_in_position
game#> character(0)