mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
- 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
This commit is contained in:
parent
2c262bcc34
commit
fea2ba6068
1 changed files with 33 additions and 12 deletions
|
@ -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 @@ static void Board_checkout_tile(const Dictionary &iDic,
|
|||
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 @@ static void Board_checkout_tile(const Dictionary &iDic,
|
|||
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 @@ static void Board_check(const Dictionary &iDic,
|
|||
{
|
||||
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 @@ static void Board_check(const Dictionary &iDic,
|
|||
j);
|
||||
}
|
||||
else
|
||||
{
|
||||
iCrossMx[j][i].setAny();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,3 +128,14 @@ void Board::buildCross(const Dictionary &iDic)
|
|||
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:
|
||||
|
|
Loading…
Reference in a new issue