Skip to content

piecepackr/ppdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ppdf

CRAN Status Badge R-CMD-check codecov Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

Table of Contents

  • This package contains functions that return {tibble} data frames with (possibly random) setup data for over a hundred board games playable with public domain game systems.
  • This board game data can be visualized by {piecepackr} using the {grid}, {ggplot2}, {rayrender}, {rayvertex}, or {rgl} graphics systems or in a command-line interface by ppcli::cat_piece() (optionally) using {cli}.
  • If you use Portable Piecepack Notation (PPN) to record the moves for any of games supported by this package then you can visualize any/all of the moves for that game with the help of the PPN parser in {ppn}.
  • The package name "ppdf" is an acronym for piecepackr data frames".
  • Many of these functions were originally contained (under a slightly different name) in the experimental {ppgames} and {tradgames} packages.
remotes::install_github("piecepackr/ppdf")
df_fujisan <- ppdf::dominoes_fujisan(seed = 42)

if (requireNamespace("piecepackr", quietly = TRUE) &&
    requireNamespace("systemfonts", quietly = TRUE) &&
    all(capabilities("png"))) {
  library("piecepackr")
  envir <- game_systems(pawn = "joystick", round = TRUE)
  render_piece(df_fujisan, file = "man/figures/README-fujisan.png",
               envir = envir, op_scale = 0.5, op_angle = 90,
               trans = op_transform, as_top = "pawn_face")
}

Setup for playing a game of Fuji-san with a set of dominoes

df_loa <- ppdf::checkers_lines_of_action()

if (requireNamespace("piecepackr", quietly = TRUE) &&
    requireNamespace("systemfonts", quietly = TRUE) &&
    all(capabilities("png"))) {
  library("piecepackr")
  envir <- game_systems()
  render_piece(df_loa, file = "man/figures/README-lines-of-action.png",
               envir = envir, op_scale = 0.5, trans = op_transform)
}

Setup for playing a game of Lines of Action with a checkers set

df_tablut <- ppdf::piecepack_tablut()

if (requireNamespace("piecepackr", quietly = TRUE) &&
    requireNamespace("systemfonts", quietly = TRUE) &&
    piecepackr::has_font("Dejavu Sans") &&
    all(capabilities(c("cairo", "png")))) {
  library("piecepackr")
  envir <- game_systems("dejavu", pawn = "joystick")
  render_piece(df_tablut, file = "man/figures/README-tablut.png",
               envir = envir, op_scale = 0.5,
               trans = op_transform, as_top = "pawn_face")
}

Setup for playing a game of Tablut with a piecepack deck

An example game of Relativity recorded in the Portable Piecepack Notation (PPN) format:

ppn_file <- system.file("ppn/relativity.ppn", package = "ppn")
cat(paste("\t", readLines(ppn_file)), sep = "\n")
 ---
 Round: Night
 GameType: 
     Name: Relativity
     Coins: "n45a5n/3a2243/3n4a2n/a25345"
 ...
 { Notes: Space has power of adjacency while Time has power of sequence }
 1S. d3#e3 1T. d3#d1
 2S. c2#c3 2T. d2#b1;M2@e6
 3S. b2#a2 3T. e3#b2
 4S. f1#f4 4T. e2#a3;M3@e6
 5S. c4#d4 5T. f1#a1
 6S. c1#c4;M5@b6 6T. b3#a3
 7S. f3#a3 7T. d1#a3
 8S. f2#f3 8T. b1#d2
 9S. f3#a3;Mn@b6 9T. e2#c2
 10S. e1#f1 10T. f1#d4
 11S. c2#c3 11T. d4#c4
 12S. b2#c2 12T. c1#e2;Ma@e6

Since Relativity is one of the games supported by this package (i.e. the function piecepack_relativity()) then ppn::read_ppn() can be used to parse this PPN file and then ppn::animate_game() can be used to animate the parsed game:

library("gifski")
library("piecepackr")
library("ppn") # remotes::install_github("piecepackr/ppn")
library("tweenr")

envir <- game_systems("dejavu")
cfg <- as.list(envir$piecepack)
cfg$suit_color <- "black"
cfg$background_color.r1 <- "#E69F00"
cfg$background_color.r2 <- "#56B4E9"
cfg$background_color.r3 <- "#009E73"
cfg$background_color.r4 <- "#F0E442"
cfg$background_color.r5 <- "#D55E00"
cfg$background_color.r6 <- "#F079A7"
envir$piecepack <- pp_cfg(cfg)

ppn_file <- system.file("ppn/relativity.ppn", package = "ppn")
game <- read_ppn(ppn_file)[[1]]
animate_game(game, file = "man/figures/README-relativity.gif",
              annotate = FALSE,
              envir = envir, trans = op_transform, op_scale = 0.5,
              n_transitions = 3, n_pauses = 2, fps = 7)

Animation of Marty and Ron Hale-Evans' abstract game Relativity

{ppdf} supports the following 23 games playable with a (possibly non-8x8) checkers set:

{ppdf} supports the following 2 games playable with a (possibly non-8x8) chess set:

{ppdf} supports the following 1 games playable with a (usually double-6) dominoes set (plus possibly additional components):

{ppdf} supports the following 87 games playable with a piecepack deck (plus possibly additional components):

  • {piecepackr} can be used visualize game setups generated by {ppdf} with {grid}, {ggplot2}, {rayrender}, {rayvertex}, or {rgl} graphics systems.
  • {ppcli} can be used to visualize game setups generated by {ppdf} in the terminal with {cli}.
  • {ppn} contains a Portable Piecepack Notation (PPN) parser that handles all the games supported by this package (and more)
  • {piecenikr} has Looney Pyramids aka Icehouse pieces support.
  • splendid-r-games for list of games you can play in the R language

About

Generate board game setups

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published