Skip to contents

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 when predict is TRUE. Defaults to TRUE if the session is interactive and FALSE otherwise.

animate

If TRUE, play a "rock, paper, scissors, shoot!" animation before revealing what you and the computer throw. Defaults to TRUE if the session is interactive and FALSE otherwise.

header

If TRUE, prints a header for the game. Defaults to TRUE if the session is interactive and FALSE 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()