| Title: | Players for Piecepack Games like Fuji-san |
|---|---|
| Description: | Functions that provide players for piecepack games like a solver for "Fuji-san". |
| Authors: | Trevor L. Davis [aut, cre] (ORCID: <https://orcid.org/0000-0001-6341-4639>) |
| Maintainer: | Trevor L. Davis <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0-1 |
| Built: | 2026-05-17 07:39:53 UTC |
| Source: | https://github.com/piecepackr/ppgamer |
Solves a Dominosa (Domino Solitaire) puzzle given a grid of pip values.
solve_dominosa(pips)solve_dominosa(pips)
pips |
A matrix of non-negative integer pip values,
or a string with rows of integers separated by |
A list with components:
domino_idsAn integer matrix of the same dimensions as pips
where cells belonging to the same domino share the same integer value.
pipsThe input pips matrix.
ppnA string of Portable Piecepack Notation for the solution.
https://www.solitairelaboratory.com/puzzlelaboratory/DominoGG.html and https://puzzlebreaks.com/dominosa/ for more information about Dominosa.
pips <- matrix(c(0, 1, 0, 1, 3, 3, 1, 0, 2, 2, 3, 2, 1, 0, 3, 2, 3, 1, 0, 2), nrow = 4L, byrow = TRUE) s <- solve_dominosa(pips) if (rlang::is_installed(c("piecepackr", "ppn"))) { g <- ppn::read_ppn(textConnection(s$ppn))[[1]] envir <- piecepackr::game_systems(round = TRUE) ppn::plot_move(g, open_device = FALSE, annotate = FALSE, envir = envir, scale = 0.95) }pips <- matrix(c(0, 1, 0, 1, 3, 3, 1, 0, 2, 2, 3, 2, 1, 0, 3, 2, 3, 1, 0, 2), nrow = 4L, byrow = TRUE) s <- solve_dominosa(pips) if (rlang::is_installed(c("piecepackr", "ppn"))) { g <- ppn::read_ppn(textConnection(s$ppn))[[1]] envir <- piecepackr::game_systems(round = TRUE) ppn::plot_move(g, open_device = FALSE, annotate = FALSE, envir = envir, scale = 0.95) }
Solves a game of Fujisan (if possible).
solve_fujisan( coins = random_fujisan_coins(), dice = random_dice() - 1, pawns = "S12M/A12C" )solve_fujisan( coins = random_fujisan_coins(), dice = random_dice() - 1, pawns = "S12M/A12C" )
coins |
A vector or matrix of Fujisan coin layout. Default is a random layout. |
dice |
A vector of Fujisan dice layout. Default is random dice. Usually not needed. |
pawns |
A FEN-like string of the pawns position. The four pawns |
A list with solution of Fujisan solution, its length, coin layout, dice (if needed), pawn position string, and portable piecepack notation.
puzzle2 <- matrix(c(4, 4, 4, 5, 2, 0, 2, 4, 0, 3, 1, 1, 1, 2, 5, 3, 3, 5, 3, 2, 5, 1, 0, 0), nrow = 2, byrow = TRUE) s <- solve_fujisan(coins = puzzle2) print(s$shortest_distance) # minimum number of moves to solve gamepuzzle2 <- matrix(c(4, 4, 4, 5, 2, 0, 2, 4, 0, 3, 1, 1, 1, 2, 5, 3, 3, 5, 3, 2, 5, 1, 0, 0), nrow = 2, byrow = TRUE) s <- solve_fujisan(coins = puzzle2) print(s$shortest_distance) # minimum number of moves to solve game