From plqueiroz@hotmail.com  Fri Apr 21 17:42:45 2000
Received: from hotmail.com (f20.law8.hotmail.com [216.33.241.20])
	by swi.psy.uva.nl (8.9.3/8.9.3) with SMTP id RAA12231
	for <prolog@swi.psy.uva.nl>; Fri, 21 Apr 2000 17:42:44 +0200 (MET DST)
Received: (qmail 65939 invoked by uid 0); 21 Apr 2000 15:42:31 -0000
Message-ID: <20000421154231.65938.qmail@hotmail.com>
Received: from 161.24.1.117 by www.hotmail.com with HTTP;
	Fri, 21 Apr 2000 08:42:31 PDT
X-Originating-IP: [161.24.1.117]
From: "Albert Fox" <plqueiroz@hotmail.com>
To: jan@swi.psy.uva.nl, jhinds@mtsu.edu, prolog@swi.psy.uva.nl
Subject: question prolog program
Date: Fri, 21 Apr 2000 15:42:31 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1; format=flowed

If you have the complete program below , please send to me.

/* Problem Solving :- Water Jugs Problem */


initial_state(jugs,jugs(0,0)).

    final_state(jugs(4,0)).
    final_state(jugs(0,4)).

    move(jugs(V1,V2),fill(1)).
    move(jugs(V1,V2),fill(2)).
    move(jugs(V1,V2),empty(1)).
    move(jugs(V1,V2),empty(2)).
    move(jugs(V1,V2),transfer(2,1)).
    move(jugs(V1,V2),transfer(1,2)).

    update(jugs(V1,V2),fill(1),jugs(C1,V2)) :- capacity(1,C1).
    update(jugs(V1,V2),fill(2),jugs(V1,C2)) :- capacity(2,C2).
    update(jugs(V1,V2),empty(1),jugs(0,V2)).
    update(jugs(V1,V2),empty(2),jugs(V1,0)).
    update(jugs(V1,V2),transfer(2,1),jugs(W1,W2)) :-
capacity(1,C1),
Liquid is V1 + V2,
Excess is Liquid - C1,
adjust(Liquid,Excess,W1,W2).
    update(jugs(V1,V2),transfer(1,2),jugs(W1,W2)) :-
capacity(2,C2),
       Liquid is V1 + V2,
       Excess is Liquid - C2,
       adjust(Liquid,Excess,W2,W1).

    adjust(Liquid, Excess,Liquid,0) :- Excess =< 0.
    adjust(Liquid,Excess,V,Excess) :- Excess > 0, V is Liquid - Excess.

    legal(jugs(V1,V2)).

    capacity(1,8).
    capacity(2,5).

%  Program 20.3    Solving the water jugs problem


________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

