Skip to contents

Solves a game of Fujisan (if possible).

Usage

solve_fujisan(
  coins = random_fujisan_coins(),
  dice = random_dice() - 1,
  pawns = "S12M/A12C"
)

Arguments

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 S, M, C, and A are represented by their letter and empty spaces by a number. The two rows are separated by /. Default is "S12M/A12C" (all pawns at starting corners).

Value

A list with solution of Fujisan solution, its length, coin layout, dice (if needed), pawns position, and portable piecepack notation.

Examples

 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
#> [1] 27
#> 
#> $shortest_path
#>  [1] "1_14_15_28" "1_14_16_28" "1_11_16_28" "1_11_19_28" "1_11_24_28"
#>  [6] "1_10_11_28" "1_11_12_28" "1_12_13_28" "1_12_27_28" "1_26_27_28"
#> [11] "1_25_26_27" "1_23_25_26" "1_18_25_26" "1_4_25_26"  "1_4_23_25" 
#> [16] "1_4_9_25"   "1_4_9_11"   "1_4_5_9"    "1_3_4_5"    "3_4_5_6"   
#> [21] "3_4_6_8"    "3_4_6_7"    "4_6_7_8"    "4_6_7_22"   "6_7_8_22"  
#> [26] "2_7_8_22"   "7_8_16_22"  "7_8_21_22" 
#> 
#> $coins
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,]    4    4    4    5    2    0    2    4    0     3     1     1
#> [2,]    1    2    5    3    3    5    3    2    5     1     0     0
#> 
#> $dice
#> [1] NA
#> 
#> $coin_string
#> [1] "44452n24n3aa/a25335325ann"
#> 
#> $dice_string
#> [1] NA
#> 
#> $pawns
#> [1] "S12M/A12C"
#> 
#> $n_counter_intuitive
#> [1] 5
#> 
#> $ppn
#> [1] "---\nGameType:\n  Name: Fujisan\n  Coins: \"44452n24n3aa/a25335325ann\"\n...\n1. a1-b1\n2. n2-k2\n3. b1-e1\n4. e1-j1\n5. j1-j2\n6. j2-l2\n7. k2-m2\n8. m2-m1\n9. l2-l1\n10. n1-k1\n11. m1-i1\n12. i1-d1\n13. d1-d2\n14. l1-i1\n15. i1-i2\n16. k1-k2\n17. k2-e2\n18. i2-c2\n19. a2-f2\n20. e2-h2\n21. h2-g2\n22. c2-h2\n23. h2-h1\n24. d2-h2\n25. f2-b2\n26. b2-b1\n27. b1-g1\n"
#>