Question: n Prolog, you are going to write a maze solver. You will write the rule: solve ( X , Y ) where X is the
n Prolog, you are going to write a maze solver. You will write the rule:
solveX Y
where X is the starting point and Y is the ending point. It will determine if there is a
path between those points using facts in the form of:
pathab
Where a is the starting point of the path and b is the ending point. Paths in this
question are directional. This means that pathab means there is a path from a to
b but not b to a
Example Facts:
pathab
pathbc
pathcd
pathef
Example queries:
solveab: would result in true. There is a direct path.
solveba: would be false.
solvead: would be true. Path is abcd
solveaf: would be false.
Your solution should work for any length path.
Now modify your solution to allow paths to be bidirectional. So pathab allow
travel from a to b and b to a
Now modify your solution to add distance of the path.The for of solve will be:
solveX Y D
Where D is now the number of paths it took.
For example using the facts above, solveabD would say D is solveadD
would be
Now modify that solution to allow for paths to have different lengths. Path would not
be in the form:
pathab
Where is the distance of that path.
Example Facts:
pathab
pathbc
pathcd
pathef
Example queries:
solveabD: would result in true and D of
solvebaD: would result in true and D of
solveadD: would be true and a D of
solveafD: would be false.
Does your solution handle infinite circular paths? For instance with bidirectional paths,
you can have a path from a to c of abc and ababc and abababc Explain
how you would handle this. You do not need to write the code for it
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
