diff options
-rw-r--r-- | prolog/problems/family_relations/father_2/common.py | 13 | ||||
-rw-r--r-- | prolog/problems/family_relations/father_2/sl.py | 5 | ||||
-rw-r--r-- | prolog/problems/family_relations/mother_2/common.py | 13 | ||||
-rw-r--r-- | prolog/problems/family_relations/mother_2/sl.py | 5 |
4 files changed, 28 insertions, 8 deletions
diff --git a/prolog/problems/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py index 0c65a83..11f0742 100644 --- a/prolog/problems/family_relations/father_2/common.py +++ b/prolog/problems/family_relations/father_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 = [ @@ -92,15 +93,19 @@ def hint(code, aux_code): return [{'id': 'x_must_be_parent'}] # Y can be of any gender, incl. female - if prolog.engine.ask_one(engine_id, - 'father(_, Y), female(Y)') == 'false': + if prolog.engine.ask_truth(engine_id, 'father(_, Y)') and \ + prolog.engine.ask_one(engine_id, 'father(_, Y), female(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, - 'father(_, Y), \+ parent(Y, _)') == 'false': + if prolog.engine.ask_truth(engine_id, 'father(_, Y)') and \ + prolog.engine.ask_one(engine_id, 'father(_, 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, 'father(_, _)') == 'false': + return [{'id': 'predicate_always_false'}] + except socket.timeout as ex: pass diff --git a/prolog/problems/family_relations/father_2/sl.py b/prolog/problems/family_relations/father_2/sl.py index 4f7f3de..e399d39 100644 --- a/prolog/problems/family_relations/father_2/sl.py +++ b/prolog/problems/family_relations/father_2/sl.py @@ -54,4 +54,9 @@ Pozor: velja eno ALI drugo, ne nujno eno IN drugo!</p> 'y_need_not_be_parent': '''\ <p><code>Y</code> pravzaprav ne rabi imeti otrok, da ima očeta...</p> ''', + + 'predicate_always_false': '''\ +<p>Vse kaže, da tvoj predikat vedno vrne "false". Morda se splača preveriti, če si se kje zatipkal, +je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?</p> +''', } 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 diff --git a/prolog/problems/family_relations/mother_2/sl.py b/prolog/problems/family_relations/mother_2/sl.py index e3cbd1e..5a98cb6 100644 --- a/prolog/problems/family_relations/mother_2/sl.py +++ b/prolog/problems/family_relations/mother_2/sl.py @@ -55,4 +55,9 @@ Pozor: velja eno ALI drugo, ne nujno eno IN drugo!</p> 'y_need_not_be_parent': '''\ <p><code>Y</code> pravzaprav ne rabi imeti otrok, da ima mamo...</p> ''', + + 'predicate_always_false': '''\ +<p>Vse kaže, da tvoj predikat vedno vrne "false". Morda se splača preveriti, če si se kje zatipkal, +je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?</p> +''', } |