Skip to contents

marble_board() returns a square holed board of desired size and color. marble_bits() returns marble pieces.

Usage

marble_board(
  nrows = 4L,
  ncols = nrows,
  x0 = 1 * scale_factor,
  y0 = 1 * scale_factor,
  ...,
  suit = "cyan",
  scale_factor = 0.5
)

marble_bits(
  ...,
  suit = 1:6,
  rank = 9L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

Arguments

nrows

Number of rows in game board (i.e. number of holes vertically)

ncols

Number of columns in game board (i.e. number of holes horizontally)

x0

X coordinate for the center of the first hole

y0

Y coordinate for the center of the first hole

...

Should be left empty.

suit

Suit value (color) of board and bits. 1L is "red", 2L is "black", 3L is "green", 4L is "blue", 5L is "yellow", and 6L is "white". Will be coerced by piece_suit().

scale_factor

Used by {ppn}. Should usually be 0.5 for square pyramidal games but could be 1 if not playing a pyramidal game.

rank

Determines the size of the marble from 0.5 inch diameter (rank 1) to 1.0 inch diamter (rank 9). The default is 1.0 inch diameter marbles which match the holed boards.

x, y

Cartesian coordinates (numeric vectors)

angle

Rotation of piece (numeric vector of degrees, counter-clockwise). Will be coerced by piece_angle().

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 <- marble_board(nrows = 2L, scale_factor = 1.0)
dfm <- marble_bits(x = c(1:2, 1:2, 1.5),
                   y = c(1, 1, 2, 2, 1.5),
                   suit = c(1:3, 5:6))
df <- rbind(dfb, dfm)
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")
}