lights_out: Play the "Lights Out" game in R

Description Usage Arguments Note Author(s) References Examples

View source: R/lights_out.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

1
2
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 [email protected]

References

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

Examples

1
2
3
4
5
6
## 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 Dec. 14, 2018, 6:22 p.m.