summaryrefslogtreecommitdiff
path: root/prolog/problems
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-02-29 00:11:26 +0100
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-02-29 00:11:26 +0100
commit49a2f24a813ca250d1c1f31f9799661ff70615ed (patch)
tree1579e7ce6ae679f5fe6cc53f4510dfa78a7ec4a3 /prolog/problems
parentbc40d810afbcde332730d50ed490deb432689db1 (diff)
Additional improvements to hints for mother, father, grandparent, sister, and brother problems.
Diffstat (limited to 'prolog/problems')
-rw-r--r--prolog/problems/family_relations/brother_2/common.py13
-rw-r--r--prolog/problems/family_relations/brother_2/sl.py12
-rw-r--r--prolog/problems/family_relations/father_2/sl.py3
-rw-r--r--prolog/problems/family_relations/grandparent_2/common.py14
-rw-r--r--prolog/problems/family_relations/grandparent_2/sl.py6
-rw-r--r--prolog/problems/family_relations/mother_2/sl.py3
-rw-r--r--prolog/problems/family_relations/sister_2/common.py13
-rw-r--r--prolog/problems/family_relations/sister_2/sl.py12
8 files changed, 56 insertions, 20 deletions
diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py
index 7f61744..0ad74c3 100644
--- a/prolog/problems/family_relations/brother_2/common.py
+++ b/prolog/problems/family_relations/brother_2/common.py
@@ -26,7 +26,8 @@ hint_type = {
'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'),
'x_y_must_be_different': Hint('x_y_must_be_different'),
'neq_used_too_early': Hint('neq_used_too_early'),
- 'nm_instead_of_neq': Hint('nm_instead_of_neq'),
+ 'neq+_instead_of_neq': Hint('neq+_instead_of_neq'),
+ 'predicate_always_false': Hint('predicate_always_false'),
}
test_cases = [
@@ -78,9 +79,13 @@ def hint(code, aux_code):
prolog.engine.ask_one(engine_id, 'brother(_, Y), female(Y)') == 'false':
return [{'id': 'y_can_be_of_any_gender'}]
- # use of \= instead of \==
- if prolog.util.Token('NEQ', '\=') in tokens:
- return [{'id': 'nm_instead_of_neq'}]
+ # use of \= or =\= instead of \==
+ 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,
diff --git a/prolog/problems/family_relations/brother_2/sl.py b/prolog/problems/family_relations/brother_2/sl.py
index f8eba49..ed2d015 100644
--- a/prolog/problems/family_relations/brother_2/sl.py
+++ b/prolog/problems/family_relations/brother_2/sl.py
@@ -46,9 +46,10 @@ Na primer: <code>X \== Y</code></p>
<p><code>Y</code> je pravzaprav lahko poljubnega spola.</p>
''',
- 'nm_instead_of_neq': '''\
-<p>Uporabi raje operator \== namesto operatorja \=. Prvi preveri, da dva objekta nista enaka,
-drugi pa ju poskusi unificirati (narediti enaka).</p>
+ 'neq+_instead_of_neq': '''\
+<p>Uporabi raje operator \== namesto operatorjev \= ali =\=. Prvi preveri, da oba operanda nista enaka,
+drugi (\=) ju poskusi unificirati (narediti enaka), tretji (=\=) pa je samo za aritmetično primerjanje
+in morata oba operanda biti takoj izračunljiva aritmetična izraza.</p>
''',
'common_parent_needed': '''\
@@ -65,4 +66,9 @@ ko naleti na primerjavo.</p>
<p>Morda pa preprosto preverjaš napačni spremenljivki?</p>
''',
+ 'predicate_always_false': '''\
+<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</p>
+<p>Č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?</p>
+''',
}
diff --git a/prolog/problems/family_relations/father_2/sl.py b/prolog/problems/family_relations/father_2/sl.py
index e399d39..e59e42d 100644
--- a/prolog/problems/family_relations/father_2/sl.py
+++ b/prolog/problems/family_relations/father_2/sl.py
@@ -56,7 +56,8 @@ Pozor: velja eno ALI drugo, ne nujno eno IN drugo!</p>
''',
'predicate_always_false': '''\
-<p>Vse kaže, da tvoj predikat vedno vrne "false". Morda se splača preveriti, če si se kje zatipkal,
+<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</p>
+<p>Č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?</p>
''',
}
diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py
index 45273c6..870ceb1 100644
--- a/prolog/problems/family_relations/grandparent_2/common.py
+++ b/prolog/problems/family_relations/grandparent_2/common.py
@@ -27,6 +27,7 @@ hint_type = {
'x_need_not_have_parent': Hint('x_need_not_have_parent'),
'y_must_have_parent': Hint('y_must_have_parent'),
'y_need_not_be_parent': Hint('y_need_not_be_parent'),
+ 'predicate_always_false': Hint('predicate_always_false'),
}
test_cases = [
@@ -120,6 +121,10 @@ def hint(code, aux_code):
prolog.engine.ask_one(engine_id, 'grandparent(_, 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, 'grandparent(_, _)') == 'false':
+ return [{'id': 'predicate_always_false'}]
+
except socket.timeout as ex:
pass
@@ -131,7 +136,8 @@ def hint(code, aux_code):
# sudo mount -o ro /dev/sdaX /mnt
# things to discuss with Tim
-# * can we make predicate_always_false a ghint?
-# with this in mind: how can we supply/know the correct target name and arity?
-# * popraviti je potrebno spremni tekst glede na novo lokacijo gumba Namig
-# * what's the name of \= token? And what of =\= token?
+# 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
+# 3 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 2961ffa..549d7cc 100644
--- a/prolog/problems/family_relations/grandparent_2/sl.py
+++ b/prolog/problems/family_relations/grandparent_2/sl.py
@@ -61,4 +61,10 @@ hint = {
'y_need_not_be_parent': '''\
<p>Vnuk <code>Y</code> pravzaprav ne rabi imeti otrok, da ima dedka ali babico...</p>
''',
+
+ 'predicate_always_false': '''\
+<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</p>
+<p>Č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?</p>
+''',
}
diff --git a/prolog/problems/family_relations/mother_2/sl.py b/prolog/problems/family_relations/mother_2/sl.py
index 5a98cb6..9656d88 100644
--- a/prolog/problems/family_relations/mother_2/sl.py
+++ b/prolog/problems/family_relations/mother_2/sl.py
@@ -57,7 +57,8 @@ Pozor: velja eno ALI drugo, ne nujno eno IN drugo!</p>
''',
'predicate_always_false': '''\
-<p>Vse kaže, da tvoj predikat vedno vrne "false". Morda se splača preveriti, če si se kje zatipkal,
+<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</p>
+<p>Č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?</p>
''',
}
diff --git a/prolog/problems/family_relations/sister_2/common.py b/prolog/problems/family_relations/sister_2/common.py
index 1bc9365..1234985 100644
--- a/prolog/problems/family_relations/sister_2/common.py
+++ b/prolog/problems/family_relations/sister_2/common.py
@@ -26,7 +26,8 @@ hint_type = {
'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'),
'x_y_must_be_different': Hint('x_y_must_be_different'),
'neq_used_too_early': Hint('neq_used_too_early'),
- 'nm_instead_of_neq': Hint('nm_instead_of_neq'),
+ 'neq+_instead_of_neq': Hint('neq+_instead_of_neq'),
+ 'predicate_always_false': Hint('predicate_always_false'),
}
test_cases = [
@@ -107,9 +108,13 @@ def hint(code, aux_code):
prolog.engine.ask_one(engine_id, 'sister(_, Y), male(Y)') == 'false':
return [{'id': 'y_can_be_of_any_gender'}]
- # use of \= instead of \==
- if prolog.util.Token('NEQ', '\=') in tokens:
- return [{'id': 'nm_instead_of_neq'}]
+ # use of \= or =\= instead of \==
+ 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, 'sister(_, _)') == 'false':
+ return [{'id': 'predicate_always_false'}]
# X and Y must be different
# this is the last code-specific hint (when everything else doesn't trigger anymore)
diff --git a/prolog/problems/family_relations/sister_2/sl.py b/prolog/problems/family_relations/sister_2/sl.py
index 5fa9d1c..a1cf5c0 100644
--- a/prolog/problems/family_relations/sister_2/sl.py
+++ b/prolog/problems/family_relations/sister_2/sl.py
@@ -45,9 +45,10 @@ Na primer: <code>X \== Y</code></p>
<p><code>Y</code> je pravzaprav lahko poljubnega spola.</p>
''',
- 'nm_instead_of_neq': '''\
-<p>Uporabi raje operator \== namesto operatorja \=. Prvi preveri, da dva objekta nista enaka,
-drugi pa ju poskusi unificirati (narediti enaka).</p>
+ 'neq+_instead_of_neq': '''\
+<p>Uporabi raje operator \== namesto operatorjev \= ali =\=. Prvi preveri, da oba operanda nista enaka,
+drugi (\=) ju poskusi unificirati (narediti enaka), tretji (=\=) pa je samo za aritmetično primerjanje
+in morata oba operanda biti takoj izračunljiva aritmetična izraza.</p>
''',
'common_parent_needed': '''\
@@ -64,4 +65,9 @@ ko naleti na primerjavo.</p>
<p>Morda pa preprosto preverjaš napačni spremenljivki?</p>
''',
+ 'predicate_always_false': '''\
+<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</p>
+<p>Č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?</p>
+''',
}