Skip to content

piecepackr/piecenikr

Repository files navigation

piecenikr: Looney Pyramids graphics

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

Looney Pyramids aka Icehouse pieces is a game system invented by Andrew Looney. The following are good sites of information about Looney Pyramids:

This R package provides a looney_pyramid_game_system() configuration that make it easier to make Looney Pyramids graphics with piecepackr.

License

Installation

Within R do:

install.packages("remotes")
remotes::install_github("piecepackr/piecepackr")
remotes::install_github("piecepackr/ppgames") # suggested
remotes::install_github("piecepackr/piecenikr")

Examples

This package contains a looney_pyramid_game_system() configuration for use with {piecepackr}. By default it includes a black border for use with {grid} graphics.

library("piecepackr")
library("piecenikr")
library("ppdf")
library("tibble")
envir <- c(looney_pyramid_game_system(), game_systems())

dfb <- checker_board(side="back", nrows=3L, ncols=3L, suit = 2L, cell_width = 2)
df1 <- icehouse_pyramids(side = "face",
                         x=2*c(1,2,2,1),
                         y=2*c(2,2,1,1),
                         suit=1:4,
                         rank=c(1:3,3),
                         angle=seq(90, 360, 90))

df2 <- icehouse_pyramids(side = "top",
                         x=2*c(1,2,3,3,3,3,3,3,3),
                         y=2*c(3,3,3,2,1,1,2,2,2),
                         suit=c(1:6,1:3),
                         rank=c(1:3,3,3,1,2,1,1))
df <- rbind(dfb, df1, df2)

pmap_piece(df, grid.piece, envir = envir, default.units = "in")
Example diagrams using {grid}
grid::grid.newpage()
pmap_piece(df, grid.piece, envir = envir, default.units = "in",
           op_scale = 0.25, op_angle = 90, trans=op_transform)
Example diagrams using {grid}

But you may want to use looney_pyramid_game_system(border = FALSE) when making graphics with the {rgl}, {rayrender}, or {rayvertex} packages:

library("piecepackr")
library("piecenikr")
library("ppdf")
library("rgl")
library("tibble")
envir <- c(looney_pyramid_game_system(border = FALSE),
           game_systems(border = FALSE))

dfb <- checker_board(nrows = 3L, ncols = 3L, suit = 6L, cell_width = 2) |> transform(x = 0, y = 0)
dfp1 <- icehouse_pyramids(side = "top", x = 0, y = 0, rank = 3L, suit = 5L)
dfp2 <- icehouse_pyramids(side = "face",
                          x = rep(c(-2, 0, 2), 3),
                          y = rep(c(2, 0, -2), each = 3),
                          angle = c(45, 0, -45, 90, 0, -90, 135, 180, -135),
                          suit = rep(1:6, length.out = 9L),
                          rank = rep(1:3, length.out = 9L))[-5L, ]
df <- dplyr::bind_rows(dfb, dfp1, dfp2)

invisible(open3d())
view3d(phi = -30, zoom = 0.8)
if (nzchar(Sys.which("wmctrl"))) system("wmctrl -r RGL -e 0,-1,-1,600,600")
pmap_piece(df, piece3d, envir = envir, trans = op_transform, scale = 0.99, lit = TRUE)
Sys.sleep(2)
rgl.snapshot("man/figures/rgl_looney_pyramids.png")
Example {rgl} diagram

There are also functions which perform board set ups for games that use Looney Pyramids:

  1. icehouse_martian_chess() sets up Martian Chess, an abstract by Andrew Looney.
  2. ppdf::piecepack_alien_city() sets up Alien City, an abstract by Michael Schoessow.

Here is an example of using icehouse_martian_chess() and the PPN parser ppn::read_ppn() in order to animate a game of Martian Chess.

library("piecenikr")
library("ppn")
ppn_file <- system.file("ppn/martian-chess.ppn", package = "piecenikr")
game <- read_ppn(ppn_file)[[1L]]
envir <- c(looney_pyramid_game_system(), game_systems())
animate_game(game, file = "man/figures/martian-chess.gif",
             annotate = FALSE, envir = envir,
             ppi = 50,
             n_transitions = 6L, n_pauses = 4L, fps = 8,
             trans = op_transform, op_scale = 0.25, op_angle = 90,
             pt_thickness = 0.3)
Animation of a game of Martian Chess

About

Looney Pyramids graphics in R

Resources

Stars

Watchers

Forks

Packages

No packages published