lights_out: Play the "Lights Out" game in R

View source: R/lights_out.R

lights_outR Documentation

Play the “Lights Out” game in R

Description

By default, the white squares in the plot denote the lights that are on, and black ones for the off. When you click on a light, this light as well as the four neighbors will switch theirs status. Your mission is to close all the lights.

Usage

lights_out(
  width = 5,
  height = 5,
  steps = 3,
  cheat = FALSE,
  col.off = "black",
  col.on = "white",
  col.frame = "lightblue",
  seed = NULL
)

Arguments

width

number of lights in x axis

height

number of lights in y axis

steps

number of “seed” lights to initialize the puzzle. In general, the larger steps is, the more complex this puzzle may be

cheat

logical. If TRUE a data frame indicating the steps to solve this puzzle will be printed

col.off

color when lights off

col.on

color when lights on

col.frame

color of lights border

seed

seed for random number generator

Note

Linux/Mac users have to use X11(type = 'Xlib') or the Cairo graphics device Cairo() in the package cairoDevice.

Author(s)

Yixuan Qiu yixuan.qiu@cos.name

References

https://en.wikipedia.org/wiki/Lights_Out_(game)

Examples

## should use Xlib for the x11() device under *nix, e.g
if (interactive()) {
    if (.Platform$OS.type == "windows") 
        x11() else x11(type = "Xlib")
    lights_out()
}

yihui/fun documentation built on Jan. 28, 2023, 2:29 p.m.