diff options
author | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-02-28 01:39:23 +0100 |
---|---|---|
committer | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-02-28 01:39:23 +0100 |
commit | 05b57576d151a49a3c04b5e0817324baadc7bcf4 (patch) | |
tree | e169e664163384e2023d61ece6e1bc35bd7c2af3 /prolog/problems/family_relations/mother_2/common.py | |
parent | 66ae415ba019fa4528f61a23948e56a713902295 (diff) |
mother/2 and father/2 hints improved.
Diffstat (limited to 'prolog/problems/family_relations/mother_2/common.py')
-rw-r--r-- | prolog/problems/family_relations/mother_2/common.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/prolog/problems/family_relations/mother_2/common.py b/prolog/problems/family_relations/mother_2/common.py index 040c13e..1bb7a4b 100644 --- a/prolog/problems/family_relations/mother_2/common.py +++ b/prolog/problems/family_relations/mother_2/common.py @@ -25,6 +25,7 @@ hint_type = { 'x_must_be_parent': Hint('x_must_be_parent'), 'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'), 'y_need_not_be_parent': Hint('y_need_not_be_parent'), + 'predicate_always_false': Hint('predicate_always_false'), } test_cases = [ @@ -93,15 +94,19 @@ def hint(code, aux_code): return [{'id': 'x_must_be_parent'}] # Y can be of any gender, incl. male - if prolog.engine.ask_one(engine_id, - 'mother(_, Y), male(Y)') == 'false': + if prolog.engine.ask_truth(engine_id, 'mother(_, Y)') and \ + prolog.engine.ask_one(engine_id, 'mother(_, Y), male(Y)') == 'false': return [{'id': 'y_can_be_of_any_gender'}] # Y does not necessarily need to be a parent - if prolog.engine.ask_one(engine_id, - 'mother(_, Y), \+ parent(Y, _)') == 'false': + if prolog.engine.ask_truth(engine_id, 'mother(_, Y)') and \ + prolog.engine.ask_one(engine_id, 'mother(_, Y), \+ parent(Y, _)') == 'false': return [{'id': 'y_need_not_be_parent'}] + # target predicate seems to always be false + if prolog.engine.ask_one(engine_id, 'mother(_, _)') == 'false': + return [{'id': 'predicate_always_false'}] + except socket.timeout as ex: pass |