| Title: | Play Games in the Console |
|---|---|
| Description: | Games that can be played in the R console. Includes coin flip, hangman, jumble, magic 8 ball, poker, rock paper scissors, shut the box, spelling bee, and 2048. |
| Authors: | Alexander Rossell Hayes [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-9412-0457>), Alan Beale [dtc] (Word lists), Kevin Atkinson [dtc] (Word lists), Luis Von Ahn [dtc] (Word lists), Flavia Rossell Hayes [ill], Kristin Bott [ctb] (look_busy() status messages), Daniel Chen [ctb] (ORCID: <https://orcid.org/0000-0003-3857-1741>, look_busy() status messages), Steven Smallberg [ctb] (look_busy() status messages) |
| Maintainer: | Alexander Rossell Hayes <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-05-15 09:43:14 UTC |
| Source: | https://github.com/rossellhayes/player |
Look like you're working hard when you're hardly working
look_busy( minutes = if (rlang::is_interactive()) Inf else 0, speed = 1, lambda = 3, background_job = FALSE, end = invisible(NULL) )look_busy( minutes = if (rlang::is_interactive()) Inf else 0, speed = 1, lambda = 3, background_job = FALSE, end = invisible(NULL) )
minutes |
How long to keep this up for.
Defaults to |
speed |
How fast to produce output.
The default value, |
lambda |
Input to a poisson distribution determining how many
calculations to perform between each message.
Defaults to |
background_job |
Whether to produce output in in a background job
(if |
end |
Code to run after |
end if minutes is finite.
Alexander Rossell Hayes [email protected] (ORCID)
With status messages contributed by:
Kristin Bott [email protected]
Daniel Chen [email protected] (ORCID)
Steven Smallberg [email protected]
look_busy()look_busy()
Interact with the game by typing commands into the console and pressing enter.
play(game = NULL, ...)play(game = NULL, ...)
game |
The name of a game to play.
If |
... |
Additional arguments passed to the chosen game. |
Calls the selected game function.
if (rlang::is_interactive()) play() play("magic_8_ball")if (rlang::is_interactive()) play() play("magic_8_ball")
Flip a coin
play_coin_flip( n = NULL, animate = rlang::is_interactive(), header = rlang::is_interactive() )play_coin_flip( n = NULL, animate = rlang::is_interactive(), header = rlang::is_interactive() )
n |
How many coins to flip.
Defaults to |
animate |
If |
header |
If |
A character vector of "heads" or "tails" results.
play_coin_flip(1) if (rlang::is_interactive()) play_coin_flip()play_coin_flip(1) if (rlang::is_interactive()) play_coin_flip()
Play a game of hangman in the console
play_hangman( difficulty = c("beginner", "easy", "medium", "hard", "expert"), word_list = NULL )play_hangman( difficulty = c("beginner", "easy", "medium", "hard", "expert"), word_list = NULL )
difficulty |
Determines the length of words used for the game and,
if |
word_list |
Optionally, a character vector of words used to play the
game.
If unspecified, a default word list will be used based on |
Generates interactive output in the console.
You can report any words you find objectionable to https://github.com/rossellhayes/hangman/issues.
Please report:
offensive words
words that deal with uncomfortable topics
proper nouns
text that is not a common English word
The default word list is derived from 12dicts created by Alan Beale.
This word list is passed through the Offensive/Profane Word List created by Luis Von Ahn to filter out potentially unwanted words.
play_hangman() play_hangman("beginner") play_hangman("easy") play_hangman("medium") play_hangman("hard") play_hangman("expert") cars <- unique(gsub(" .*", "", rownames(mtcars))) play_hangman(word_list = cars)play_hangman() play_hangman("beginner") play_hangman("easy") play_hangman("medium") play_hangman("hard") play_hangman("expert") cars <- unique(gsub(" .*", "", rownames(mtcars))) play_hangman(word_list = cars)
Play a game of jumbles in the console
play_jumble( difficulty = c("beginner", "easy", "medium", "hard", "expert"), word_list = NULL )play_jumble( difficulty = c("beginner", "easy", "medium", "hard", "expert"), word_list = NULL )
difficulty |
Determines the length of words used for the game and,
if |
word_list |
Optionally, a character vector of words used to play the
game.
If unspecified, a default word list will be used based on |
Generates interactive output in the console.
Difficulty levels are defined as follows:
beginner: very common English words with 3 to 5 letters
easy: common English words with 4 to 6 letters
medium: slightly less common English words with 5 to 8 letters
hard: somewhat less common English words with 6 to 11 letters
expert: less common English words with 7 to 15 letters
You can report any words you find objectionable to https://github.com/rossellhayes/hangman/issues.
Please report:
offensive words
words that deal with uncomfortable topics
proper nouns
text that is not a common English word
The default word list is derived from 12dicts created by Alan Beale.
This word list is passed through the Offensive/Profane Word List created by Luis Von Ahn to filter out potentially unwanted words.
play_jumble() play_jumble("beginner") play_jumble("easy") play_jumble("medium") play_jumble("hard") play_jumble("expert") cars <- unique(gsub(" .*", "", rownames(mtcars))) play_jumble(word_list = cars)play_jumble() play_jumble("beginner") play_jumble("easy") play_jumble("medium") play_jumble("hard") play_jumble("expert") cars <- unique(gsub(" .*", "", rownames(mtcars))) play_jumble(word_list = cars)
Ask a Magic 8 Ball a question in the console
play_magic_8_ball(question = NULL, header = rlang::is_interactive())play_magic_8_ball(question = NULL, header = rlang::is_interactive())
question |
A character string.
Ask the Magic 8 Ball anything your heart desires.
If |
header |
If |
A character string answering your question.
play_magic_8_ball("Will I ever find love?") if (rlang::is_interactive()) play_magic_8_ball()play_magic_8_ball("Will I ever find love?") if (rlang::is_interactive()) play_magic_8_ball()
Interact with the game by typing commands into the console and pressing enter.
play_poker(colors = c(2, 4, 1))play_poker(colors = c(2, 4, 1))
colors |
One of
|
Generates an interactive game of poker in the console.
| Hand | Points | Description |
| Junk | -10 | Nothing of value. |
| Low pair | 0 | Two cards of the same rank, ten or below. |
| High pair | 5 | Two aces, kings, queens, or jacks. |
| Two pair | 10 | Two cards of one rank and two cards of another. |
| Three of a kind | 20 | Three cards of the same rank. |
| Straight | 50 | Five cards in sequential order. |
| Flush | 75 | Five cards of the same suit. |
| Full house | 100 | Three cards of one rank and two cards of another. |
| Four of a kind | 1,000 | Four cards of the same rank. |
| Straight flush | 50,000 | Five cards of the same suit in sequential order. |
| Royal flush | 1,000,000 | Ace, king, queen, jack, and ten of the same suit. |
For straights, aces may be considered the highest card (above king) or the lowest card (below two). However, aces may not be used to connect a king and a two (e.g. Q-K-A-2-3 is not a straight).
play_poker() play_poker(colors = 4) play_poker(colors = 1)play_poker() play_poker(colors = 4) play_poker(colors = 1)
Play a game of rock, paper, scissors in the console
play_rock_paper_scissors( selection = c(NA, "rock", "paper", "scissors"), predict = TRUE, record_data = rlang::is_interactive(), animate = rlang::is_interactive(), header = rlang::is_interactive() )play_rock_paper_scissors( selection = c(NA, "rock", "paper", "scissors"), predict = TRUE, record_data = rlang::is_interactive(), animate = rlang::is_interactive(), header = rlang::is_interactive() )
selection |
Whether to throw rock, paper, or scissors.
Can be abbreviated as "r", "p", or "s".
Defaults to |
predict |
If |
record_data |
If |
animate |
If |
header |
If |
play_rock_paper_scissors("rock") if (rlang::is_interactive()) play_rock_paper_scissors()play_rock_paper_scissors("rock") if (rlang::is_interactive()) play_rock_paper_scissors()
Your goal is to flip down all nine tiles numbered from 1 to 9. Each turn, you roll two dice and flip down any number of tiles that add up to the same number as the sum of your dice. After you have flipped down the 7, 8, and 9 tiles, you may choose whether to roll one or two dice. You win the game if you flip down all nine tiles! But if you ever can't flip down a combination of tiles that sums to your die roll, it's game over.
play_shut_the_box()play_shut_the_box()
Generates interactive output in the console.
play_shut_the_box()play_shut_the_box()
Inspired by the New York Times Spelling Bee, created by Sam Ezersky.
play_spelling_bee()play_spelling_bee()
Generates interactive output in the console.
You can report any words you find objectionable to https://github.com/rossellhayes/hangman/issues.
Please report:
offensive words
words that deal with uncomfortable topics
proper nouns
text that is not a common English word
The default word list is derived from 12dicts created by Alan Beale.
This word list is passed through the Offensive/Profane Word List created by Luis Von Ahn to filter out potentially unwanted words.
play_spelling_bee()play_spelling_bee()