diff options
Diffstat (limited to 'prolog/problems/family_relations/ancestor_2')
-rw-r--r-- | prolog/problems/family_relations/ancestor_2/common.py | 16 |
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: |