Package 'wordPuzzleR'

Title: Word Puzzle Game
Description: The word puzzle game requires you to find out the letters in a word within a limited number of guesses. In each round, if your guess hit any letters in the word, they reveal themselves. If all letters are revealed before your guesses run out, you win this game; otherwise you fail. You may run multiple games to guess different words.
Authors: Xiurui Zhu [aut, cre], @olivory [ctb] (Add `URL` and `BugReports` fields to `DESCRIPTION`.)
Maintainer: Xiurui Zhu <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2024-11-21 02:48:24 UTC
Source: https://github.com/zhuxr11/wordpuzzler

Help Index


Configure wordPuzzleR

Description

config_game configures wordPuzzleR, or show current configuration when used with no arguments.

Usage

config_game(..., .verbose = TRUE)

Arguments

...

Arguments passed on to configurations. Valid names may be:

dict

(String) path to dictionary file, where each line is a word.

min_len

(Integer) minimal word length, default 3.

max_len

(Integer) maximal word length, default 8.

guess

(Integer) maximal guesses, default 10.

pattern

(String) Regular expression to filter qualified words, default "[A-Za-z]+".

.verbose

(Logical) whether config messages should be printed.

Value

Named list of new configurations, invisibly.

Examples

# Show current config
config_game()

Run word puzzle game

Description

run_game is the main function to run word puzzle game. The word puzzle game requires you to guess the word with single letters in a limited times of trials. The letters you have guessed in the word reveal themselves. If all letters are revealed before your guesses run out, you win this round, otherwise you fail.

Usage

run_game(mask_char = "_", verbose = TRUE, ...)

Arguments

mask_char

(String) letter to mask the letters not guessed in the word.

verbose

(Logical) whether to print welcome and score messages.

...

For internal use only.

Value

Named list of game stats invisibly, including:

score

Named integer with names as success (success rounds) and total (total rounds).

best_guess

Integer as the minimal number of guesses.

best_hit

Named integer with names as hit (guesses that hit any letters in the word) and guess (total guesses).

Examples

# Run word puzzle game
if (interactive() == TRUE) {
  run_game()
}