Hallo Ich hab mal wieder eine Frage :confused:
Also ich habe diesen Code bekommen [ganzer Code unten] und muss nun am Dienstag von London wegfliegen und am Freitag wieder in London landen und dazwischen muss ich durch Mialno, Ljubljana und Zürich fliegen. Und jeden Tag kann man nur einmal fliegen
Ich habe es nun mit
aber es kommt immer nur false
was mach ich falsch? denn
Code
travel0(City1,City2,Day,Arrival1,[City1-City3:Flight1:Departure1|Residual]):-[INDENT]flight(City1,City3,Day,Flight1,Departure1,Arrival3),[/INDENT]
[INDENT]possibleTransfer(Arrival1,Departure1),[/INDENT]
[INDENT]travel0(City3,City2,Day,Arrival3,Residual).
[/INDENT]
City1 = London
City 2= London
Day = Tue
Arrival = Fri
City1-City3 = [Milano, Zürich, Ljubiljana]
oder hab ich da jz iwas falsch verstanden?? verzweifel schon langsam :confused:
Code
% flights.pl:
:-op(50,xfy,:).
timeTable(edinburgh,london,[INDENT][9:40/10:50/ba4733/daily,[/INDENT]
[INDENT]13:40/14:50/ba4753/daily,
19:40/20:50/ba4833/[mon,tue,wed,thu,fri,sun]]).
[/INDENT]
timeTable(london,edinburgh,[INDENT][9:40/10:50/ba4732/daily,
11:40/12:50/ba4752/daily,
18:40/19:50/ba4822/[mon,tue,wed,thu,fri]]).
[/INDENT]
timeTable(london,ljubljana,[INDENT][13:20/16:20/sa201/[fri],
13:20/16:20/sa213/[sun]]).
[/INDENT]
timeTable(ljubljana,london,[INDENT][11:10/12:20/sa200/[fri],
11:25/12:20/sa212/[sun]]).
[/INDENT]
timeTable(london,zurich,[INDENT][9:10/11:45/ba510/daily,
14:45/17:20/sr459/daily]).
[/INDENT]
timeTable(zurich,london,[INDENT][9:00/9:40/ba613/[mon,tue,wed,thu,fri,sat],
16:10/16:55/sr806/[mon,tue,wed,thu,fri,sun]]).
[/INDENT]
timeTable(london,milano,[INDENT][8:30/11:20/ba510/daily,
11:00/13:50/az459/daily]).
[/INDENT]
timeTable(milano,london,[INDENT][9:10/10:00/az458/daily,
12:20/13:10/ba511/daily]).
[/INDENT]
timeTable(ljubljana,zurich,[INDENT][11:30/12:40/sa322/[tue,thu]]).
[/INDENT]
timeTable(zurich,ljubljana,[INDENT][13:30/14:40/sa323/[tue,thu]]).
[/INDENT]
timeTable(zurich,milano,[INDENT][7:55/8:45/sr620/daily]).
[/INDENT]
timeTable(milano,zurich,[INDENT][9:25/10:15/sr621/daily,[/INDENT]
[INDENT]12:45/13:35/sr623/daily]).
[/INDENT]
flight(City1,City2,Day,Flight,Departure,Arrival):-[INDENT]timeTable(City1,City2,TimeTable),[/INDENT]
[INDENT]member(Departure/Arrival/Flight/DayTimeTable,TimeTable),[/INDENT]
[INDENT]dayOfFlight(Day,DayTimeTable).
[/INDENT]
dayOfFlight(Day,daily):-[INDENT]member(Day,[mon,tue,wed,thu,fri,sat,sun]).[/INDENT]
dayOfFlight(Day,List):-[INDENT]member(Day,List).
[/INDENT]
travel(City1,City2,Day,Letovi):-[INDENT]travel0(City1,City2,Day,0:0,Letovi).
[/INDENT]
% Arrival1 contains the time of arrival in City1;
% it limits the no. of flights with which one can continue travelling
travel0(City1,City2,Day,Arrival1,[City1-City2:Flight:Departure1]):-[INDENT]flight(City1,City2,Day,Flight,Departure1,_),[/INDENT]
[INDENT]possibleTransfer(Arrival1,Departure1).
[/INDENT]
travel0(City1,City2,Day,Arrival1,[City1-City3:Flight1:Departure1|Residual]):-[INDENT]flight(City1,City3,Day,Flight1,Departure1,Arrival3),[/INDENT]
[INDENT]possibleTransfer(Arrival1,Departure1),[/INDENT]
[INDENT]travel0(City3,City2,Day,Arrival3,Residual).
[/INDENT]
timeOfDeparture([_-_:_:Departure|_],Departure).
possibleTransfer(Hour1:Minute1,Hour2:Minute2):-[INDENT]60*(Hour2-Hour1)+Minute2-Minute1>=40.
[/INDENT]
member(X,[X|_]).member(X,[_|Rest]):-[INDENT]member(X,Rest).
[/INDENT]
Alles anzeigen