| Type: | Package |
| Title: | The 'WORDLE' Game |
| Version: | 0.3.1 |
| Description: | The 'Wordle' game. Players have six attempts to guess a five-letter word. After each guess, the player is informed which letters in their guess are either: anywhere in the word; in the right position in the word. This can be used to inform the next guess. Can be played interactively in the console, or programmatically. Based on Josh Wardle's gamehttps://www.powerlanguage.co.uk/wordle/. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| URL: | https://github.com/DavidASmith/wordler |
| Imports: | crayon |
| LazyData: | true |
| RoxygenNote: | 7.1.2 |
| Depends: | R (≥ 2.10) |
| Suggests: | rmarkdown, knitr, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2022-01-29 21:47:24 UTC; User |
| Author: | David Smith [aut, cre], Gethin Davies [ctb] |
| Maintainer: | David Smith <david.alex.smith@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2022-02-01 09:20:02 UTC |
Assess a guess against the target word
Description
Assesses the guess in listgame$guess (index fromgame$guess_count) against the target word ingame$target.
Usage
assess_guess(game)Arguments
game | 'wordler' game object (as generated by |
Details
Adds the assessment to the corresponding list item ingame$assess.This assessment should be considered as how the guesses should be displayedto the user and replicates the behaviour of the WORDLE game(https://www.powerlanguage.co.uk/wordle/).
For each letter in each guess, one of the following assessments are made:
'not_in_word' - the letter is not present in the target word (or hasalready been flagged as 'in_word' earlier in the word).
'in_word' - the letter is in the target word. More specifically,the first instance of the letter in the guess present in the word.Subsequent instances are flagged as 'not_in_word'.
'in_position' - the letter is in the same position in the targetword.
Value
'wordler' game object.
Get counts of each letter in the target
Description
Get counts of each letter in the target
Usage
count_freqs(xs, target)Arguments
xs,target | we count the occurrences of each element in |
Value
Named list of elements ofxs with counts.
Submit a guess word to a wordler game object
Description
Ifx is a valid guess, it is added togame$guess and assessedagainst the target word. Increments game$guess_count if a valid guess is made.
Usage
have_a_guess(x, game, allowed_words = NULL)Arguments
x | the guess. |
game | 'wordler' game object (as generated by |
allowed_words | a character vector of valid words for the guess. xmust be in this vector to be allowed. Defaults to words used by the WORDLEgame online (?wordler::wordle_allowed) if not provided. |
Value
A 'wordler' game object.
Detects wordler objects
Description
Detects wordler objects
Usage
is.wordler(x, ...)Arguments
x | an R object |
... | additional arguments |
Value
ReturnsTRUE if x is a 'wordler' object, otherwiseFALSE.
Establish if guess is correct and set game state accordingly
Description
Compares the guess ingame$guess (index fromgame$guess_count)with the corresponding target word ingame$target. If the guess isequal to the target,game$game_won andgame$game_over areboth set toTRUE.
Usage
is_guess_correct(game)Arguments
game | 'wordler' game object (as generated by |
Value
A 'wordler' game object.
Keyboard layouts for printing a wordler game at the console.
Description
A list of keyboard layouts used to show letters known to be not in targetword, in the target word, and in the right position in the target word.Each element must be a list having 3 items, each representing a row of akeyboard layout.
Usage
keyboardsFormat
A list of length 1.
Source
https://gist.github.com/cfreshman/cdcdf777450c5b5301e439061d29694c
Constructs a new object of class "wordler"
Description
Returns a "wordler" object which holds the state of a wordler game asguesses are made. The returned object will have a target word which isselected from the default list unless provided in thetargetargument.
Usage
new_wordler( target = sample(wordler::wordle_answers, 1), game_over = FALSE, game_won = FALSE, guess_count = 0, guess = lapply(1:6, function(x) unlist(strsplit("_____", ""))), assess = lapply(1:6, function(x) rep("not_in_word", 5)), keyboard = wordler::keyboards$qwerty, letters_known_not_in_word = character(0), letters_known_in_word = character(0), letters_known_in_position = character(0))Arguments
target | the target word for the game. Defaults to a random selectionfrom words used by the WORDLE game online (?wordler::wordle_answers) if notprovided. |
game_over | a logical indicating if the game is over. Defaults to FALSE. |
game_won | a logical indicating if the game has been won. In otherwords, has the target word been correctly guessed. |
guess_count | an integer representing the number of guesses made sofar. Defaults to 0. |
guess | a list (of length 6) of character vectors (each of length 5)representing the guesses of the target word. Each element of the listrepresents one of six guesses allowed. Each guess defaults to |
assess | a list (of length 6) of character vectors (each of length 5)representing an assessment of each letter in each guess. |
keyboard | a list (of length 3) of character vectors each representinga row of a keyboard layout used to visualise the game by |
letters_known_not_in_word | a character vector of letters known not tobe in the target word. |
letters_known_in_word | a character vector of letters know to be in thetarget word. |
letters_known_in_position | a character vector of letters known to bein the correct position in the target word. |
Details
The wordler object is a list which has the following elements:
target- The target word.game_over- A logical indicating if the game is over. Set toTRUEif either the word is correctly guessed, or all guesses areused.game_won- A logical indicating if the game has been won(target word correctly guessed).guess_count- The number of guesses made so far.guess- A list of guesses of the target word.assess- A list of assessments of the target word. Note thatthis represents how the letters in each guess should be displayed whenprinting the game.keyboard- A list representing the keyboard layout to be usedwhen printing the game state.letters_known_not_in_word- A vector of letters known not tobe in the target word based on guesses made so far.letters_known_in_word- A vector of letters known tobe in the target word based on guesses made so far.letters_known_not_in_word- A vector of letters known tobe in the right position in the target word based on guesses made so far.
Value
An object of class "wordler".
Play a game of WORDLE in the console
Description
Starts an interactive game of WORDLE in the console. Based on WORDLE(https://www.powerlanguage.co.uk/wordle/).
Usage
play_wordler(target_words = NULL, allowed_words = NULL)Arguments
target_words | character vector of potential target words for thegame. A word will be randomly selected from this vector as the target wordto be guessed. Defaults to words used by the WORDLE game online(?wordler::wordle_answers) if not provided. |
allowed_words | character vector of valid words for the guess. Guessmust be in this vector to be allowed. Defaults to words used by the WORDLEgame online (?wordler::wordle_allowed) if not provided. |
Value
No return value. Starts interactive game in console.
Prints a wordler game to the console.
Description
Prints a wordler game to the console.
Usage
## S3 method for class 'wordler'print(x, ...)Arguments
x | 'wordler' game object (as generated by |
... | additional arguments |
Value
No return value.
Prints instructions to play a wordler game in the console
Description
Prints instructions to play a wordler game in the console
Usage
print_instructions()Value
No return value.
All five-letter words from the Nettalk Corpus Syllable Data Set.
Description
A dataset containing all five-letter words from the Nettalk Corpus SyllableData Set as returned by qdapDictionaries::dictionaries().
Usage
qdap_dictFormat
A character vector of length 2488.
Source
https://CRAN.R-project.org/package=qdapDictionaries/
All five-letter words from the Ubuntu dictionary.
Description
A dataset containing all five-letter words from Ubuntu dictionary'/usr/share/dict/words'.
Usage
ubuntu_dictFormat
A character vector of length 4594.
Source
Establish which letters are known to be in the correct position in the targetword
Description
For all items ingame$guess, establishes the letters which are nowknown to be in the correct position in the target word. These are present asa character vector ingame$letters_known_in_position in the returnedobject.
Usage
update_letters_known_in_position(game)Arguments
game | 'wordler' game object (as generated by |
Value
A 'wordler' game object.
Establish which letters are known to be in the target word
Description
For all items ingame$guess, establishes the letters which are nowknown to be in the target word. These are present as a character vector ingame$letters_known_in_word in the returned object.
Usage
update_letters_known_in_word(game)Arguments
game | 'wordler' game object (as generated by |
Value
A 'wordler' game object.
Establish which letters are known to _not_ be in the target word
Description
For all items ingame$guess, establishes the letters which are nowknown to not be in the target word. These are present as a character vectoringame$letters_known_not_in_word in the returned object.
Usage
update_letters_known_not_in_word(game)Arguments
game | 'wordler' game object (as generated by |
Value
A 'wordler' game object.
All words used to validate guesses by the original WORDLE game.
Description
A dataset containing all words which are used to validate guesses by theoriginal WORDLE game. Note that this does not include the words which can beanswers. Theses are held in ?wordle_answers.
Usage
wordle_allowedFormat
A character vector of length 10657.
Source
https://gist.github.com/cfreshman/cdcdf777450c5b5301e439061d29694c
All words used as potential answers by the original WORDLE game.
Description
A dataset containing all words which can be used as answers to the originalWORDLE game.
Usage
wordle_answersFormat
A character vector of length 2315.
Source
https://gist.github.com/cfreshman/a03ef2cba789d8cf00c08f767e0fad7b/