From 90dbc3fa624d62e093bea7b90a72a28ad216f7bd Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 29 Feb 2016 00:27:21 +0100 Subject: Additional improvements to hints for mother, father, grandparent, sister, and brother problems. --- prolog/problems/family_relations/brother_2/common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'prolog/problems/family_relations/brother_2') diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py index 0ad74c3..87f27a3 100644 --- a/prolog/problems/family_relations/brother_2/common.py +++ b/prolog/problems/family_relations/brother_2/common.py @@ -65,6 +65,10 @@ 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, 'brother(_, _)'): + return [{'id': 'predicate_always_false'}] + # X must be male if prolog.engine.ask_truth(engine_id, 'female(X), brother(X, _)'): return [{'id': 'x_must_be_male'}] @@ -83,10 +87,6 @@ def hint(code, aux_code): if prolog.util.Token('NEQU', '\=') in tokens or prolog.util.Token('NEQA', '=\=') in tokens: return [{'id': 'neq+_instead_of_neq'}] - # target predicate seems to always be false - if prolog.engine.ask_one(engine_id, 'brother(_, _)') == 'false': - return [{'id': 'predicate_always_false'}] - # X and Y must be different if prolog.util.Token('NEQ', '\==') not in tokens and prolog.engine.ask_truth(engine_id, 'setof(X, (member(X, [william, alessandro, andrew]), brother(X, X)), L), length(L, 3)'): -- cgit v1.2.1