This Prolog program utilizes the A* search algorithm to solve a path finding on a colored board. Given a board consisting of cells with colors (Red, Yellow, or Blue), the program searches for a path between a start and a goal cell of the same color.
Prolog interpreter (e.g., SWI-Prolog)
- Clone the repository to your local machine:
git clone https://github.com/AbdelrhmanReda17/prolog-color-pathfinding-a-star.git
- Navigate to the project directory:
cd prolog-color-pathfinding-a-star
- Run the Prolog program:
swipl get-path.pl
- The program will output either a path found or a message indicating that no path exist.
-
For example, as shown in the picture, 0,0 is the start cell and 1,3 is the end cell. The correct path is 0,0 -> 1,0 -> 2,0 -> 2,1 -> 2,2 -> 1,2 -> 1,3
-
Example Input:
?- find_path([[red, red , yellow ,yellow], [red, blue, red , red], [red, red , red, yellow] ,[blue, red , blue, yellow]] , [0,0] , [1,3]).
-
Example Output:
Path found: [[0,0],[1,0],[2,0],[2,1],[2,2],[1,2],[1,3]]