Skip to contents

go_board() returns an go board. go_bits() returns go pieces.

Usage

go_board(nrows = 19L, ncols = nrows, x0 = 1, y0 = 1, ..., suit = "black")

go_bits(
  ...,
  suit = 1:6,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  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 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

dfb <- go_board()
dfw <- go_bits(suit = "white", x = 1:19, y = 1:19)
dfk <- go_bits(suit = "black", x = 1:19, y = 19:1)
df <- rbind(dfb, dfw, dfk)
if (requireNamespace("ppcli", quietly = TRUE) &&
    packageVersion("ppcli") >= "0.2.0-1") {
  ppcli::cat_piece(df, annotate = TRUE)
}
#>                                          
#> 19 ●─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─┰─○ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 18 ┝━●━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━○━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 17 ┝━╋━●━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━○━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 16 ┝━╋━╋━●━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━○━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 15 ┝━╋━╋━╋━●━╋━╋━╋━╋━╋━╋━╋━╋━╋━○━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 14 ┝━╋━╋━╋━╋━●━╋━╋━╋━╋━╋━╋━╋━○━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 13 ┝━╋━╋━╋━╋━╋━●━╋━╋━╋━╋━╋━○━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 12 ┝━╋━╋━╋━╋━╋━╋━●━╋━╋━╋━○━╋━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 11 ┝━╋━╋━╋━╋━╋━╋━╋━●━╋━○━╋━╋━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 10 ┝━╋━╋━╋━╋━╋━╋━╋━╋━●━╋━╋━╋━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 9  ┝━╋━╋━╋━╋━╋━╋━╋━○━╋━●━╋━╋━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 8  ┝━╋━╋━╋━╋━╋━╋━○━╋━╋━╋━●━╋━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 7  ┝━╋━╋━╋━╋━╋━○━╋━╋━╋━╋━╋━●━╋━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 6  ┝━╋━╋━╋━╋━○━╋━╋━╋━╋━╋━╋━╋━●━╋━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 5  ┝━╋━╋━╋━○━╋━╋━╋━╋━╋━╋━╋━╋━╋━●━╋━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 4  ┝━╋━╋━○━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━●━╋━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 3  ┝━╋━○━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━●━╋━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 2  ┝━○━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━╋━●━┥ 
#>    │ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ │ 
#> 1  ○─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─┸─● 
#>                                          
#>    a b c d e f g h i j k l m n o p q r s 
dfb <- go_board(4L, 4L)
dfw <- go_bits(suit = "white", x = 1:4, y = 1:4)
dfk <- go_bits(suit = "black", x = 1:4, y = 4:1)
df <- rbind(dfb, dfw, dfk)
if (require("piecepackr", quietly = TRUE) &&
    packageVersion("piecepackr") >= "1.15.0-9" &&
    requireNamespace("systemfonts", quietly = TRUE) &&
    piecepackr::has_font("Dejavu Sans") &&
    piecepackr:::device_supports_unicode()) {
  grid::grid.newpage()
  envir = game_systems(background_color = "burlywood")
  pmap_piece(df, envir = envir, default.units = "in")
}