From 2d9a7b4323c8f78495ce45917cefdb502c846bbc Mon Sep 17 00:00:00 2001
From: Aleksander Sadikov
Date: Mon, 29 Feb 2016 13:46:53 +0100
Subject: Hints for aunt/2 improved. Also added to text for
predicate_always_false hints.
---
prolog/problems/family_relations/aunt_2/common.py | 9 +++++++--
prolog/problems/family_relations/aunt_2/sl.py | 8 ++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
(limited to 'prolog/problems/family_relations/aunt_2')
diff --git a/prolog/problems/family_relations/aunt_2/common.py b/prolog/problems/family_relations/aunt_2/common.py
index e545000..d408041 100644
--- a/prolog/problems/family_relations/aunt_2/common.py
+++ b/prolog/problems/family_relations/aunt_2/common.py
@@ -33,6 +33,7 @@ hint_type = {
'aunt_vs_mother': Hint('aunt_vs_mother'),
'x_need_not_be_parent': Hint('x_need_not_be_parent'),
'y_need_not_be_parent': Hint('y_need_not_be_parent'),
+ 'predicate_always_false': Hint('predicate_always_false'),
}
test_cases = [
@@ -69,12 +70,16 @@ def hint(code, aux_code):
try:
engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
+ # target predicate seems to always be false
+ if not prolog.engine.ask_truth(engine_id, 'aunt(_, _)'):
+ return [{'id': 'predicate_always_false'}]
+
# X and Y mixed up
# warning: knowledge base dependent
# independent: match on findall(X/Y, (sister(Y, P), parent(P, X)), L)
if prolog.engine.ask_truth(engine_id,
- 'findall(X/Y, aunt(X, Y), \
- [vanessa/sally, patricia/sally, joanne/melanie, john/vanessa, susan/patricia])'):
+ 'setof(X/Y, aunt(X, Y), [alessandro/daniela, alessandro/luana, jeffrey/andrew, \
+ jeffrey/melanie, patricia/susan, vanessa/john, william/andrew, william/melanie])'):
return [{'id': 'x_and_y_mixed_up'}]
# precedence fail (AND block vs OR block)
diff --git a/prolog/problems/family_relations/aunt_2/sl.py b/prolog/problems/family_relations/aunt_2/sl.py
index 81014f4..15b6aec 100644
--- a/prolog/problems/family_relations/aunt_2/sl.py
+++ b/prolog/problems/family_relations/aunt_2/sl.py
@@ -70,5 +70,13 @@ Si morda pozabil, da teta in starš od Y
ne smeta biti ista oseba?<
Teta je namreč sestra od starša od Y
.
''', # TODO: only trigger if sister is not part of correct solution
+
+ 'predicate_always_false': '''\
+Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?
+Če je ime pravilno, se morda splača preveriti tudi, če se nisi zatipkal kje drugje,
+je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?
+Možno je seveda tudi, da so tvoji pogoji prestrogi ali celo nemogoči (kot bi bila npr. zahteva,
+da je X
hkrati starš in sestra od Y
).
+''',
}
--
cgit v1.2.1