makeSetting: make setting of a sliding puzzle

Description Usage Arguments Value Examples

View source: R/class.R

Description

make setting of a sliding puzzle

Usage

1
makeSetting(boardsize, piecesize)

Arguments

boardsize

a numeric vector of length 2.

(number of rows, number of columns) of the board. Should be >= 1 and <= 9.

piecesize

a named list.

The name of each element should be a alphabetic character representing a type of piece. Case sensitive. Duplicated names are not allowed.

Each element should be a numeric vector of length 2, giving (vertical size, horizontal size) of that type of piece. Should be >= 1 and <= 9.

Value

an object of class 'slidepzl_setting', which is a list with following elements:

boardsize

same as boardsize argument

piecearea

a named list.

The name of each element is a alphabetic character, giving the 'type' of piece.

Each element is a numeric matrix of size (k,2), giving relative locations of cells which that type of piece occupies.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# simple 3x3 puzzle
mysetting <- makeSetting(
  boardsize = c(3,3),
  piecesize = list(
    "A" = c(1,1),
    "B" = c(1,1),
    "C" = c(1,1),
    "D" = c(1,1),
    "E" = c(1,1),
    "F" = c(1,1),
    "G" = c(1,1)
  )
)
mysetting

shigono/rSlidePzl documentation built on Jan. 21, 2021, 8:01 a.m.