Learn R Programming

lares (version 4.8.4)

scrabble_words: Scrabble: Highest score words finder

Description

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_words(
  tiles,
  free = 0,
  force_start = "",
  force_end = "",
  force_str = "",
  force_n = 0,
  force_max = 0,
  scores = getOption("lares.lang"),
  language = getOption("lares.lang"),
  words = NA,
  quiet = FALSE
)

Arguments

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_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 options("lares.lang" = "en") and forget about it!

words

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

quiet

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

See Also

Other Scrabble: scrabble_dictionary(), scrabble_points(), scrabble_score()

Examples

Run this code
# NOT RUN {
# Automatic use of languages and scores
options("lares.lang" = "es")

scrabble_words(tiles = "holasa",
               free = 1,
               force_start = "",
               force_end = "",
               force_str = "_o_a",
               force_n = 6,
               force_max = 0,
               quiet = FALSE)
               
# Custom scores table and manual language input 
cu_scores <- data.frame(
  tiles = c(tolower(LETTERS)[1:14],"_",tolower(LETTERS)[15:length(LETTERS)]),
  scores = c(1,1,1,1,1,1,1,1,1,1,1,1,3,1,8,1,3,5,1,1,1,2,4,10,10,5,10))
  
scrabble_words(tiles = "holase",
               language = "es",
               scores = cu_scores,
               free = 1,
               force_start = "_o_a")

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

Run the code above in your browser using DataLab