scrabble: Scrabble: Dictionaries

scrabble_dictionaryR Documentation

Scrabble: Dictionaries

Description

Download words from 4 different languages: English, Spanish, German, and French. Words will be save into the temp directory. This is an auxiliary function. You may want to use scrabble_words directly if you are searching for the highest score words!

Get score for any word or list of words. You may set manually depending on the rules and languages you are playing with. Check the examples for Spanish and English values when I played Words With Friends.

Dataframe for every letter and points given a language.

Find highest score words given a set of letters, rules, and language to win at Scrabble! You just have to find the best place to post your tiles.

Usage

scrabble_dictionary(lang_dic, quiet = FALSE)

scrabble_score(words, scores.df)

scrabble_points(lang)

scrabble_words(
  tiles = "",
  free = 0,
  force_start = "",
  force_end = "",
  force_str = "",
  force_exclude = "",
  exclude_here = "",
  force_n = 0,
  force_max = 0,
  language = Sys.getenv("LARES_LANG"),
  scores = language,
  words = NULL,
  quiet = FALSE,
  print = TRUE
)

Arguments

lang_dic

Character. Any of "en","es","de","fr". Set to NULL if you wish to skip this step (and use words parameter in scrabble_words instead).

quiet

Boolean. Do not print words as they are being searched.

words

Character vector. Use if you wish to manually add words.

scores.df

Dataframe. Must contain two columns: "tiles" with every letter of the alphabet and "scores" for each letter's score.

lang

Character. Any of "en","es". Set to NULL if you wish to skip this step (and use words parameter in scrabble_words() instead).

tiles

Character. The letters you wish to consider.

free

Integer. How many free blank tiles you have?

force_start, force_end

Character. Force words to start or end with a pattern of letters and position. Examples: "S" or "SO" or "__S_O"... If the string contains tiles that were not specified in tiles, they will automatically be included.

force_str

Character vector. Force words to contain strings. If the string contains tiles that were not specified in tiles, they will automatically be included.

force_exclude, exclude_here

Character vector. Exclude words containing these tiles (and positions). Not very relevant on Scrabble but for Wordle.

force_n, force_max

Integer. Force words to be n or max n characters long. Leave 0 to ignore parameter.

scores, language

Character. Any of "en","es","de","fr". If scores is not any of those languages, must be a data.frame that contains two columns: "tiles" with every letter of the alphabet and "scores" for each letter's score. If you wish to overwrite or complement this dictionaries other words you can set to "none" and/or use the words parameter. You might also want to set this parameter globally with Sys.setenv("LARES_LANG" = "en") and forget about it!

print

Boolean. Print how many words are left by step.

Value

data.frame with words and language columns.

data.frame with word, scores, and length values for each word.

data.frame with tiles and scores for each alphabet letter.

data.frame with matching words found, sorted by higher points.

Examples


# For Spanish words
dictionary <- scrabble_dictionary("es")


# For Spanish words (default)
es_scores <- scrabble_points("es")
# Custom scores for each letter
cu_scores <- data.frame(
  tiles = tolower(LETTERS),
  scores = c(1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 5, 2, 4, 2, 1, 4, 10, 1, 1, 1, 2, 5, 4, 8, 3, 10)
)

# Score values for each set of rules
words <- c("Bernardo", "Whiskey", "R is great")
scrabble_score(words, es_scores)
scrabble_score(words, cu_scores)

scrabble_points("es")
scrabble_points("en")
# Not yet available
scrabble_points("fr")

# Automatic use of languages and scores
Sys.setenv("LARES_LANG" = "es")
scrabble_words(
  tiles = "hola",
  free = 2,
  force_start = "h",
  force_n = 4,
  force_str = "_o_a",
  exclude_here = "__z|j"
)

wordle <- c("board", "tempo", "shoes", "hoard")
scrabble_words(
  language = NULL,
  words = wordle,
  force_n = 5,
  force_str = "O_R"
)

# Words considered for a language (you can custom it too!)
es_words <- scrabble_dictionary("es")


laresbernardo/lares documentation built on April 25, 2024, 5:31 a.m.