summaryrefslogtreecommitdiff
path: root/prolog
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-03-01 00:38:27 +0100
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-03-01 00:38:27 +0100
commitf99c7db178964f641a422d4ad7cbe60e1483f3e5 (patch)
treece42c22feeba5fdd673f423fc15590a4af2c371c /prolog
parentff8c6a018249920a79dd20d37edf5a4b7a311691 (diff)
Improved hints for ancestor/2.
Diffstat (limited to 'prolog')
-rw-r--r--prolog/problems/family_relations/ancestor_2/common.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/prolog/problems/family_relations/ancestor_2/common.py b/prolog/problems/family_relations/ancestor_2/common.py
index 3b70227..d2e4f76 100644
--- a/prolog/problems/family_relations/ancestor_2/common.py
+++ b/prolog/problems/family_relations/ancestor_2/common.py
@@ -89,23 +89,23 @@ def hint(code, aux_code):
return [{'id': 'base_case'}]
# ancestor to oneself
- if prolog.engine.ask_truth(engine_id, 'ancestor(X, X)'):
+ if prolog.engine.ask_truthTO(engine_id, 'ancestor(X, X)'):
return [{'id': 'ancestor_to_oneself'}]
- # Y does not necessarily need to be a parent
- if prolog.engine.ask_one(engine_id,
- 'ancestor(_, Y), \+ parent(Y, _)') == 'false':
- return [{'id': 'descendant_need_not_be_parent'}]
-
# descendant instead of ancestor (wrong direction)
# warning: knowledge base dependent
- if prolog.engine.ask_truth(engine_id,
+ if prolog.engine.ask_truthTO(engine_id,
'findall(_, ancestor(william, X), L1), length(L1, 2), \
findall(_, ancestor(X, william), L2), length(L2, 6)'):
return [{'id': 'wrong_direction'}]
+ # Y does not necessarily need to be a parent
+ if prolog.engine.ask_one(engine_id,
+ 'ancestor(_, Y), \+ parent(Y, _)') == 'false':
+ return [{'id': 'descendant_need_not_be_parent'}]
+
except socket.timeout as ex:
- return [{'id': 'base_case'}]
+ pass
finally:
if engine_id: