eliot-dev
[Top][All Lists]
Advanced

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

[Eliot-dev] eliot/game board_cross.cpp


From: eliot-dev
Subject: [Eliot-dev] eliot/game board_cross.cpp
Date: Sun, 01 Jan 2006 19:37:26 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Branch:         
Changes by:     Antoine Fraboulet <address@hidden>      06/01/01 19:37:26

Modified files:
        game           : board_cross.cpp 

Log message:
        - correct off by one in score, once again. index+1 is right !
        - revert previous dic_chr patch. make dic_char instead.
        The board should/will use codes instead of tiles for performance reasons
        in the next version

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/board_cross.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: eliot/game/board_cross.cpp
diff -u eliot/game/board_cross.cpp:1.5 eliot/game/board_cross.cpp:1.6
--- eliot/game/board_cross.cpp:1.5      Sat Dec 24 18:42:44 2005
+++ eliot/game/board_cross.cpp  Sun Jan  1 19:37:26 2006
@@ -18,13 +18,18 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *****************************************************************************/
 
+/**
+ *  \file   board_cross.cpp
+ *  \brief  Build cross information used to speed up search
+ *  \author Antoine Fraboulet & Olivier Teulière
+ *  \date   2005
+ */
+
 #include <dic.h>
 #include "tile.h"
 #include "board.h"
-
 #include "debug.h"
 
-
 static void Board_checkout_tile(const Dictionary &iDic,
                                 vector<Tile>& iTiles,
                                 vector<bool> & iJoker,
@@ -52,7 +57,7 @@
     for (j = i; j < index; j++)
         leftTiles[j - i] = toupper(iTiles[j].toChar());
     leftTiles[index - i] = 0;
-    node = Dic_lookup(iDic, Dic_root(iDic), leftTiles);
+    node = Dic_char_lookup(iDic, Dic_root(iDic), leftTiles);
     if (node == 0)
     {
         oCross.clear();
@@ -66,19 +71,20 @@
     rightTiles[j - index - 1] = 0;
     for (succ = Dic_succ(iDic, node); succ; succ = Dic_next(iDic, succ))
     {
-        if (Dic_word(iDic, Dic_lookup(iDic, succ, rightTiles)))
-            oCross.insert(Tile(Dic_chr(iDic, succ)));
+        if (Dic_word(iDic, Dic_char_lookup(iDic, succ, rightTiles)))
+            oCross.insert(Tile(Dic_char(iDic, succ)));
         if (Dic_last(iDic, succ))
             break;
     }
 
-     /* Points on the right part */
-     while (!iTiles[index].isEmpty())
-     {
-         index++;
-         if (!iJoker[index])
-             oPoints += iTiles[index].getPoints();
-     }
+    /* Points on the right part */
+    /* yes, it is REALLY [index+1] */
+    while (!iTiles[index+1].isEmpty())
+    {
+       index++;
+       if (!iJoker[index])
+           oPoints += iTiles[index].getPoints();
+    }
 }
 
 
@@ -94,7 +100,9 @@
         {
             iPointMx[j][i] = -1;
             if (!iTilesMx[i][j].isEmpty())
+            {
                 iCrossMx[j][i].clear();
+           }
             else if (!iTilesMx[i][j - 1].isEmpty() ||
                      !iTilesMx[i][j + 1].isEmpty())
             {
@@ -107,7 +115,9 @@
                                     j);
             }
             else
+            {
                 iCrossMx[j][i].setAny();
+           }
         }
     }
 }
@@ -118,3 +128,14 @@
     Board_check(iDic, m_tilesRow, m_jokerRow, m_crossCol, m_pointCol);
     Board_check(iDic, m_tilesCol, m_jokerCol, m_crossRow, m_pointRow);
 }
+
+
+/****************************************************************/
+/****************************************************************/
+
+/// Local Variables:
+/// mode: c++
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// indent-tabs-mode: nil
+/// End:




reply via email to

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