Fix bug reported by user: if robot finishes a search but fails to find

a move it's still done with its turn and must trade or pass.
This commit is contained in:
Andy2 2010-08-24 18:38:12 -07:00
parent 38ed6e4054
commit 3dba8ba13b
2 changed files with 11 additions and 9 deletions

View file

@ -513,11 +513,13 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
result = XP_FALSE; result = XP_FALSE;
} else { } else {
PossibleMove* move; PossibleMove* move;
result = chooseMove( engine, &move ); if ( chooseMove( engine, &move ) ) {
if ( result ) {
XP_ASSERT( !!newMove ); XP_ASSERT( !!newMove );
XP_MEMCPY( newMove, &move->moveInfo, sizeof(*newMove) ); XP_MEMCPY( newMove, &move->moveInfo, sizeof(*newMove) );
} else {
newMove->nTiles = 0;
} }
result = XP_TRUE;
} }
util_engineStopping( engine->util ); util_engineStopping( engine->util );

View file

@ -642,7 +642,7 @@ static XP_Bool
makeRobotMove( ServerCtxt* server ) makeRobotMove( ServerCtxt* server )
{ {
XP_Bool result = XP_FALSE; XP_Bool result = XP_FALSE;
XP_Bool finished; XP_Bool searchComplete;
XP_S16 turn; XP_S16 turn;
const TrayTileSet* tileSet; const TrayTileSet* tileSet;
MoveInfo newMove; MoveInfo newMove;
@ -674,14 +674,14 @@ makeRobotMove( ServerCtxt* server )
} }
XP_ASSERT( !!server_getEngineFor( server, turn ) ); XP_ASSERT( !!server_getEngineFor( server, turn ) );
finished = engine_findMove( server_getEngineFor( server, turn ), searchComplete = engine_findMove( server_getEngineFor( server, turn ),
model, model_getDictionary( model ), model, model_getDictionary( model ),
tileSet->tiles, tileSet->nTiles, XP_FALSE, tileSet->tiles, tileSet->nTiles, XP_FALSE,
#ifdef XWFEATURE_SEARCHLIMIT #ifdef XWFEATURE_SEARCHLIMIT
NULL, XP_FALSE, NULL, XP_FALSE,
#endif #endif
targetScore, &canMove, &newMove ); targetScore, &canMove, &newMove );
if ( finished ) { if ( searchComplete ) {
const XP_UCHAR* str; const XP_UCHAR* str;
XWStreamCtxt* stream = NULL; XWStreamCtxt* stream = NULL;