fun (version 0.2)

sliding_puzzle: Sliding puzzle in R

Description

Use R to play sliding puzzle

Usage

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.

References

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

Examples

Run this code
# NOT RUN {
## 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))
}
# }

Run the code above in your browser using DataLab