A-star-search is a project mainly written in C, it's free.
Using an A* search to solve the 15 puzzle.
This is collection of C library data structures and a solution for the fifteen puzzle, using an A* Search.
Library:
Fifteen Puzzle:
Must free memory allocated by the a-star-search
Must write unit tests for the solver
Install Check, a C testing framework.
Download source code.
In the a-star-search directory, compile the source files with:
$ make
Also in the a-star-search directory, run the tests and ensure they all pass. To run library tests:
$ make libcheck
To use the data structures, include the path to the src folder, and link the library object file directory. Here's an example including the linkedlist.h file and linking the lib/src/* folder
In hello.c:
/*
* include the linkedlist header file
*/
include "../lib/src/linkedlist.h"
// ...
When compiling:
$ gcc -o hello hello.c ../lib/src/*.o
On the command line in the directory with the solver executable, run it with:
$ ./solver [--help] [--verbose] [--heuristic <hamming | manhattan>] <dim> <pos 1> <pos 2> ... <pos dim * dim>
Running solver with the --help flag will print this screen:
arguments summary:
--help Displays this help text.
--verbose Displays verbose output when solving. This includes a GUI printout and the value of the distance metric.
--heuristic <hamming | manhattan> Heuristic metric to use for the A* search. Manhattan is default.
<dim> Dimension of the square board. If the dimension is n, then we have an n x n board.
<pos k> Number at position k, where starting from 1, we count left to right, up to down. Put a 0 to mark the empty spot.
a-star-search/
README.md
Makefile
lib/
src/
Collection of data structure libraries, including linkedlist, arraylist, priorityqueue, stack, queue, and heap.
tests/
Collection of tests for these data structures, using the Check framework
fifteen-puzzle/
src/
Implementation of an A* Search on the fifteen puzzle.
tests/
Tests for the fifteen puzzle solver