Basic Prolog Maze Runner Simple Program

You are asked to write a simple program in Prolog to find a path through a maze. Your

input will consist of facts of the form

pway(a, b, 10).

indicating that there is a passageway from intersection a to intersection b of length 10 meters.

You are to write a rule

solve(X, Y, P, N) :- ...

that will find a path P of length N (if one exists) from intersection X to intersection Y.

The intent is that the user will invoke solve as a query, specifying X and Y as constants and P and N as variables.

Here is a concrete example. Suppose the database contains the following rules:

pway(a, b, 10).

pway(b, c, 15).

pway(d, c, 5).

pway(d, b, 10).

If the user types

solve(a, d, P, N)

the Prolog interpreter might respond with

P = [a, b, c, d]

N = 30 If at this point the user types a semicolon, the interpreter should respond with

P = [a, b, d]

N = 20

One more semicolon should produce


There are no more paths.


1. Note that passageways are bi-directional; if you can walk 10 meters from a tob, you can

also walk 10 meters from b toa.

2. Most mazes will have cycles. Your code must cope with them. There's no point in

passing through the same intersection more than once, and you certainly don't want the

interpreter to fall into an infinite regression doing so.

3. Note that the bi-directionality of passageways creates a huge number of trivial cycles:

you'll want to avoid walking from a tob and back to a again.


1. You might find the tutorials at the link below very useful.

[login to view URL]~jrfisher/www/prolog_tutorial/[login to view URL]

2. You shouldn't need to use any imperative features of Prolog (the cut, fail, or

database ordering) for this work. In fact, you shouldn't even need not, though you'll

probably want \= (numeric ``not equal''). A solution for the assignment consisting of

only seven rules does exist!

3. You'll want to add distances. Remember that you must use the is predicate to force

arithmetic computation.

4. generating all possible solutions, sorting them, and then producing them one-by-one on

demand. Other approaches may be easier, however. You may need the use of cut and fail

for the this part of the work.

[login to view URL] script. Make sure to you will deliver your work as a include your README

and test cases/mazes.

Kemahiran: Prolog

Lihat lagi: maze solving algorithm c++, maze problem in c, recursive maze solver c++, prolog examples list, maze solving algorithm in c, prolog examples pdf, maze problem in prolog, maze solving algorithm java, simple program search txt file, simple program lotto, simple program request accept entered information, simple program ticketmaster, simple program notepad, free simple program, visual simple program, simple program file text line, simple program visual basic output system, create simple program salary computation using basic turbo, simple program visual basic, simple program visual basic hindi

Tentang Majikan:
( 2 ulasan ) Hafizabad, Pakistan

ID Projek: #19041216

6 pekerja bebas membida secara purata $52 untuk pekerjaan ini


Hello Sir, I am a computer science tutor, I teach (among others) Prolog and Advanced Algorithms. I have done many projects like this, and I'm one of the top Prolog developers, and you can check by clicking on my prof Lagi

$50 USD dalam sehari
(104 Ulasan)

Hi, I am a software engineer experienced in Prolog (I am using SWI Prolog). I can complete your project within 3 days from awarding, properly tested and commented. Looking forward to hearing from you.

$45 USD dalam 2 hari
(27 Ulasan)

Hi i am expert on prolog, I can help you on this, you can check my lastest feedback and see the most of them are done in prolog.

$50 USD dalam 2 hari
(12 Ulasan)

Hello, I use Prolog programming daily in my regular employment. I will create a Prolog program to solve these mazes. I will be using SWI Prolog. A milestone payment for the full budget for your project must be de Lagi

$126 USD dalam 3 hari
(2 Ulasan)

solve(X, Y, P ,N):- solve2(X, Y, [], P, N). solve2(X, X, _, [], 0). solve2(X, Y, PP, [X|P], N):- X \= Y, pway(X, Z, N1), noinc(Z, PP), solve2(Z, Y, [X|PP], P, N2), N is N1 + N2. solve2(X, Y, PP, Lagi

$10 USD dalam sehari
(1 Ulasan)

Hello! I've read your description and have several questions. 1. You say I don't need "not" statement for search, but to cut cycles I need to use member predicate with not, e.g. I will proceed if X is not member of pa Lagi

$30 USD dalam 6 hari
(0 Ulasan)