I need some help with a prolog homework for my AI class. The question is to write prolog code for einstein's puzzle. I know how to write it down in my own but there are some constraints in the homework.
there are 5 houses
the Englishman lives in the red house
the Spaniard owns the dog
coffee is drunk in the green house
the Ukrainian drinks tea
the green house is immediately to the right of the ivory house
the Old Gold smoker owns snails
Kools are smoked in the yellow house
milk is drunk in the middle house
the Norwegian lives in the first house
the man who smokes Chesterelds lives in the house next to the man with the fox
3 Kools are smoked in the house next to the house where the horse is kept
the Lucky Strike smoker drinks orange juice
the Japanese smokes Parliaments
the Norwegian lives next to the blue house
I know that I need to use list for houses because they are ordered. I wanted to use list for the house characteristics too but I got a problem here.
I was going to use anonymous variables house(englishman, red, _, _, _). but I dont know how to interpret that for the homework.
Here are the constraints: you should use the following binary predicate symbols:
owns(N,Pet)
smokes(N, Cigarette).
drinks(N, Drink).
Other than that you are free to use any number of predicates.
here is how I initialized the facts but I dont know how to make the rules in this case
next_to(X,Y) :- right_of(X,Y); right_of(Y,X).
owns(spaniard, dog).
drinks(ukrainian, tea).
smokes(japanese, parliaments).
right_of(ivory, green).
lives(englishman, red).
owns(X, snail) :- smokes(X, old_gold).
smokes(X, kools) :- owns(X, yellow).
smokes(X, lucky_strike) :- drinks(X, orange_juice).
drinks(X, coffee) :- owns(X, green_house).
it makes sense a little bit but it looks completely wrong at the same time. I don't think I can go anywhere with this one. :/
Question&Answers:os