In this project, a solver for the wooden puzzle Snake Cube was developed in the Prolog programming language.
The program was built using SICStus Prolog, and this solver will use the library clpfd
provided from SICStus.
The user will provide the snake in a specified format, and the program will return a solution for it.
The user can ask for more solutions.
The snake provided should be a list starting and ending with the value 3
, and the mid values should be 1
or 2
, which the 1
will represent a straight in the snake, and the 2
a corner.
Information about the puzzle came from: https://www.jaapsch.net/puzzles/snakecube.htm
- Set the working directory to where the program will write the file.
File->Working Directory…
; - Consult the file
main.pl
; - Run
snake_cube(+Snake, +Mode)
.Snake
- The snake that you want to get a solution; There are some examples inmain.pl
such assnake_2d([3,2,2,2,2,2,2,3])
andunique_solution([3,2,2,2,2,2,2,2,2,1,2,1,2,2,2,1,2,2,2,2,2,2,2,2,2,2,3])
.Mode
- The number of solutions you want, it can beone
orall
.
The cube solution will give an array that has the order in which the positions will be visited.
The positions in the cube are the same as in this image: