Skip to contents

This function starts an interactive command line game of mastRmind. The player has a certain number of opportunities to guess a secret combination of colors (referred to as **secret code** in the original Mastermind peg game). The goal is to guess the secret code within the given number of attempts. After each guess, feedback is provided in the form of black and white pegs. A black peg means a correct color in the correct position. A white peg means a correct color in the wrong position.

Usage

play(attempts = 10, seed = NULL)

Arguments

attempts

The number of attempts the player has. Default is 10.

seed

An optional seed for the random number generator to make the secret code reproducible. Default is NULL.

Examples

if (FALSE) { # \dontrun{
  # To play the game with default settings:
  play()

  # To play a game with 12 attempts:
  play(rows = 12)
  
  # To generate consistent color codes, use seeds
  # For example ...
  play(seed = 123)  # Generates code 3 6 3 2
} # }