- 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>();
}
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -62,3 +62,9 @@ private:
#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
/// 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");
}
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -73,3 +73,10 @@ private:
};
#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
/// 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);
int checkRound(Round &iRound, bool iFirstTurn);
/*************************
/**
*
*
*************************/
*/
void testRound(const Round &iRound);
void removeTestRound();
char getTestChar(int iRow, int iCol) const;
/*************************
*
/**
* board_search.c
*************************/
*/
void search(const Dictionary &iDic, const Rack &iRack, Results &oResults);
void searchFirst(const Dictionary &iDic, const Rack &iRack, Results &oResults);
/*************************
*
/**
* board_cross.c
*************************/
*/
void buildCross(const Dictionary &iDic);
/*************************
/**
*
*
*************************/
*/
int getWordMultiplier(int iRow, int iCol) const;
int getLetterMultiplier(int iRow, int iCol) const;
@ -150,3 +146,10 @@ private:
};
#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
* \brief Eliot coordinate system
* \brief Board coordinate system
* \author Antoine Fraboulet
* \date 2005
*/
@ -85,26 +85,39 @@ void Coord::setFromString(const string &iStr)
setRow(row);
}
string Coord::toString() const
string Coord::toString(coord_mode_t mode) const
{
ASSERT(isValid(), "Invalid coordinates");
string res;
char s[5];
sprintf(s, "%d", m_col);
if (getDir() == HORIZONTAL)
char res[7];
char srow[3];
char scol[3];
sprintf(scol, "%d", m_col);
sprintf(srow, "%c", m_row + 'A' - 1);
switch (mode)
{
res = string(1, m_row + 'A' - 1) + s;
case COORD_MODE_COMPACT:
if (getDir() == HORIZONTAL)
sprintf(res,"%s%s",srow,scol);
else
sprintf(res,"%s%s",scol,srow);
break;
case COORD_MODE_LONG:
if (getDir() == HORIZONTAL)
sprintf(res,"%2s %2s",srow,scol);
else
sprintf(res,"%2s %2s",scol,srow);
break;
}
else
{
res = s + string(1, m_row + 'A' - 1);
}
return res;
return string(res);
}
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -19,7 +19,7 @@
/**
* \file coord.h
* \brief Game coordinates system
* \brief Board coordinates system
* \author Antoine Fraboulet
* \date 2005
*/
@ -55,7 +55,12 @@ public:
void swap();
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:
Direction m_dir;
@ -65,8 +70,9 @@ private:
#endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -62,3 +62,10 @@ bool Cross::operator==(const Cross &iOther) const
else
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
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

@ -48,3 +48,10 @@
#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]);
}
/// 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_ */
/// 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;
}
/// 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_ */
/// 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";
}
/// 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_
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

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

View file

@ -27,16 +27,10 @@
#ifndef _HISTORY_H
#define _HISTORY_H
#include <string>
#include <vector>
using std::string;
using std::vector;
class Round;
class Turn;
class PlayedRack;
#include "pldrack.h"
#include "round.h"
#include "turn.h"
/**
* History stores all the turns that have been played
@ -45,23 +39,23 @@ class PlayedRack;
* - one for each of the players
*
* A History is never void (getSize() can be used as the is the current turn
* number for the complete game history).
* number for the complete game history).
*
* History starts at zero.
*
* The top of the history is an empty
* Turn until it has been filled and game is up to a new round.
*
* getCurrentRack() can/should be used to store the current played rack.
*
* getCurrentRack() can/should be used to store the current played rack.
* setCurrentRack must be called whenever the current played rack is
* modified.
*
*
* History owns the turns that it stores. Do not delete a turn referenced by History
*/
class History
{
public:
public:
History();
virtual ~History();
@ -90,15 +84,15 @@ public:
/// String handling
string toString() const;
private:
vector<Turn*> m_history;
private:
vector < Turn* > m_history;
};
#endif
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -73,3 +73,10 @@ private:
};
#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 try_number = 0;
int p = m_currPlayer;
m_results.clear();
do
{
res = helperSetRackRandom(p, iCheck, mode);
} while (res == 2);
try_number ++;
} while (res == 2 && try_number < MAX_RANDOM_TRY);
// 0 : ok
// 1 : not enough tiles
// 2 : check failed (number of voyels before round 15)
@ -64,9 +70,9 @@ int Training::setRackManual(bool iCheck, const string &iLetters)
m_results.clear();
uLetters = iLetters;
for(it = uLetters.begin(); it != uLetters.end(); it ++)
{
*it = toupper(*it);
}
{
*it = toupper(*it);
}
res = helperSetRackManual(p, iCheck, uLetters);
// 0 : ok
// 1 : not enough tiles
@ -78,17 +84,17 @@ int Training::setRack(set_rack_mode iMode, bool iCheck, const string &iLetters)
{
int res = 0;
switch(iMode)
{
case RACK_MANUAL:
res = setRackManual(iCheck, iLetters);
break;
case RACK_ALL:
res = setRackRandom(m_currPlayer, iCheck, iMode);
break;
case RACK_NEW:
res = setRackRandom(m_currPlayer, iCheck, iMode);
break;
}
{
case RACK_MANUAL:
res = setRackManual(iCheck, iLetters);
break;
case RACK_ALL:
res = setRackRandom(iCheck, iMode);
break;
case RACK_NEW:
res = setRackRandom(iCheck, iMode);
break;
}
return res;
}
@ -128,6 +134,7 @@ int Training::start()
return 0;
}
int Training::endTurn()
{
// Nothing to do?
@ -140,7 +147,7 @@ void Training::search()
// Search for the current player
Rack 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());
}
@ -209,4 +216,5 @@ std::string Training::getTestPlayWord() const
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// indent-tabs-mode: nil
/// End:

View file

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

View file

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

View file

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