示例#1
0
static void game_update(game_t * game) {

   ASSERT(game!=NULL);

   game->status = game_comp_status(game);

   ASSERT(game_is_ok(game));
}
示例#2
0
bool game_is_ok(const game_t * game) {

   board_t board[1];
   int pos, move;

   if (game == NULL) return false;

   if (game->size < 0 || game->size > GameSize) return false;
   if (game->pos < 0 || game->pos > game->size) return false;

   // optional heavy DEBUG mode

   if (!UseSlowDebug) return true;

   if (!board_is_ok(game->start_board)) return false;

   board_copy(board,game->start_board);

   for (pos = 0; pos <= game->size; pos++) {

      if (pos == game->pos) {
         if (!board_equal(game->board,board)) return false;
      }

      if (pos >= game->size) break;

      if (game->key[pos] != board->key) return false;

      move = game->move[pos];
      if (!move_is_legal(move,board))
          ;

      move_do(board,move);
   }

   if (game->status != game_comp_status(game)) return false;

   return true;
}