From f99c7db178964f641a422d4ad7cbe60e1483f3e5 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Tue, 1 Mar 2016 00:38:27 +0100 Subject: Improved hints for ancestor/2. --- prolog/problems/family_relations/ancestor_2/common.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'prolog/problems/family_relations/ancestor_2/common.py') 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: -- cgit v1.2.1