3 input lists - 1 modified output list
From: Neil York Oliver (neilyork82_at_yahoo.com)
Date: 04/28/04
- Next message: FirewallVictim: "NEWBIE QUESTION: List Searching"
- Previous message: Neil York Oliver: "lists"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Apr 2004 02:45:00 +1000
Hi,
I am trying to write a procedure that has four arguments. Please help me
with this problem.
MyCase(A,B,C,D)
A is a list of options (each of the form is aa(X,Y,S).
B is a list of locations (It only contains one atom of the form bb(X,Y).
C is a list of intentions (each of the form is aa(X,Y,S).
D is the required result(output) that should return the modified list of
intentions (adding new options (aa(X,Y,S)) into the existing list of
intentions). If a new option is the same distance from it as an existing one
(aa(X,Y,S)), then the new option is added later in the modified list.
Thanks. What will be the best algorithm?
Regards,
Joe
PS.
To make it easier,
new options will be inserted into the current list in order of Manhattan
distance of the goal(aa(X,Y,S)) from the ((agent's)) current location.
% Manhattan distance between two squares
distance((X,Y), (X1,Y1), D) :-
dif(X, X1, Dx),
dif(Y, Y1, Dy),
D is Dx + Dy.
% D is |A - B|
dif(A, B, D) :-
D is A - B, D >= 0, !.
dif(A, B, D) :-
D is B - A.
- Next message: FirewallVictim: "NEWBIE QUESTION: List Searching"
- Previous message: Neil York Oliver: "lists"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|