isValidState: check the validity of state

Description Usage Arguments Value Examples

View source: R/functions_state.R

Description

check the validity of state

Usage

1
isValidState(state, setting)

Arguments

state

an object of 'slidepzl_state' class.

setting

an object of 'slidepzl_setting' class.

Value

logical. is the state valid?

Examples

 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

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