GNU-Prolog

Iā€™m using: GNU-Prolog version ???

I want the code to:
What is the water source of each point - river or lake (assuming the source is the closest).1
The user enters a point number. The answer is the source of the water.
2. What are the shortest routes from each point to each of the sources.
The user enters a point number. The answer is two lists.
3. What is the total consumer from the water source to each point.
The user enters a point number. The answer is total consumption.
4. Assuming a water quality warning has been received from a monitoring station (marked in red), to which junctions should the
Water supply.
ALL OF THIS BY MAKING A DATA BASE WHAT I NEED TO USE FOR THOSE QUERYS
PLS HELP ME ITS ARRGENT!!!

This site is for SWI-Prolog.

If you need help with GNU-Prolog you will be better off asking on StackOverflow tag Prolog.

A good starting point for learning Prolog is this one for example.

1 Like

guys i dont have much time only until friday pls helppppppppp

If you use SWI-Prolog then others might answer.

not if they keep this tone.

1 Like

As a first step I would suggest to think about database tables ā€“ what tables would you want to have in the database to store the information about water sources, water points (rivers or lakes), and perhaps some geometric information ā€“ how rivers and lakes are connected and how long rivers are ā€“ i would imagine that a water source is the source of a river with rivers eventually end in lakes.

So, visualize this on a map and then translate what you see on a map into tables in a database.

Once you have tables you can translate these into prolog ā€“ with each table translated into prolog predicates ā€¦

Dan

Here is a possible starting point, maybe this helps you

% Here are some facts about what is connected to what as well as distances between things.
% start, end and distance are just convenient mnemonics for remembering what each argument is.
connection(start(someRiver), end(someLake), distance(20)).
connection(start(someLake), end(anotherRiver), distance(49)).

% X is connected to Y if there is a connection between X and Y. We dont care about distance (the third argument) here.
connected(X, Y):- 
    connection(start(X), end(Y), _).

% X is connected to Y if there is a connection between X and Intermediary, and if Intermediary is connected to Y.
% Again we dont care about distance.
connected(X, Y):- 
    connection(start(X), end(Intermediary), _),
    connected(Intermediary, Y).

Are you SWI-Prolog enthusiasts trading class problems for users? :wink: