sliding_puzzle: Sliding puzzle in R

Description Usage Arguments Details Note Author(s) References Examples

View source: R/sliding_puzzle.R

Description

Use R to play sliding puzzle

Usage

1
sliding_puzzle(size = c(3, 3), bg = "lightblue", z = NULL)

Arguments

size

two dimensional vector, the size of sliding puzzle. Note: the element of size must be greater than 1.

bg

the background color of blocks.

z

the matrix of sliding puzzle, if z is specified, size will be omited.

Details

If size is specified and z is NULL, then the function will generate a solvable sliding puzzle.

Note

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

Author(s)

Taiyun Wei

References

About the sliding puzzle: https://en.wikipedia.org/wiki/Sliding_puzzle

Examples

1
2
3
4
5
6
7
## should use Xlib for the x11() device under *nix, e.g
if (interactive()) {
    if (.Platform$OS.type == "windows") 
        x11() else x11(type = "Xlib")
    sliding_puzzle()
    sliding_puzzle(z = matrix(0:11, 3, 4))
}

Example output



fun documentation built on Oct. 24, 2020, 1:07 a.m.