Skip to content
Python program that solves the Missionaries and Cannibals problem, a toy problem in AI, with iterative deepening search.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
missionaries_and_cannibals Add better error message Feb 17, 2018

Missionaries and Cannibals

Build Status

Solves the missionaries and cannibals problem with iterative deepening search.

The problem is as follows:

Three missionaries and three cannibals are on one side of a river, along with a boat that can hold one or two people.

initial state

Find a way to get everyone to the other side, without ever leaving a group of missionaries on one side outnumbered by the cannibals.

The current state is represented with a list [a, b, c]. This list represents the number of missionaries on the wrong side, cannibals on the wrong side, and whether the boat is on the wrong side. Initially all the missionaries, cannibals, and the boat are on the wrong side of the river. The list representing the initial state is [3, 3, 1], while the list representing the goal state is [0, 0, 0].

The program outputs the 11 step path to the goal state to the screen.

How to Run


Please run with Python 3. The program was written with Python 3.6.3.

You can’t perform that action at this time.