- add comments and emacs mode

This commit is contained in:
Antoine Fraboulet 2006-01-01 19:49:35 +00:00
parent 55badf52e4
commit 4665fa176b
32 changed files with 244 additions and 76 deletions

View file

@ -65,3 +65,9 @@ vector<Tile> AIPercent::getChangedLetters() const
return vector<Tile>(); return vector<Tile>();
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -62,3 +62,9 @@ private:
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -89,3 +89,9 @@ protected:
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -136,3 +136,10 @@ void Bag::dumpAll() const
} }
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -73,3 +73,10 @@ private:
}; };
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -473,3 +473,9 @@ void Board::checkDouble()
} }
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -90,31 +90,27 @@ public:
void removeRound(const Dictionary &iDic, const Round &iRound); void removeRound(const Dictionary &iDic, const Round &iRound);
int checkRound(Round &iRound, bool iFirstTurn); int checkRound(Round &iRound, bool iFirstTurn);
/************************* /**
* *
* */
*************************/
void testRound(const Round &iRound); void testRound(const Round &iRound);
void removeTestRound(); void removeTestRound();
char getTestChar(int iRow, int iCol) const; char getTestChar(int iRow, int iCol) const;
/************************* /**
*
* board_search.c * board_search.c
*************************/ */
void search(const Dictionary &iDic, const Rack &iRack, Results &oResults); void search(const Dictionary &iDic, const Rack &iRack, Results &oResults);
void searchFirst(const Dictionary &iDic, const Rack &iRack, Results &oResults); void searchFirst(const Dictionary &iDic, const Rack &iRack, Results &oResults);
/************************* /**
*
* board_cross.c * board_cross.c
*************************/ */
void buildCross(const Dictionary &iDic); void buildCross(const Dictionary &iDic);
/************************* /**
* *
* */
*************************/
int getWordMultiplier(int iRow, int iCol) const; int getWordMultiplier(int iRow, int iCol) const;
int getLetterMultiplier(int iRow, int iCol) const; int getLetterMultiplier(int iRow, int iCol) const;
@ -150,3 +146,10 @@ private:
}; };
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -19,7 +19,7 @@
/** /**
* \file coord.cpp * \file coord.cpp
* \brief Eliot coordinate system * \brief Board coordinate system
* \author Antoine Fraboulet * \author Antoine Fraboulet
* \date 2005 * \date 2005
*/ */
@ -85,26 +85,39 @@ void Coord::setFromString(const string &iStr)
setRow(row); setRow(row);
} }
string Coord::toString() const string Coord::toString(coord_mode_t mode) const
{ {
ASSERT(isValid(), "Invalid coordinates"); ASSERT(isValid(), "Invalid coordinates");
string res; char res[7];
char s[5]; char srow[3];
sprintf(s, "%d", m_col); char scol[3];
sprintf(scol, "%d", m_col);
sprintf(srow, "%c", m_row + 'A' - 1);
switch (mode)
{
case COORD_MODE_COMPACT:
if (getDir() == HORIZONTAL) if (getDir() == HORIZONTAL)
{ sprintf(res,"%s%s",srow,scol);
res = string(1, m_row + 'A' - 1) + s;
}
else else
{ sprintf(res,"%s%s",scol,srow);
res = s + string(1, m_row + 'A' - 1); break;
case COORD_MODE_LONG:
if (getDir() == HORIZONTAL)
sprintf(res,"%2s %2s",srow,scol);
else
sprintf(res,"%2s %2s",scol,srow);
break;
} }
return res;
return string(res);
} }
/// Local Variables: /// Local Variables:
/// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -19,7 +19,7 @@
/** /**
* \file coord.h * \file coord.h
* \brief Game coordinates system * \brief Board coordinates system
* \author Antoine Fraboulet * \author Antoine Fraboulet
* \date 2005 * \date 2005
*/ */
@ -55,7 +55,12 @@ public:
void swap(); void swap();
void setFromString(const string &iStr); void setFromString(const string &iStr);
string toString() const;
typedef enum {
COORD_MODE_COMPACT,
COORD_MODE_LONG
} coord_mode_t;
string toString(coord_mode_t mode = COORD_MODE_COMPACT) const;
private: private:
Direction m_dir; Direction m_dir;
@ -65,8 +70,9 @@ private:
#endif #endif
/// Local Variables: /// Local Variables:
/// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -62,3 +62,10 @@ bool Cross::operator==(const Cross &iOther) const
else else
return false; return false;
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -57,3 +57,10 @@ private:
}; };
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -48,3 +48,10 @@
#endif #endif
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -284,3 +284,9 @@ void Duplicate::nextHumanPlayer()
m_hasPlayed[m_currPlayer]); m_hasPlayed[m_currPlayer]);
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -82,3 +82,10 @@ private:
}; };
#endif /* _DUPLICATE_H_ */ #endif /* _DUPLICATE_H_ */
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -254,3 +254,9 @@ int FreeGame::helperPass(const vector<Tile> &iToChange, int n)
return 0; return 0;
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -64,3 +64,10 @@ private:
}; };
#endif /* _FREEGAME_H_ */ #endif /* _FREEGAME_H_ */
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -214,3 +214,10 @@ void GameFactory::printVersion() const
<< "Public License;\nsee the file named COPYING for details.\n"; << "Public License;\nsee the file named COPYING for details.\n";
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -93,3 +93,10 @@ private:
}; };
#endif // _GAME_FACTORY_H_ #endif // _GAME_FACTORY_H_
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -39,7 +39,7 @@
History::History() History::History()
{ {
Turn* t = new Turn(); Turn* t = new Turn ();
m_history.clear(); m_history.clear();
m_history.push_back(t); m_history.push_back(t);
} }
@ -143,7 +143,7 @@ void History::removeLastTurn()
delete t; delete t;
} }
// Now we have the previous played round in back() // now we have the previous played round in back()
Turn* t = m_history.back(); Turn* t = m_history.back();
t->setNum(0); t->setNum(0);
t->setPlayer(0); t->setPlayer(0);
@ -160,13 +160,13 @@ string History::toString() const
string rs = ""; string rs = "";
#ifdef DEBUG #ifdef DEBUG
char buff[20]; char buff[20];
sprintf(buff, "%ld", m_history.size()); sprintf(buff,"%d",m_history.size());
rs = "history size = " + string(buff) + "\n\n"; rs = "history size = " + string(buff) + "\n\n";
#endif #endif
for (i = 0; i < m_history.size(); i++) for (i = 0; i < m_history.size(); i++)
{ {
Turn *t = m_history[i]; Turn *t = m_history[i];
rs += t->toString() + "\n"; rs += t->toString() + string("\n");
} }
return rs; return rs;
} }
@ -177,6 +177,8 @@ string History::toString() const
/// Local Variables: /// Local Variables:
/// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -27,16 +27,10 @@
#ifndef _HISTORY_H #ifndef _HISTORY_H
#define _HISTORY_H #define _HISTORY_H
#include <string>
#include <vector> #include <vector>
#include "pldrack.h"
using std::string; #include "round.h"
using std::vector; #include "turn.h"
class Round;
class Turn;
class PlayedRack;
/** /**
* History stores all the turns that have been played * History stores all the turns that have been played
@ -61,7 +55,7 @@ class PlayedRack;
class History class History
{ {
public: public:
History(); History();
virtual ~History(); virtual ~History();
@ -90,15 +84,15 @@ public:
/// String handling /// String handling
string toString() const; string toString() const;
private: private:
vector<Turn*> m_history; vector < Turn* > m_history;
}; };
#endif #endif
/// Local Variables: /// Local Variables:
/// mode: c++ /// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -97,4 +97,5 @@ const string Player::toString() const
/// mode: c++ /// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -69,7 +69,7 @@ public:
// A new rack is created with the remaining letters // A new rack is created with the remaining letters
void endTurn(const Round &iRound, int iTurn); void endTurn(const Round &iRound, int iTurn);
const std::string toString() const; const string toString() const;
private: private:
/// ID of the player /// ID of the player
@ -89,6 +89,8 @@ private:
class HumanPlayer: public Player class HumanPlayer: public Player
{ {
public: public:
string name;
HumanPlayer(int iId): Player(iId) {} HumanPlayer(int iId): Player(iId) {}
virtual ~HumanPlayer() {} virtual ~HumanPlayer() {}
@ -98,3 +100,9 @@ public:
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -84,4 +84,5 @@ void Results::sort_by_points()
/// mode: c++ /// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -76,4 +76,5 @@ private:
/// mode: c++ /// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -144,7 +144,7 @@ void Round::removeRightToRack(Tile c, bool iJoker)
string Round::getWord() const string Round::getWord() const
{ {
char c; char c;
std::string s; string s;
for (int i = 0; i < getWordLen(); i++) for (int i = 0; i < getWordLen(); i++)
{ {
@ -175,6 +175,8 @@ string Round::toString() const
} }
/// Local Variables: /// Local Variables:
/// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -82,7 +82,7 @@ public:
const Coord& getCoord() const { return m_coord; } const Coord& getCoord() const { return m_coord; }
Coord& accessCoord() { return m_coord; } Coord& accessCoord() { return m_coord; }
std::string toString() const; string toString() const;
private: private:
vector<Tile> m_word; vector<Tile> m_word;
@ -93,3 +93,10 @@ private:
}; };
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -209,3 +209,9 @@ bool Tile::operator !=(const Tile &iOther) const
return !(*this == iOther); return !(*this == iOther);
} }
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -73,3 +73,10 @@ private:
}; };
#endif #endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -38,14 +38,20 @@ Training::~Training()
{ {
} }
int Training::setRackRandom(int p, bool iCheck, set_rack_mode mode)
int Training::setRackRandom(bool iCheck, set_rack_mode mode)
{ {
#define MAX_RANDOM_TRY 5
int res; int res;
int try_number = 0;
int p = m_currPlayer;
m_results.clear(); m_results.clear();
do do
{ {
res = helperSetRackRandom(p, iCheck, mode); res = helperSetRackRandom(p, iCheck, mode);
} while (res == 2); try_number ++;
} while (res == 2 && try_number < MAX_RANDOM_TRY);
// 0 : ok // 0 : ok
// 1 : not enough tiles // 1 : not enough tiles
// 2 : check failed (number of voyels before round 15) // 2 : check failed (number of voyels before round 15)
@ -83,10 +89,10 @@ int Training::setRack(set_rack_mode iMode, bool iCheck, const string &iLetters)
res = setRackManual(iCheck, iLetters); res = setRackManual(iCheck, iLetters);
break; break;
case RACK_ALL: case RACK_ALL:
res = setRackRandom(m_currPlayer, iCheck, iMode); res = setRackRandom(iCheck, iMode);
break; break;
case RACK_NEW: case RACK_NEW:
res = setRackRandom(m_currPlayer, iCheck, iMode); res = setRackRandom(iCheck, iMode);
break; break;
} }
return res; return res;
@ -128,6 +134,7 @@ int Training::start()
return 0; return 0;
} }
int Training::endTurn() int Training::endTurn()
{ {
// Nothing to do? // Nothing to do?
@ -140,7 +147,7 @@ void Training::search()
// Search for the current player // Search for the current player
Rack r; Rack r;
m_players[m_currPlayer]->getCurrentRack().getRack(r); m_players[m_currPlayer]->getCurrentRack().getRack(r);
// debug("Training::search for %s\n",r.toString().c_str()); debug("Training::search for %s\n",r.toString().c_str());
m_results.search(*m_dic, m_board, r, m_history.getSize()); m_results.search(*m_dic, m_board, r, m_history.getSize());
} }
@ -209,4 +216,5 @@ std::string Training::getTestPlayWord() const
/// mode: c++ /// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -52,7 +52,7 @@ public:
void search(); void search();
int playResult(int); int playResult(int);
virtual int setRackRandom(int, bool, set_rack_mode); int setRackRandom(bool, set_rack_mode);
int setRackManual(bool iCheck, const string &iLetters); int setRackManual(bool iCheck, const string &iLetters);
int setRack(set_rack_mode iMode, bool iCheck, const string &iLetters); int setRack(set_rack_mode iMode, bool iCheck, const string &iLetters);
@ -87,3 +87,10 @@ private:
}; };
#endif /* _TRAINING_H_ */ #endif /* _TRAINING_H_ */
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -48,6 +48,7 @@ Turn::Turn(int iNum, int iPlayerId,
void Turn::operator=(const Turn &iOther) void Turn::operator=(const Turn &iOther)
{ {
m_num = iOther.m_num; m_num = iOther.m_num;
m_playerId = iOther.m_playerId;
m_pldrack = iOther.m_pldrack; m_pldrack = iOther.m_pldrack;
m_round = iOther.m_round; m_round = iOther.m_round;
} }
@ -64,8 +65,9 @@ string Turn::toString(bool iShowExtraSigns) const
return rs; return rs;
} }
/// Local Variables: /// Local Variables:
/// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End:

View file

@ -60,8 +60,9 @@ private:
#endif #endif
/// Local Variables: /// Local Variables:
/// mode: c++
/// mode: hs-minor /// mode: hs-minor
/// c-basic-offset: 4 /// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End: /// End: