Created
June 2, 2015 13:52
-
-
Save Superlokkus/f5d217143c854b9bd0d1 to your computer and use it in GitHub Desktop.
Fehlerhafte aber funktionierende Lösung für KI Aufgabe 18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- [idDfs]. | |
%Es folgt die schlecht umgesetzte aber immerhin funktionierende Lösung für KI Aufgabe 18 | |
adj(X,Y) :- adj0(X,Y); adj0(Y,X). | |
adj0(X,Y) :- member((X,Y), [ | |
(1,2), (2,3), (4,5), | |
(2,7), (4,9), (5,10), | |
(6,7), (7,8), (8,9), | |
(7,12), (10,15), | |
(13,14), (14,15), | |
(11,16), (12,17), (14,19),(15,20), | |
(17,18), (18,19), | |
(19,24), | |
(21,22), (22,23), (23,24), (24,25) | |
]). | |
%blumen([3,17,20,21]). | |
%Frau(25). | |
%Mann = 7. | |
zweig(Start,Ziele,Weg,Depth) :- | |
(length(Ziele,Y), Y =:= 0),writeln(Weg); | |
subset(Weg,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]),%Workaround , cut würde sicher helfen um Endlos Unifizierung abzubrechen | |
selectchk(AktZiel,Ziele,RestZiele), | |
dlDfs(Start,AktZiel,[Start], Depth, ReturnPath), | |
length(ReturnPath,D), | |
select(_Dup,ReturnPath,RP), | |
append(Weg,RP,L), | |
zweig(AktZiel,RestZiele,L,Depth - D). | |
sammeln0(Start,Frau,Blumen,Weg,Depth) :- | |
permutation(P,Blumen),append(P,[Frau],G), | |
zweig(Start,G,Weg,Depth); | |
writeln(Depth), | |
sammeln0(Start,Frau,Blumen,Weg,Depth+1). | |
sammeln(Start,Frau,Blumen,Weg) :- sammeln0(Start,Frau,Blumen,Weg,1). %Weg wird aufgrund von einem Designfehler nicht unifiziert, aber immerhin geprintet | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment