eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot/game results.cpp round.h


From: Olivier Teulière
Subject: [Eliot-dev] eliot/game results.cpp round.h
Date: Fri, 03 Jul 2009 23:00:13 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>       09/07/03 23:00:13

Modified files:
        game           : results.cpp round.h 

Log message:
        Sort the training results using the dictionary order as alphabetical 
order

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/results.cpp?cvsroot=eliot&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/eliot/game/round.h?cvsroot=eliot&r1=1.14&r2=1.15

Patches:
Index: results.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/results.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- results.cpp 24 Jan 2009 17:44:57 -0000      1.18
+++ results.cpp 3 Jul 2009 23:00:12 -0000       1.19
@@ -32,9 +32,9 @@
 #include "debug.h"
 
 
-bool wcharCompare(wchar_t c1, wchar_t c2)
+bool tileCompare(const Tile &t1, const Tile &t2)
 {
-    return towlower(c1) < towlower(c2);
+    return t1.toCode() < t2.toCode();
 }
 
 struct less_points : public binary_function<const Round&, const Round&, bool>
@@ -48,23 +48,23 @@
             return false;
         else
         {
-            // If the scores are equal, sort alphabetically, ignoring
-            // the case
+            // If the scores are equal, sort alphabetically (i.e. in the
+            // order of the letters in the dictionary), ignoring the case
             const wstring &s1 = r1.getWord();
             const wstring &s2 = r2.getWord();
-            if (std::lexicographical_compare(s1.begin(),
-                                             s1.end(),
-                                             s2.begin(),
-                                             s2.end(),
-                                             wcharCompare))
+            if (std::lexicographical_compare(r1.getTiles().begin(),
+                                             r1.getTiles().end(),
+                                             r2.getTiles().begin(),
+                                             r2.getTiles().end(),
+                                             tileCompare))
             {
                 return true;;
             }
-            else if (std::lexicographical_compare(s2.begin(),
-                                                  s2.end(),
-                                                  s1.begin(),
-                                                  s1.end(),
-                                                  wcharCompare))
+            else if (std::lexicographical_compare(r2.getTiles().begin(),
+                                                  r2.getTiles().end(),
+                                                  r1.getTiles().begin(),
+                                                  r1.getTiles().end(),
+                                                  tileCompare))
             {
                 return false;
             }

Index: round.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/round.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- round.h     22 Nov 2008 13:09:31 -0000      1.14
+++ round.h     3 Jul 2009 23:00:13 -0000       1.15
@@ -75,6 +75,7 @@
     unsigned int getWordLen() const { return m_word.size(); }
     int getPoints() const           { return m_points; }
     int getBonus()  const           { return m_bonus; }
+    const vector<Tile> &getTiles() const { return m_word; }
 
     /*************************
      * Coordinates




reply via email to

[Prev in Thread] Current Thread [Next in Thread]