Use edger to solve triangular edge matching puzzles using a backtracking algorithm. edger is inspired by a puzzle (pictured below) given to me by Tash and Stu; and Ken Shirriff's article on solving a similar puzzle with Arc.
There are many types of edge matching puzzles. Some parameters include: shape and number of tiles; the existence of edge constraints like those in the picture; and whether edges match symmetrically or asymetrically (e.g. matching colour to colour, or matching the head of a frog to it's legs). This package solves the puzzle pictured above, ignoring the edge constraints for simplicity. I might expand edger to solve a broader range of puzzles If I feel like it.
Install edger from github with:
# install.packages("devtools")
devtools::install_github("jsphdms/edger")Visually inspect solutions like so:
library(edger)
edge_plot(tiles = list(c("green", "red", "yellow") # Top row
,c("green", "yellow", "white") # Second row
,c("white", "white", "blue")
,c("blue", "black", "white")
,c("white", "green", "red") # Third row
,c("black", "green", "red")
,c("green", "black", "black")
,c("yellow", "green", "white")
,c("blue", "yellow", "red")
,c("green", "red", "black") # Fourth row
,c("blue", "white", "blue")
,c("white", "black", "blue")
,c("red", "yellow", "white")
,c("yellow", "black", "blue")
,c("green", "yellow", "black")
,c("green", "black", "red")))
