Skip to content

piecepackr/ppcli

Repository files navigation

ppcli

CRAN Status Badge R-CMD-check codecov

Table of Contents

  • cat_piece() prints out plaintext Unicode board game diagrams while str_piece() returns just the character vector.

  • Can optionally colorize output for the terminal using {cli} or HTML using fansi::sgr_to_html().

  • The board game data frame format used by this package is the same as:

    • The format expected by piecepackr::pmap_piece() or piecepackr::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 by ppgames::read_ppn() i.e. can view any of the moves of games recorded using Portable Piecepack Notation (PPN).
  • 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")

Dominoes diagram

library("ppcli")
library("ppdf")
cat_piece(piecepack_xiangqi())

Setup for playing Xiangqi with a piecepack

Why not in {piecepackr} yet?

The plaintext scheme used by cat_piece() / str_piece() requires more knowledge about the state of previously drawn pieces:

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().

Supported Board Game Fonts

R packages

Blog/forum posts

About

Generate plaintext board game diagrams

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published