Description Usage Arguments Value Examples
View source: R/functions_state.R
check the validity of state
1 | isValidState(state, setting)
|
state |
an object of 'slidepzl_state' class. |
setting |
an object of 'slidepzl_setting' class. |
logical. is the state valid?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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)
)
)
# a valid case
state1 <- makeState(
list(
makePiece(type = "A", loc = c(1,1)),
makePiece(type = "B", loc = c(1,2))
)
)
isValidState(state1, mysetting) # TRUE
# a invalid case
state2 <- makeState(
list(
makePiece(type = "A", loc = c(1,1)),
makePiece(type = "B", loc = c(1,1)) # the location is duplicated with piece 1
)
)
isValidState(state2, mysetting) # FALSE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.