checker_board() returns a square checkers board of desired size and type.
checker_bits() returns checkers discs.
Usage
checker_board(
nrows = 8L,
ncols = nrows,
x0 = 1,
y0 = 1,
...,
side = "face",
piece_side = paste0("board_", side),
suit = "green",
angle = 0,
cell_width = getOption("ppdf.checker_cell_width", 1)
)
checker_bits(
...,
side = "back",
piece_side = paste0("bit_", side),
suit = 1:6,
x = as.double(1:6),
y = 1,
angle = 0,
cell_width = getOption("ppdf.checker_cell_width", 1),
length.out = NA_integer_
)Arguments
- nrows
Number of rows in game board
- ncols
Number of columns in game board
- x0
X coordinate for the center of the first cell
- y0
Y coordinate for the center of the first cell
- ...
Should be left empty.
- side
Either "face" or "back"
- piece_side
If
"board_face"a checkered board (as in American Checkers). If"board_back"a lined board (as in Turkish Checkers).- suit
Suit value (color) of board/checkers.
1Lis "red",2Lis "black",3Lis "green",4Lis "blue",5Lis "yellow", and6Lis "white". Will be coerced bypiece_suit().- angle
Angle of board in degrees. Italian Checkers rotates its board 90 degrees compared to other checkers variants.
- cell_width
Width of board cell.
piecepackr::game_systems()supports1or2. IfNULLthen don't set it yet.- x, y
Cartesian coordinates (numeric vectors)
- length.out
The number of pieces. Not needed if all the arguments are the same length (or of length one) and this length is the same as the number of desired pieces.
Value
A tibble::tibble() data frame with the following columns:
"piece_side"
"suit"
"rank"
"cfg" (optional, defaults to
"piecepack")"x"
"y"
"angle" (optional, defaults to
0).
This data frame is compatible with piecepackr::render_piece() and likely ppcli::cat_piece().
Examples
dfb <- checker_board(nrows = 4L, ncol = 4L)
df1 <- checker_bits(suit = "white", x = c(1, 3), y = 1)
df2 <- checker_bits(suit = "white", x = c(2, 4), y = 2)
df3 <- checker_bits(suit = "black", x = c(1, 3), y = 3)
df4 <- checker_bits(suit = "black", x = c(2, 4), y = 4)
df <- rbind(dfb, df1, df2, df3, df4)
if (require("piecepackr", quietly = TRUE) &&
packageVersion("piecepackr") >= "1.15.0-1") {
grid::grid.newpage()
envir = game_systems()
pmap_piece(df, envir = envir, default.units = "in")
}