Any prolog fans? I was attempting to go on the codecomments.com prolog forum, but they're down for the moment so I was curious to see if anyone here knew any prolog...Basically I'm trying to write a program that emulates the game 6 Degrees of Kevin Bacon...

how you play is you pick an actor and you try to see how many degrees away from Kevin Bacon he is. I.E. Kevin Bacon was in Apollo 13 and so was Tom Hanks, so Tom Hanks is 1 degree away from Kevin Bacon. Tim Allen was in Toy Story with Tom Hanks, so Tim allen is 2 degrees away from Kevin Bacon. However, I'm very new to prolog, and I'm stuck...here's the code I have worked out thus far...

%% I plan on adding a lot more examples then this
in('Kevin Bacon', 'Appollo 13').
in('Tom Hanks', 'Appollo 13').
in('Tom Hanks', 'Toy Story').
in('Tim Allen', 'Toy Story').
in('Kevin Smith', 'Mallrats').

%%related/2 - sees if the 2 actors are related
related(X, Y) :-
in(X, Z),
in(Y, Z),
not(in(X, X)),
not(in(Y, Y)).

%%degrees/3 - asks if actor x is Z degrees away from actor Y
degrees(X, Y, Z) :-
related(X, Y),
Z is 1.
degrees(X, Y, Z) :-
related(X, Actor),
related(Actor, Y),
Z is 2.

basically my problem is that Kevin Bacon under this set up is both 1 degree and 2 degrees away. Prolog sees that Kevin Bacon is related to himself, also that he's related to Tom Hanks, both editions. Any ideas how to cure this ailment? Thanks buddies in advance.