
Play a game of rock, paper, scissors in the console
Source:R/rock_paper_scissors.R
play_rock_paper_scissors.Rd
Play a game of rock, paper, scissors in the console
Usage
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()
)
Arguments
- selection
Whether to throw rock, paper, or scissors. Can be abbreviated as "r", "p", or "s". Defaults to
NA
, which interactively asks which to throw.- predict
If
TRUE
, the computer player fits a model on past games to predict what you will throw and try to beat you.- record_data
If
TRUE
, save data from this game into a file. This data is used for predictions whenpredict
isTRUE
. Defaults toTRUE
if the session is interactive andFALSE
otherwise.- animate
If
TRUE
, play a "rock, paper, scissors, shoot!" animation before revealing what you and the computer throw. Defaults toTRUE
if the session is interactive andFALSE
otherwise.- header
If
TRUE
, prints a header for the game. Defaults toTRUE
if the session is interactive andFALSE
otherwise.
Examples
play_rock_paper_scissors("rock")
#>
Rock ✊ 📄 Paper
#> You lose
#> I predicted you would throw: 33% scissors, 33% paper, 33% rock.
if (rlang::is_interactive()) play_rock_paper_scissors()