Question
Please help me with my assignment! The Language is Prolog . The Puzzle There are three cannibals and three missionaries on one bank of a
Please help me with my assignment! The Language is Prolog.
The Puzzle
There are three cannibals and three missionaries on one bank of a river. They want to get to the other side. There is a rowboat, but it can only hold one or two people at a time.
The boat will not go across the river by itself. It must be rowed. Either a missionary a cannibal can row the boat, but if it ever happens that cannibals outnumber missionaries on either bank of the river, then the cannibals will eat the missionaries on that bank. (Note that it is okay for there to be some positive number of cannibals and no missionaries on a bank, since then there are no missionaries to be eaten.) Someone who is in the boat on a given bank is considered to be on that bank, so a missionary cannot hide in the boat.
The problem is to develop a plan for getting everybody across the river, without anybody being eaten.
The assignment
Write a program in a logic programming style in Prolog for the Missionaries/Cannibals problem. It should print solutions that do not involve reaching the same state twice. Print the solution as a sequence of states. It is not necessary to give instructions for how to get from one state to the next, since that should be obvious from the states themselves.
Please include a definition of parameterless predicate run. Goal
run.
should run the program, finding and printing a path from the initial state to the final state.
Tracing
Goal
trace.
succeeds and turns on tracing. After that, start the program. Each time you hit Enter, one more step will be done.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started