Cannibals and Missionaries Problem Solver in Prolog
This GitHub repository contains a Prolog implementation for solving the classic "Cannibals and Missionaries" problem. The problem involves transporting missionaries and cannibals across a river, adhering to specific rules to avoid missionaries being eaten by cannibals. The Prolog code utilizes logical programming to represent states, valid moves, and safety checks.
Logical Representation: States of the problem, initial and goal states, and valid moves are represented using Prolog terms and predicates. Breadth-First Search: The code employs a breadth-first search strategy to efficiently find a solution path from the initial to the goal state. Safety Checks: The implementation includes safety checks to ensure that the number of cannibals does not exceed the number of missionaries on either side of the river.
Clone the repository. Load the Prolog file (missionaries-cannibals.pl) in your Prolog interpreter. Execute the "?- solve." predicate to find and display the solution path for the problem.