Learn R Programming

player (version 0.1.0)

play_rock_paper_scissors: Play a game of rock, paper, scissors in the console

Description

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

Run this code
play_rock_paper_scissors("rock")

if (rlang::is_interactive()) play_rock_paper_scissors()

Run the code above in your browser using DataLab