Package 'piecenikr'

Title: Looney Pyramid Graphics
Description: Functions and objects to make Looney Pyramids graphics.
Authors: Trevor L. Davis [aut, cre] (ORCID: <https://orcid.org/0000-0001-6341-4639>)
Maintainer: Trevor L. Davis <[email protected]>
License: CC BY-SA 4.0
Version: 0.2.1
Built: 2026-05-14 21:28:29 UTC
Source: https://github.com/piecepackr/piecenikr

Help Index


Data frames with game info

Description

icehouse_games() contain information about the games whose setups are provided by this package.

Usage

icehouse_games()

Value

A tibble::tibble() data frame with character columns "game", "methods", "comment", and "url" for game name, setup function name(s), possible comment, and url for more information.

Examples

head(icehouse_games())
nrow(icehouse_games())

Icehouse movetext parser

Description

icehouse_parser() provides a parser to be used with PPN movetext. looney_pyramid_parser() is an alias.

Usage

icehouse_parser(movetext = character(), metadata = list(), ...)

looney_pyramid_parser(movetext = character(), metadata = list(), ...)

Arguments

movetext

A named character vector of move text.

metadata

A named list of metadata

...

Passed to ppn::default_parser().

Value

A named list of data frames with parsed game states.

Examples

if (requireNamespace("ppn", quietly = TRUE)) {
  l <- ppn::read_ppn(system.file("ppn/martian-chess.ppn", package = "piecenikr"),
                     parse = FALSE)[[1L]]
  game <- icehouse_parser(l$movetext, l$metadata)
}

Generate icehouse pieces

Description

icehouse_pyramids() generates a data frame of icehouse pyramids, looney_pyramids() is an alias. icehouse_none() generates a zero-row data frame. icehouse_setup_by_name() generates a data frame from a given icehouse game name.

Usage

icehouse_pyramids(
  ...,
  side = "top",
  piece_side = paste0("pyramid_", side),
  suit = rep(1:5, each = 3L),
  rank = rep.int(1:3, 5L),
  x = as.double(rep.int(1:5, 3L)),
  y = as.double(rep(3:1, each = 5L)),
  angle = 0,
  length.out = NA_integer_
)

icehouse_none()

icehouse_setup_by_name(
  name,
  ...,
  getter = function(x) get(x, envir = getNamespace("piecenikr"))
)

Arguments

...

Should be left empty.

side

Normally either "top" (default) or "face".

piece_side

If "board_face" a checkered board (as in American Checkers). If "board_back" a lined board (as in Turkish Checkers).

suit

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

rank

Number of pips on the icehouse pyramid.

x, y

Cartesian coordinates (numeric vectors)

angle

Rotation of bit/board (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.

name

Game name. Will be normalized by normalize_name().

getter

Function with a single function name argument to use. By default will just look for functions in this package but a developer may want to consider dynGet() or a wrapper around get() with a custom envir argument.


Data frames of starting diagrams for various games

Description

tibble data frames of setups for 1 games playable with the Looney Pyramids game system. Data frame output can usually be plotted with pmap_piece(df, default.units = "in").

Usage

icehouse_martian_chess(n_players = 2, seed = NULL)

Arguments

n_players

Number of players

seed

Random seed

Details

Here are links for more information about the various other games:

Game URL
Martian Chess https://www.looneylabs.com/rules/martian-chess

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


Configuration objects for drawing Looney Pyramids

Description

looney_pyramid_game_system() provides a basic configuration object for drawing Looney Pyramids, icehouse_game_system() is an alias.

Usage

looney_pyramid_game_system(..., border = TRUE)

icehouse_game_system(..., border = TRUE)

Arguments

...

Should be empty.

border

If TRUE draw a black border line on piece edges. Should normally be TRUE when drawing with {grid} graphics and FALSE when drawing with 3D graphic systems.

Details

Looney Pyramids aka Icehouse pieces is a game system invented by Andrew Looney. See https://www.looneylabs.com/looney-pyramids.

Value

Returns a list with an icehouse_pieces configuration for drawing Looney Pyramids.


Basic grob function for Looney Pyramids

Description

looneyPyramidGrob provides a basic grob function for the sides Looney Pyramids.

Usage

looneyPyramidGrob(piece_side, suit, rank, cfg = pp_cfg())

Arguments

piece_side

Piece side of the piece

suit

Suit of the piece

rank

Rank of the piece

cfg

Piecepackr configuration object


Deprecated functions

Description

These functions are Deprecated in this release of piecenikr, they will be marked as Defunct and removed in a future version.

Usage

df_martian_chess(n_players = 2, seed = NULL)

looney_pyramids(..., border = TRUE)

Arguments

n_players

Number of players

seed

Random seed

...

Should be empty.

border

If TRUE draw a black border line on piece edges. Should normally be TRUE when drawing with {grid} graphics and FALSE when drawing with 3D graphic systems.