From d4e24f31ab51640c2e65eb68446f0d5f6174b7e1 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Wed, 2 Mar 2016 15:24:00 +0100 Subject: Improved hints for ancestor/2 and descendant/2. --- prolog/problems/family_relations/ancestor_2/common.py | 5 +++++ prolog/problems/family_relations/ancestor_2/sl.py | 8 ++++++++ prolog/problems/family_relations/descendant_2/common.py | 5 +++++ prolog/problems/family_relations/descendant_2/sl.py | 8 ++++++++ prolog/problems/family_relations/grandparent_2/common.py | 7 ------- prolog/problems/family_relations/grandparent_2/sl.py | 2 +- 6 files changed, 27 insertions(+), 8 deletions(-) (limited to 'prolog/problems/family_relations') diff --git a/prolog/problems/family_relations/ancestor_2/common.py b/prolog/problems/family_relations/ancestor_2/common.py index 2353eab..a7c491d 100644 --- a/prolog/problems/family_relations/ancestor_2/common.py +++ b/prolog/problems/family_relations/ancestor_2/common.py @@ -31,6 +31,7 @@ hint_type = { 'descendant_need_not_be_parent': Hint('descendant_need_not_be_parent'), 'wrong_direction': Hint('wrong_direction'), 'only_two_levels_deep': Hint('only_two_levels_deep'), + 'predicate_always_false': Hint('predicate_always_false'), 'timeout': Hint('timeout'), } @@ -84,6 +85,10 @@ def hint(code, aux_code): return [{'id': 'grandparent_used_markup', 'start': m[0], 'end': m[1]} for m in marks] + \ [{'id': 'grandparent_used'}] + # target predicate seems to always be false + if not prolog.engine.ask_truthTO(engine_id, 'ancestor(_, _)'): + return [{'id': 'predicate_always_false'}] + # descendant instead of ancestor (wrong direction) # warning: knowledge base dependent if prolog.engine.ask_truthTO(engine_id, diff --git a/prolog/problems/family_relations/ancestor_2/sl.py b/prolog/problems/family_relations/ancestor_2/sl.py index 974bde3..de66ba4 100644 --- a/prolog/problems/family_relations/ancestor_2/sl.py +++ b/prolog/problems/family_relations/ancestor_2/sl.py @@ -78,6 +78,14 @@ npr. prababica ali prapradedek sta tudi prednika.

Si morda sprogramiral ravno obratno in zamenjal prednika s potomcem? X naj bo prednik od Y in ne obratno!

+''', + + 'predicate_always_false': '''\ +

Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?

+

Če je ime pravilno, se morda splača preveriti tudi, če se nisi zatipkal kje drugje, +je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?

+

Možno je seveda tudi, da so tvoji pogoji prestrogi ali celo nemogoči (kot bi bila npr. zahteva, +da je X hkrati starš in sestra od Y ali kaj podobnega).

''', 'timeout': '''\ diff --git a/prolog/problems/family_relations/descendant_2/common.py b/prolog/problems/family_relations/descendant_2/common.py index b4d8f31..6cfe1cd 100644 --- a/prolog/problems/family_relations/descendant_2/common.py +++ b/prolog/problems/family_relations/descendant_2/common.py @@ -30,6 +30,7 @@ hint_type = { 'descendant_of_oneself_with_or': Hint('descendant_of_oneself_with_or'), 'descendant_need_not_be_parent': Hint('descendant_need_not_be_parent'), 'wrong_direction': Hint('wrong_direction'), + 'predicate_always_false': Hint('predicate_always_false'), 'timeout': Hint('timeout'), 'final_hint': Hint('final_hint'), } @@ -88,6 +89,10 @@ def hint(code, aux_code): return [{'id': 'grandparent_used_markup', 'start': m[0], 'end': m[1]} for m in marks] + \ [{'id': 'grandparent_used'}] + # target predicate seems to always be false + if not prolog.engine.ask_truthTO(engine_id, 'descendant(_, _)'): + return [{'id': 'predicate_always_false'}] + # ancestor instead of descendant (wrong direction) # warning: knowledge base dependent if prolog.engine.ask_truthTO(engine_id, diff --git a/prolog/problems/family_relations/descendant_2/sl.py b/prolog/problems/family_relations/descendant_2/sl.py index 9f1d818..c53c8b9 100644 --- a/prolog/problems/family_relations/descendant_2/sl.py +++ b/prolog/problems/family_relations/descendant_2/sl.py @@ -68,6 +68,14 @@ Premisli, morda se ti splača tudi grafično skicirati tvojo trenutno rešitev.< 'descendant_need_not_be_parent': '''\

Potomec X pravzaprav ne rabi imeti otrok...

+''', + + 'predicate_always_false': '''\ +

Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?

+

Če je ime pravilno, se morda splača preveriti tudi, če se nisi zatipkal kje drugje, +je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?

+

Možno je seveda tudi, da so tvoji pogoji prestrogi ali celo nemogoči (kot bi bila npr. zahteva, +da je X hkrati starš in sestra od Y ali kaj podobnega).

''', 'timeout': '''\ diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py index 1665c18..6939e85 100644 --- a/prolog/problems/family_relations/grandparent_2/common.py +++ b/prolog/problems/family_relations/grandparent_2/common.py @@ -134,10 +134,3 @@ def hint(code, aux_code): return [] -# sudo mount -o ro /dev/sdaX /mnt -# things to discuss with Tim -# 1o can we make predicate_always_false a ghint? -# with this in mind: how can we supply/know the correct target name and arity? -# 2x popraviti je potrebno spremni tekst glede na novo lokacijo gumba Namig -# 3x what's the name of \= token? And what of =\= token? -# 4 final hint! This very much improves the user experience, adds knowledge, therefore needs to be implemented now! diff --git a/prolog/problems/family_relations/grandparent_2/sl.py b/prolog/problems/family_relations/grandparent_2/sl.py index 231be90..3f8a549 100644 --- a/prolog/problems/family_relations/grandparent_2/sl.py +++ b/prolog/problems/family_relations/grandparent_2/sl.py @@ -67,6 +67,6 @@ hint = {

Če je ime pravilno, se morda splača preveriti tudi, če se nisi zatipkal kje drugje, je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?

Možno je seveda tudi, da so tvoji pogoji prestrogi ali celo nemogoči (kot bi bila npr. zahteva, -da je X hkrati starš in sestra od Y).

+da je X hkrati starš in sestra od Y ali kaj podobnega).

''', } -- cgit v1.2.1