I have looked all over and I cannot figure out how to make this work.
| ?- werewolf(sam).
no (needs to be yes)
here is my code so far. When a person gets bit they should become the entity that bit them however as shown above this is not working correctly. I have tried many different ways to do this but still... werewolf(sam) is always no when it should be yes.
Thanks for any help
-Matt
werewolf(X) :-
howlatmoon(X),
fleacollar(X).
vampire(X) :-
howlatmoon(X),
hatesgarlic(X);
hatesmirrors(X).
bittenby(X,Y) :-
Y is X.
bittenby(bob,sam).
bittenby(joe,bob).
fleacollar(bob).
howlatmoon(bob).
howlatmoon(joe).
hatesmirrors(joe).
Consider the following set of Halloween related facts:
1. If you howl at the moon and wear a flea collar you are a werewolf.
2. Anyone who howls at the moon and hates garlic or mirrors is a vampire.
3. Anyone bitten by a vampire becomes a vampire and anyone bitten by a werewolf becomes a werewolf.
4. Bob wears a flea collar.
5. Bob and Joe both howl at the moon.
6. Sam was bitten by Bob.
7. Joe hates mirrors.
8. Joe once bit Bob.
| ?- werewolf(sam).
no (needs to be yes)
here is my code so far. When a person gets bit they should become the entity that bit them however as shown above this is not working correctly. I have tried many different ways to do this but still... werewolf(sam) is always no when it should be yes.
Thanks for any help
-Matt
werewolf(X) :-
howlatmoon(X),
fleacollar(X).
vampire(X) :-
howlatmoon(X),
hatesgarlic(X);
hatesmirrors(X).
bittenby(X,Y) :-
Y is X.
bittenby(bob,sam).
bittenby(joe,bob).
fleacollar(bob).
howlatmoon(bob).
howlatmoon(joe).
hatesmirrors(joe).
Consider the following set of Halloween related facts:
1. If you howl at the moon and wear a flea collar you are a werewolf.
2. Anyone who howls at the moon and hates garlic or mirrors is a vampire.
3. Anyone bitten by a vampire becomes a vampire and anyone bitten by a werewolf becomes a werewolf.
4. Bob wears a flea collar.
5. Bob and Joe both howl at the moon.
6. Sam was bitten by Bob.
7. Joe hates mirrors.
8. Joe once bit Bob.