[gbrainy] New Predicate Logic puzzle
- From: Jordi Mas <jmas src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gbrainy] New Predicate Logic puzzle
- Date: Wed, 6 Jan 2010 13:01:03 +0000 (UTC)
commit 54ce9c26b30008b2317a33732d549a0d6772bd42
Author: Jordi Mas <jmas softcatala org>
Date: Wed Jan 6 14:01:28 2010 +0100
New Predicate Logic puzzle
po/POTFILES.in | 1 +
src/Games/GameList.cs | 1 +
src/Games/Logic/PuzzlePredicateLogic.cs | 158 +++++++++++++++++++++++++++++++
src/Games/Makefile.am | 1 +
4 files changed, 161 insertions(+), 0 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 25fc912..fc07858 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,6 +57,7 @@ src/Games/Logic/PuzzleNextFigure.cs
src/Games/Logic/PuzzleNumericRelation.cs
src/Games/Logic/PuzzleNumericSequence.cs
src/Games/Logic/PuzzleOstracism.cs
+src/Games/Logic/PuzzlePredicateLogic.cs
src/Games/Logic/PuzzlePencil.cs
src/Games/Logic/PuzzlePeopleTable.cs
src/Games/Logic/PuzzlePercentage.cs
diff --git a/src/Games/GameList.cs b/src/Games/GameList.cs
index 6271402..623e097 100644
--- a/src/Games/GameList.cs
+++ b/src/Games/GameList.cs
@@ -74,6 +74,7 @@ namespace gbrainy.Games
typeof (PuzzlePercentage),
typeof (PuzzleTimeNow),
typeof (Puzzle3DCube),
+ typeof (PuzzlePredicateLogic),
};
static Type[] CalculationTrainersInternal = new Type[]
diff --git a/src/Games/Logic/PuzzlePredicateLogic.cs b/src/Games/Logic/PuzzlePredicateLogic.cs
new file mode 100644
index 0000000..be74812
--- /dev/null
+++ b/src/Games/Logic/PuzzlePredicateLogic.cs
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+using System;
+using Cairo;
+using Mono.Unix;
+
+using gbrainy.Core.Main;
+using gbrainy.Core.Libraries;
+
+namespace gbrainy.Games.Logic
+{
+ public class PuzzlePredicateLogic : Game
+ {
+ int question;
+ ArrayListIndicesRandom random_indices;
+ const int num_options = 4;
+
+ internal struct Predicate
+ {
+ internal string question;
+ internal string [] options;
+ internal int answer_index;
+
+ internal Predicate (string question, string op1, string op2, string op3, string op4, int answer_index)
+ {
+ this.question = question;
+ this.answer_index = answer_index;
+
+ options = new string [num_options];
+ options[0] = op1;
+ options[1] = op2;
+ options[2] = op3;
+ options[3] = op4;
+ }
+ };
+
+ Predicate [] predicates =
+ {
+ new Predicate (String.Format (Catalog.GetString ("If all painters are artists and some citizens of Barcelona are artists. Which of the following sentences is correct? Answer {0}, {1}, {2} or {3}."),
+ GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ Catalog.GetString ("Some citizens of Barcelona are painters"),
+ Catalog.GetString ("All citizens of Barcelona are painters"),
+ Catalog.GetString ("No citizen of Barcelona is a painter"),
+ Catalog.GetString ("None of the other options"),
+ 3),
+
+ new Predicate (String.Format (Catalog.GetString ("If no ill artist is happy and some artists are happy. Which of the following sentences is correct? Answer {0}, {1}, {2} or {3}."),
+ GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ Catalog.GetString ("Some artist are not ill"),
+ Catalog.GetString ("Some painters are not artists"),
+ Catalog.GetString ("All artists are happy"),
+ Catalog.GetString ("None of the other options"),
+ 0),
+
+ new Predicate (String.Format (Catalog.GetString ("If people that travels always buy a map and you are not going to travel. Which of the following sentences is correct? Answer {0}, {1}, {2} or {3}."),
+ GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ Catalog.GetString ("You do not have any map"),
+ Catalog.GetString ("You do not buy a map"),
+ Catalog.GetString ("All people has a map"),
+ Catalog.GetString ("None of the other options"),
+ 3),
+
+ new Predicate (String.Format (Catalog.GetString ("If you whistle if you are happy and you only smile when you whistle. Which of the following sentences is correct? Answer {0}, {1}, {2} or {3}."),
+ GetPossibleAnswer (0), GetPossibleAnswer (1), GetPossibleAnswer (2), GetPossibleAnswer (3)),
+ Catalog.GetString ("You smile if you are happy"),
+ Catalog.GetString ("You are only happy if you whistle"),
+ Catalog.GetString ("You whistle if you are not happy"),
+ Catalog.GetString ("None of the other options"),
+ 0),
+ };
+
+ public override string Name {
+ get {return Catalog.GetString ("Predicate Logic");}
+ }
+
+ public override string Question {
+ get {return predicates[question].question;}
+ }
+
+ public override string Tip {
+ get { return Catalog.GetString ("A triangle can be embedded inside another triangle.");}
+ }
+
+ public override string Answer {
+ get {
+ string answer = base.Answer + " ";
+ return answer;
+ }
+ }
+
+ public override void Initialize ()
+ {
+ int answers;
+ int correct_answer;
+
+ question = random.Next (predicates.Length);
+
+ correct_answer = predicates [question].answer_index;
+ answers = predicates [question].options.Length;
+ random_indices = new ArrayListIndicesRandom (answers - 1);
+ random_indices.Initialize ();
+ random_indices.Add (answers - 1);
+
+ for (int i = 0; i < answers; i++)
+ {
+ if (random_indices[i] == correct_answer) {
+ right_answer = GetPossibleAnswer (i);
+ break;
+ }
+ }
+
+ }
+
+ public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
+ {
+ double x = DrawAreaX, y = DrawAreaY + 0.1;
+ int option;
+
+ base.Draw (gr, area_width, area_height, rtl);
+
+ gr.SetPangoLargeFontSize ();
+ gr.MoveTo (0.1, y);
+ gr.ShowPangoText (Catalog.GetString ("Possible answers are:"));
+
+ gr.SetPangoNormalFontSize ();
+
+ y += 0.15;
+ x += 0.05;
+ for (int n = 0; n < predicates[question].options.Length; n++)
+ {
+ option = random_indices [n];
+ gr.MoveTo (x, y);
+ gr.ShowPangoText (String.Format ("{0}) {1}", GetPossibleAnswer (n),
+ predicates[question].options[option].ToString ()));
+ gr.Stroke ();
+ y += 0.15;
+ }
+ }
+ }
+}
diff --git a/src/Games/Makefile.am b/src/Games/Makefile.am
index ca3b46f..1bffb12 100644
--- a/src/Games/Makefile.am
+++ b/src/Games/Makefile.am
@@ -47,6 +47,7 @@ CSFILES = \
Logic/PuzzleTimeNow.cs \
Logic/PuzzleTriangles.cs \
Logic/PuzzleTrianglesWithNumbers.cs \
+ Logic/PuzzlePredicateLogic.cs \
Memory/MemoryColouredFigures.cs \
Memory/MemoryColouredText.cs \
Memory/MemoryCountDots.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]