A solution to the Wolf-Goat-Cabbage Problem for CPTR430("Artificial Intelligence") using a tree. The solution-finding algorithms are BFS and DFS.
A farmer with a wolf, a goat, and a container of cabbage are on the west bank of the river. On the river is a boat in which the farmer and one of the other three (wolf, goat, or cabbage) can fit. If the wolf is left alone with the goat, the wolf will eat the goat. If the goat is left alone with the container of cabbage, the goat will eat the cabbage. Your goal is to transfer everyone to the other side of the river safely.
Below details how to run this assignment.
Python3
Run the main.py
file using python3.
python 3 main.py
The solution will be output as a sequential array of the states of the problem. Note that the first array is the West bank, the second array is the East bank, and the Right
or Left
is the side the boat is on. The farmer is always on the side of the boat.