- extra debug output command for board cross info

This commit is contained in:
Antoine Fraboulet 2006-11-05 13:27:49 +00:00
parent aeb3cdb781
commit 70041c80b3
3 changed files with 72 additions and 1 deletions

View file

@ -188,8 +188,10 @@ void help_training()
printf(" gj -- grille + jokers\n"); printf(" gj -- grille + jokers\n");
printf(" gm -- grille + valeur des cases\n"); printf(" gm -- grille + valeur des cases\n");
printf(" gn -- grille + valeur des cases (variante)\n"); printf(" gn -- grille + valeur des cases (variante)\n");
printf(" gd -- grille + debug cross (debug only)\n");
printf(" l -- lettres non jouées\n"); printf(" l -- lettres non jouées\n");
printf(" p -- partie\n"); printf(" p -- partie\n");
printf(" pd -- partie (debug)\n");
printf(" P -- partie (format standard)\n"); printf(" P -- partie (format standard)\n");
printf(" r -- recherche\n"); printf(" r -- recherche\n");
printf(" s -- score\n"); printf(" s -- score\n");
@ -292,6 +294,9 @@ void display_data(const Game &iGame, const wchar_t *delim, wchar_t **state)
case L'\0': case L'\0':
GameIO::printBoard(cout, iGame); GameIO::printBoard(cout, iGame);
break; break;
case L'd':
GameIO::printBoardDebug(cout, iGame);
break;
case L'j': case L'j':
GameIO::printBoardJoker(cout, iGame); GameIO::printBoardJoker(cout, iGame);
break; break;
@ -313,8 +318,18 @@ void display_data(const Game &iGame, const wchar_t *delim, wchar_t **state)
GameIO::printNonPlayed(cout, iGame); GameIO::printNonPlayed(cout, iGame);
break; break;
case L'p': case L'p':
switch (token[1])
{
case '\0':
iGame.save(cout,Game::FILE_FORMAT_ADVANCED); iGame.save(cout,Game::FILE_FORMAT_ADVANCED);
break; break;
case 'd':
GameIO::printGameDebug(cout, iGame);
break;
default:
printf("commande inconnue\n");
}
break;
case L'P': case L'P':
iGame.save(cout,Game::FILE_FORMAT_STANDARD); iGame.save(cout,Game::FILE_FORMAT_STANDARD);
break; break;
@ -419,7 +434,9 @@ void loop_training(Training &iGame)
{ {
int n = _wtoi(token); int n = _wtoi(token);
if (n <= 0) if (n <= 0)
{
iGame.back(n == 0 ? 1 : -n); iGame.back(n == 0 ? 1 : -n);
}
else else
{ {
if (iGame.playResult(--n)) if (iGame.playResult(--n))

View file

@ -51,6 +51,32 @@ void GameIO::printBoard(ostream &out, const Game &iGame)
} }
} }
/* this mode is used for regression tests */
void GameIO::printBoardDebug(ostream &out, const Game &iGame)
{
int row, col;
/* first printf row cell contents */
for (row = BOARD_MIN; row <= BOARD_MAX; row++)
{
out << " " << (char)(row - BOARD_MIN + 'A') << "r ";
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
out << iGame.getBoard().getCellContent_row(row, col);
}
out << endl;
}
out << " -" << endl;
for (row = BOARD_MIN; row <= BOARD_MAX; row++)
{
out << " " << (char)(row - BOARD_MIN + 'A') << "c ";
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
{
out << iGame.getBoard().getCellContent_col(row, col);
}
out << endl;
}
}
void GameIO::printBoardJoker(ostream &out, const Game &iGame) void GameIO::printBoardJoker(ostream &out, const Game &iGame)
{ {
@ -221,3 +247,27 @@ void GameIO::printAllPoints(ostream &out, const Game &iGame)
} }
} }
void GameIO::printGameDebug(ostream &out, const Game &iGame)
{
out << "Game:: joueur en cours " << iGame.currPlayer() << " sur " << iGame.getNPlayers() << endl;
out << "Game:: mode " << iGame.getModeAsString() << endl;
out << "Game:: variante ";
switch (iGame.getVariant())
{
case Game::kNONE:
out << "aucune" << endl;
break;
case Game::kJOKER:
out << "joker" << endl;
break;
default:
out << "inconnu" << endl;
break;
}
out << "Game:: rack size " << iGame.RACK_SIZE << endl;
out << "Game:: history --" << endl;
out << convertToMb(iGame.getHistory().toString());
out << "--" << endl;
out << "" << endl;
}

View file

@ -41,9 +41,11 @@ class GameIO
{ {
public: public:
static void printBoard(ostream &out, const Game &iGame); static void printBoard(ostream &out, const Game &iGame);
static void printBoardDebug(ostream &out, const Game &iGame);
static void printBoardJoker(ostream &out, const Game &iGame); static void printBoardJoker(ostream &out, const Game &iGame);
static void printBoardMultipliers(ostream &out, const Game &iGame); static void printBoardMultipliers(ostream &out, const Game &iGame);
static void printBoardMultipliers2(ostream &out, const Game &iGame); static void printBoardMultipliers2(ostream &out, const Game &iGame);
static void printNonPlayed(ostream &out, const Game &iGame); static void printNonPlayed(ostream &out, const Game &iGame);
static void printPlayedRack(ostream &out, const Game &iGame, int n); static void printPlayedRack(ostream &out, const Game &iGame, int n);
static void printAllRacks(ostream &out, const Game &iGame); static void printAllRacks(ostream &out, const Game &iGame);
@ -51,6 +53,8 @@ public:
static void printPoints(ostream &out, const Game &iGame); static void printPoints(ostream &out, const Game &iGame);
static void printAllPoints(ostream &out, const Game &iGame); static void printAllPoints(ostream &out, const Game &iGame);
static void printGameDebug(ostream &out, const Game &iGame);
private: private:
/// This class is a toolbox, and should not be instanciated /// This class is a toolbox, and should not be instanciated
GameIO(); GameIO();