From aec4e861a2477762326c0f9b001668f5c1ff9ddb Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Wed, 30 Sep 2015 17:39:14 +0200 Subject: Figures added for mother problem. --- .../problems/family_relations/grandparent_2/common.py | 17 +++++++++++------ prolog/problems/family_relations/mother_2/Mother-1.png | Bin 0 -> 40513 bytes prolog/problems/family_relations/mother_2/Mother-2.png | Bin 0 -> 36521 bytes prolog/problems/family_relations/mother_2/Mother-3.png | Bin 0 -> 38712 bytes prolog/problems/family_relations/mother_2/sl.py | 8 ++++---- 5 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 prolog/problems/family_relations/mother_2/Mother-1.png create mode 100644 prolog/problems/family_relations/mother_2/Mother-2.png create mode 100644 prolog/problems/family_relations/mother_2/Mother-3.png diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py index 98e40fc..8ccd23d 100644 --- a/prolog/problems/family_relations/grandparent_2/common.py +++ b/prolog/problems/family_relations/grandparent_2/common.py @@ -103,16 +103,21 @@ def hint(program, solved_problems): 'grandparent(X, _), \+ parent(X, _)'): return [{'id': 'x_must_be_parent'}] - # X does not necessarily need to have a parent - if prolog.engine.ask_one(engine_id, - 'grandparent(X, _), \+ parent(_, X)') == 'false': - return [{'id': 'x_need_not_have_parent'}] - # Y must have a parent if prolog.engine.ask_truth(engine_id, 'grandparent(_, Y), \+ parent(_, Y)'): return [{'id': 'y_must_have_parent'}] + # stop further hint testing if target predicate is always true or always false + if prolog.engine.ask_truth(engine_id, + '\+ grandparent(_, _) ; findall(X/Y, grandparent(X, Y), [A/B]), var(A), var(B)'): + return [] + + # X does not necessarily need to have a parent + if prolog.engine.ask_one(engine_id, + 'grandparent(X, _), \+ parent(_, X)') == 'false': + return [{'id': 'x_need_not_have_parent'}] + # Y does not necessarily need to be a parent if prolog.engine.ask_one(engine_id, 'grandparent(_, Y), \+ parent(Y, _)') == 'false': @@ -125,5 +130,5 @@ def hint(program, solved_problems): if engine_id: prolog.engine.destroy(engine_id) - return None + return [] diff --git a/prolog/problems/family_relations/mother_2/Mother-1.png b/prolog/problems/family_relations/mother_2/Mother-1.png new file mode 100644 index 0000000..239b54f Binary files /dev/null and b/prolog/problems/family_relations/mother_2/Mother-1.png differ diff --git a/prolog/problems/family_relations/mother_2/Mother-2.png b/prolog/problems/family_relations/mother_2/Mother-2.png new file mode 100644 index 0000000..e0179e4 Binary files /dev/null and b/prolog/problems/family_relations/mother_2/Mother-2.png differ diff --git a/prolog/problems/family_relations/mother_2/Mother-3.png b/prolog/problems/family_relations/mother_2/Mother-3.png new file mode 100644 index 0000000..e0ea5c1 Binary files /dev/null and b/prolog/problems/family_relations/mother_2/Mother-3.png differ diff --git a/prolog/problems/family_relations/mother_2/sl.py b/prolog/problems/family_relations/mother_2/sl.py index 3494096..bd4d57e 100644 --- a/prolog/problems/family_relations/mother_2/sl.py +++ b/prolog/problems/family_relations/mother_2/sl.py @@ -16,10 +16,10 @@ description = '''\ plan = [ '''\ -

+

Mama ima otroka in je ženskega spola.

Loni naj zbriše imena relacij (parent, mother) s te slike!

''', '''\ -

''', +

Mama X je starš od Y in je ženskega spola.

''', '''\

Če je X ženska in je hkrati X starš od Y, potem je X mama od Y.

''' @@ -32,12 +32,12 @@ hint = { 'x_must_be_female': '''\

Mama je navadno ženskega spola.

-

+

''', 'x_must_be_parent': '''\

Mama naj bi imela vsaj enega otroka... torej je starš od nekoga.

-

+

''', 'y_can_be_of_any_gender': '''\ -- cgit v1.2.1