-
cat_piece()
prints out plaintext Unicode board game diagrams whilestr_piece()
returns just the character vector. -
Can optionally colorize output for the terminal using
{cli}
or HTML usingfansi::sgr_to_html()
. -
The board game data frame format used by this package is the same as:
- The format expected by
piecepackr::pmap_piece()
orpiecepackr::render_piece()
for visualization with{grid}
,{ggplot2}
,{rayrender}
,{rayvertex}
, or{rgl}
. - The format returned by 100+ functions in the {ppdf} package.
- The
dfs
attribute of games parsed byppgames::read_ppn()
i.e. can view any of the moves of games recorded using Portable Piecepack Notation (PPN).
- The format expected by
-
This is an extraction and refinement of functionality originally contained in the experimental {ppgames} package.
remotes::install_github("piecepackr/ppcli")
library("ppcli")
library("tibble")
df <- tibble(piece_side = "tile_face",
x=c(0.5, 1.0, 1.5, 2.0, 2.5, 2.5, 3.5, 4.0, 4.0,
4.5, 5.5, 6.0, 7.5, 8.0),
y=c(5.0, 2.5, 1.0, 4.5, 6.0, 3.0, 1.0, 6.5, 2.5,
4.0, 6.0, 4.5, 4.0, 2.5),
rank = c(4, 2, 5, 4, 1, 1, 5, 1, 5, 6, 2, 6, 6, 4) + 1,
suit = c(4, 5, 0, 1, 1, 5, 4, 2, 5, 5, 6, 6, 4, 0) + 1,
angle = c(0, 90, 0, 90, 0, 0, 0, 90, 90, 0, 0, 90, 0, 90),
cfg = "dominoes_white")
cat_piece(df, style = "Game Bit Mono")
library("ppcli")
library("ppdf")
cat_piece(piecepack_xiangqi())
The plaintext scheme used by cat_piece()
/ str_piece()
requires more knowledge about the state of previously drawn pieces:
- We need to know which Box-drawing characters are already on the board.
- We need to standardize on the target font scheme since some fonts like Game Bit Mono and Game Bit Duo rely on glyphs in the Unicode Private-Use-Area.
We don't need to know nearly as much state about how other game pieces were drawn when drawing with {grid}
, {ggplot2}
, {rayrender}
, {rayvertex}
, or {rgl}
so it is much more straightforward to simply plot them in sequence using piecepackr::pmap_piece()
.