I need your help in solving the following problem:
There're 3 girls (Ann,Susan,Alice) who need to choose what color shoes and dress to wear. There're 3 possible colors for shoes and dresses: white, blue and green.
Main conditions:
- Ann hates white.
- Susan wears shoes and dress of same color.
- Alice has white shoes.
- Alice and Ann's shoes and dress have different colors.
My code satisfies only 2 conditions; I'm kinda having hard times meeting conditions on the same color for Susan and whereas other girls need to have different color garments.
Here's what I come up with:
PREDICATES
girl(symbol)
shoes(symbol,symbol)
skirt(symbol,symbol)
hates(symbol,symbol)
will_wear(symbol, symbol, symbol)
CLAUSES
will_wear(X,Y,Z):-
girl(X),
shoes(X,Y),
skirt(X,Z),
not(hates(X,Y)),
not(hates(X,Z)).
girl(ann).
girl(susan).
girl(alice).
hates(ann,white).
skirt(_,white).
skirt(_,blue).
skirt(_,green).
shoes(alice,white).
shoes(_,blue).
shoes(_,green).
GOAL
will_wear(Name,Shoes,Dress).
Code above works fine, but gives too many solutions. Plus, I couldn't come up with any logical solution for the condition for Susan to wear shoes and dress of same color.
Thanks.