Skip to contents

morris_board() returns various morris boards. morris_bits() returns morris pieces aka merels.

Usage

morris_board(n = 9L, x0 = 1, y0 = 1, ..., suit = "green")

morris_bits(
  ...,
  suit = 1:6,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

Arguments

n

The number of "men" the morris board is for.

x0

X coordinate for the center of the first point

y0

Y coordinate for the center of the first point

...

Should be left empty.

suit

Suit value (color) of board/bit. 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().

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

df <- morris_board(9L)
if (requireNamespace("ppcli", quietly = TRUE) &&
    packageVersion("ppcli") >= "0.2.0-8") {
  ppcli::cat_piece(df, annotate = TRUE)
}
#> 7 ┌─────┬─────┐
#>   │     │     │
#> 6 │ ┌───┼───┐ │
#>   │ │   │   │ │
#> 5 │ │ ┌─┴─┐ │ │
#>   │ │ │   │ │ │
#> 4 ├─┼─┤   ├─┼─┤
#>   │ │ │   │ │ │
#> 3 │ │ └─┬─┘ │ │
#>   │ │   │   │ │
#> 2 │ └───┼───┘ │
#>   │     │     │
#> 1 └─────┴─────┘
#>                
#>   a b c d e f g
df <- morris_board(n = 3L)
if (requireNamespace("piecepackr", quietly = TRUE)) {
  piecepackr::render_piece(df, open_device = FALSE, annotate = TRUE)
}