mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
fix bug summarizing score for one-tile moves; remove return from
middle of function.
This commit is contained in:
parent
cddb31c22d
commit
969d69f3ae
1 changed files with 97 additions and 88 deletions
|
@ -489,11 +489,19 @@ figureMoveScore( ModelCtxt* model, MoveInfo* moveInfo, EngineCtxt* engine,
|
||||||
|
|
||||||
for ( i = 0, tiles = moveInfo->tiles; i < nTiles; ++i, ++tiles ) {
|
for ( i = 0, tiles = moveInfo->tiles; i < nTiles; ++i, ++tiles ) {
|
||||||
|
|
||||||
|
/* Moves using only one tile will sometimes score only in the
|
||||||
|
crosscheck direction. Score may still be 0 after the call to
|
||||||
|
scoreWord above. Keep trying to get some text in mainWord until
|
||||||
|
something's been scored. */
|
||||||
|
if ( score > 0 ) {
|
||||||
|
mainWord = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
tmpMI.commonCoord = tiles->varCoord;
|
tmpMI.commonCoord = tiles->varCoord;
|
||||||
tmpMI.tiles[0].tile = tiles->tile;
|
tmpMI.tiles[0].tile = tiles->tile;
|
||||||
|
|
||||||
oneScore = scoreWord( model, &tmpMI, engine, stream, silent,
|
oneScore = scoreWord( model, &tmpMI, engine, stream, silent,
|
||||||
notifyInfo, NULL );
|
notifyInfo, mainWord );
|
||||||
if ( !!stream ) {
|
if ( !!stream ) {
|
||||||
formatWordScore( stream, oneScore, multipliers[i] );
|
formatWordScore( stream, oneScore, multipliers[i] );
|
||||||
}
|
}
|
||||||
|
@ -557,7 +565,8 @@ scoreWord( ModelCtxt* model, MoveInfo* movei, /* new tiles */
|
||||||
XP_UCHAR* mainWord )
|
XP_UCHAR* mainWord )
|
||||||
{
|
{
|
||||||
XP_U16 tileMultiplier;
|
XP_U16 tileMultiplier;
|
||||||
XP_U16 restScore, scoreFromCache;
|
XP_U16 restScore = 0;
|
||||||
|
XP_U16 scoreFromCache;
|
||||||
XP_U16 thisTileValue;
|
XP_U16 thisTileValue;
|
||||||
XP_U16 nTiles = movei->nTiles;
|
XP_U16 nTiles = movei->nTiles;
|
||||||
Tile tile;
|
Tile tile;
|
||||||
|
@ -567,11 +576,6 @@ scoreWord( ModelCtxt* model, MoveInfo* movei, /* new tiles */
|
||||||
MoveInfoTile* tiles = movei->tiles;
|
MoveInfoTile* tiles = movei->tiles;
|
||||||
XP_U16 firstCoord = tiles->varCoord;
|
XP_U16 firstCoord = tiles->varCoord;
|
||||||
DictionaryCtxt* dict = model->vol.dict;
|
DictionaryCtxt* dict = model->vol.dict;
|
||||||
WordScoreFormatter fmtr;
|
|
||||||
|
|
||||||
if ( !!stream || !!mainWord ) {
|
|
||||||
wordScoreFormatterInit( &fmtr, dict );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( movei->isHorizontal ) {
|
if ( movei->isHorizontal ) {
|
||||||
row = movei->commonCoord;
|
row = movei->commonCoord;
|
||||||
|
@ -588,8 +592,10 @@ scoreWord( ModelCtxt* model, MoveInfo* movei, /* new tiles */
|
||||||
*incr = tiles[0].varCoord;
|
*incr = tiles[0].varCoord;
|
||||||
start = find_start( model, col, row, movei->isHorizontal );
|
start = find_start( model, col, row, movei->isHorizontal );
|
||||||
|
|
||||||
if ( (end - start) < 1 ) { /* one-letter word: score 0 */
|
if ( (end - start) >= 1 ) { /* one-letter word: score 0 */
|
||||||
return 0;
|
WordScoreFormatter fmtr;
|
||||||
|
if ( !!stream || !!mainWord ) {
|
||||||
|
wordScoreFormatterInit( &fmtr, dict );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IS_BLANK(tiles->tile) ) {
|
if ( IS_BLANK(tiles->tile) ) {
|
||||||
|
@ -620,7 +626,6 @@ scoreWord( ModelCtxt* model, MoveInfo* movei, /* new tiles */
|
||||||
Tile checkWordBuf[MAX_ROWS];
|
Tile checkWordBuf[MAX_ROWS];
|
||||||
Tile* curTile = checkWordBuf;
|
Tile* curTile = checkWordBuf;
|
||||||
|
|
||||||
restScore = 0;
|
|
||||||
for ( *incr = start; *incr <= end; ++*incr ) {
|
for ( *incr = start; *incr <= end; ++*incr ) {
|
||||||
XP_U16 tileScore = 0;
|
XP_U16 tileScore = 0;
|
||||||
XP_Bool isBlank;
|
XP_Bool isBlank;
|
||||||
|
@ -677,7 +682,8 @@ scoreWord( ModelCtxt* model, MoveInfo* movei, /* new tiles */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !!stream || !!mainWord ) {
|
if ( !!stream || !!mainWord ) {
|
||||||
wordScoreFormatterFinish( &fmtr, checkWordBuf, stream, mainWord );
|
wordScoreFormatterFinish( &fmtr, checkWordBuf, stream,
|
||||||
|
mainWord );
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
@ -691,7 +697,10 @@ scoreWord( ModelCtxt* model, MoveInfo* movei, /* new tiles */
|
||||||
restScore = engine_getScoreCache( engine, movei->commonCoord );
|
restScore = engine_getScoreCache( engine, movei->commonCoord );
|
||||||
}
|
}
|
||||||
|
|
||||||
return (restScore + thisTileValue);
|
restScore += thisTileValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return restScore;
|
||||||
} /* scoreWord */
|
} /* scoreWord */
|
||||||
|
|
||||||
static XP_U16
|
static XP_U16
|
||||||
|
|
Loading…
Add table
Reference in a new issue