again over F/W/G/C Problem i need some help.. 
Author Message
 again over F/W/G/C Problem i need some help..

I have written (with the help of a book) a solution to farmer/wolf/....
problem i hve to write a predicate
solve(X)/1 where X is a list of position that solves the problem and if Call
Solve(X) the answer is simply the solution but i dont know how to do that.
Would you be so kind to give the solution of/and an Hint over how to solve
this problem ,of i have to change  all the code ???
Thanks in advance.....
The code :..path(position(n,n,n,n),position(s,s,s,s),[position(s,s,s,s)]).
gives the answare but is /3 predicate
how can i add a new /1 predicate ???
maybe with (asserta) ????
% move/2

move(position(X,X,G,C), position(Y,Y,G,C))           % Farmer+Wolf
:- opposite(X,Y),
 not(unsafe(position(Y,Y,G,C))). % Test is not unsafe

move(positie(X,W,X,C), position(Y,W,Y,C))
%  Farmer+Goat
:- opposite(X,Y),
not(unsafe(position(Y,W,Y,C))). % Test is not unsafe

move(positie(X,W,G,X), positie(Y,W,G,Y))           % Farmer+Cabbage
:- opposite(X,Y),
not(unsafe(position(Y,W,G,Y))).%Test is not unsafe

move(positie(X,W,G,C), positie(Y,W,G,C))           % Farmer
:- opposite(X,Y),
not(unsafe(position(Y,W,G,C))). % Test is not unsafe

path(FirstNextPosition,FirstNextPosition,Stack) :-
% Final position
write('Solution Path Is:' ),nl,reverse(Stack).

path(StartPositie,EindPositie,Stack) :-
move(StartPositie,FirstNextPosition), %Find a move
 not(member(FirstNextPosition,Stack)), %


% member/2
member(X,[Y|T]) :- member(X,T).

% reverse/1
reverse([H|T]) :- reverse(T), write(H), nl.

% opposite structure

unsafe(position(X,Y,Y,C)) :- opposite(X,Y).
% Wolf eats  Goat
unsafe(position(X,W,Y,Y)) :- opposite(X,Y).
% Goat eats Cabbage

Mon, 02 Jun 2003 09:52:17 GMT  
 [ 1 post ] 

 Relevant Pages 

1. problem with registers FS and GS

2. Question on FS and GS registers

3. FS and GS registers

4. FS: and GS:

5. Using GS and FS segment register

6. The use of FS & GS

7. FS: and GS:

8. TD trashing gs/fs, anyone?

9. ws-to-ws transfer

10. Scheme vs ML again and again and again and again

11. Scheme vs ML again and again and again and again

12. VW/GS Remote SharedPageCache and Windows 2000 Advanced Server problem


Powered by phpBB® Forum Software