Last active
February 5, 2017 21:44
-
-
Save MattBlissett/ccb2e4d8de4332a20c1005fe8801a7e5 to your computer and use it in GitHub Desktop.
Friends at Hogwarts
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
% Prolog: How Hogwarts students decide their friends. | |
% (Very incomplete!) | |
% | |
% Try at http://swish.swi-prolog.org/ | |
% ?- friend(X, draco). | |
% X = harry. | |
% X = tom. | |
% | |
purebloodish(W) :- child(W, P), child(W, Q), | |
magical(P), magical(Q), | |
P \= Q. | |
halfblood(W) :- child(W, P), child(W, Q), | |
magical(P), | |
not(magical(Q)), | |
P \= Q. | |
mudblood(W) :- child(W, P), child(W, Q), | |
not(magical(P)), | |
not(magical(Q)), | |
P \= Q. | |
squib(S) :- child(S, P), | |
magical(P), | |
not(magical(S)). | |
friend(F, P) :- not(slytherin(P)), magical(F). | |
friend(F, _) :- magical(F), purebloodish(F). | |
friend(F, _) :- magical(F), halfblood(F). | |
child(harry, james). | |
child(harry, lily). | |
child(hermionie, dentist1). | |
child(hermionie, dentist2). | |
child(tom, tomsr). | |
child(tom, merope). | |
child(argus, argusdad). | |
child(argus, argusmum). | |
magical(james). | |
magical(lily). | |
magical(merope). | |
magical(harry). | |
magical(hermionie). | |
magical(tom). | |
magical(argusmum). | |
magical(draco). | |
slytherin(draco). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment