makeState: make a state (or goal conditions) of a puzzle

Description Usage Arguments Value Examples

View source: R/class.R

Description

make a state (or goal conditions) of a puzzle

Usage

1
makeState(pieces)

Arguments

pieces

a list of objects of 'slidepzl_piece' class. They can have NAs in their locations.

Value

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

piecetypes

a character vector, whose ith element gives the 'type' of ith piece.

piecelocs

a numeric matrix of size (k, 2), where k is the number of pieces on the board. The ith row gives (row, column) of the upper left corner of the ith piece. It can have NAs.

Validity of the state is not guaranteed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mystate <- makeState(
  list(
    makePiece(type = "A", loc = c(1,1)),
    makePiece(type = "B", loc = c(1,2)),
    makePiece(type = "C", loc = c(1,3)),
    makePiece(type = "D", loc = c(2,1)),
    makePiece(type = "E", loc = c(2,2)),
    makePiece(type = "F", loc = c(2,3)),
    makePiece(type = "G", loc = c(3,1)),
    makePiece(type = "H", loc = c(3,2))
  )
)
mystate

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