[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot dic/dic_search.cpp game/duplicate.cpp gam... [cppdic]
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot dic/dic_search.cpp game/duplicate.cpp gam... [cppdic] |
Date: |
Tue, 04 Dec 2007 16:07:27 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Branch: cppdic
Changes by: Olivier Teulière <ipkiss> 07/12/04 16:07:26
Modified files:
dic : dic_search.cpp
game : duplicate.cpp freegame.cpp game.cpp game.h
training.cpp
test : .cvsignore driver
utils : eliottxt.cpp
Added files:
test : training_7pl1.input training_7pl1.ref
training_benj.input training_benj.ref
training_racc.input training_racc.ref
Log message:
- The dictionary cannot be changed in a Game object anymore
- Fixed DicSearch::searchBenj(): line order problem (same on HEAD, but
it is harmless there)
- Fixed DicSearch::search7pl1(): there were some leftovers from the
hard-coded letters...
- Text interface: Added support for the "benjamin", "raccords" and "7
+ 1" searches
- Added corresponding scenarii
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic_search.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.1.2.5&r2=1.1.2.6
http://cvs.savannah.gnu.org/viewcvs/eliot/game/duplicate.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.16&r2=1.16.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/game/freegame.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.18.2.1&r2=1.18.2.2
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.31.2.4&r2=1.31.2.5
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.h?cvsroot=eliot&only_with_tag=cppdic&r1=1.29.2.3&r2=1.29.2.4
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.17&r2=1.17.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/.cvsignore?cvsroot=eliot&only_with_tag=cppdic&r1=1.1&r2=1.1.6.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/driver?cvsroot=eliot&only_with_tag=cppdic&r1=1.5.2.1&r2=1.5.2.2
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_7pl1.input?cvsroot=eliot&only_with_tag=cppdic&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_7pl1.ref?cvsroot=eliot&only_with_tag=cppdic&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_benj.input?cvsroot=eliot&only_with_tag=cppdic&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_benj.ref?cvsroot=eliot&only_with_tag=cppdic&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_racc.input?cvsroot=eliot&only_with_tag=cppdic&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_racc.ref?cvsroot=eliot&only_with_tag=cppdic&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/eliottxt.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.16.2.8&r2=1.16.2.9
Patches:
Index: dic/dic_search.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/Attic/dic_search.cpp,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- dic/dic_search.cpp 4 Dec 2007 11:09:59 -0000 1.1.2.5
+++ dic/dic_search.cpp 4 Dec 2007 16:07:24 -0000 1.1.2.6
@@ -116,7 +116,7 @@
map<wchar_t, list<wstring> > *results;
int search_len;
wchar_t search_wordtst[DIC_WORD_MAX];
- wchar_t search_letters[DIC_LETTERS];
+ char search_letters[63];
};
template <typename DAWG_EDGE>
@@ -185,7 +185,7 @@
struct params_7plus1_t params;
- for (int i = 0; i < DIC_LETTERS; i++)
+ for (unsigned int i = 0; i < sizeof(params.search_letters); i++)
params.search_letters[i] = 0;
/*
@@ -235,7 +235,7 @@
params.search_len = wordlen;
params.search_wordtst[wordlen + 1] = L'\0';
const wstring &letters = iDic.getHeader().getLetters();
- for (unsigned int i = 0; i <= letters.size(); i++)
+ for (unsigned int i = 0; i < letters.size(); i++)
{
params.added_char = letters[i];
unsigned int code = iDic.getHeader().getCodeFromChar(letters[i]);
@@ -351,10 +351,12 @@
edge2 = reinterpret_cast<const
DAWG_EDGE*>(iDic.getEdgeAt(edge1->ptr));
do
{
- wordtst[2] = iDic.getHeader().getCharFromCode(edge2->chr);
edgetst = Dic_seek_edgeptr(iDic, iWord.c_str(), edge2);
if (edgetst->term)
+ {
+ wordtst[2] = iDic.getHeader().getCharFromCode(edge2->chr);
oWordList.push_back(wordtst);
+ }
} while (!(*edge2++).last);
} while (!(*edge1++).last);
} while (!(*edge0++).last);
Index: game/duplicate.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/duplicate.cpp,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -b -r1.16 -r1.16.2.1
--- game/duplicate.cpp 22 Jan 2006 12:23:53 -0000 1.16
+++ game/duplicate.cpp 4 Dec 2007 16:07:24 -0000 1.16.2.1
@@ -77,7 +77,7 @@
ASSERT(!m_players[n]->isHuman(), "AI requested for a human player");
AIPlayer *player = static_cast<AIPlayer*>(m_players[n]);
- player->compute(*m_dic, m_board, m_history.getSize());
+ player->compute(m_dic, m_board, m_history.getSize());
if (player->changesLetters())
{
Index: game/freegame.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/freegame.cpp,v
retrieving revision 1.18.2.1
retrieving revision 1.18.2.2
diff -u -b -r1.18.2.1 -r1.18.2.2
--- game/freegame.cpp 27 Nov 2007 18:01:06 -0000 1.18.2.1
+++ game/freegame.cpp 4 Dec 2007 16:07:25 -0000 1.18.2.2
@@ -86,7 +86,7 @@
AIPlayer *player = static_cast<AIPlayer*>(m_players[n]);
- player->compute(*m_dic, m_board, m_history.getSize());
+ player->compute(m_dic, m_board, m_history.getSize());
if (player->changesLetters())
{
helperPass(player->getChangedLetters(), n);
@@ -222,7 +222,7 @@
// It is forbidden to change letters when the bag does not contain at
// least 7 letters (this is explicitely stated in the ODS).
- Bag bag(*m_dic);
+ Bag bag(m_dic);
realBag(bag);
if (bag.nTiles() < 7)
{
Index: game/game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.cpp,v
retrieving revision 1.31.2.4
retrieving revision 1.31.2.5
diff -u -b -r1.31.2.4 -r1.31.2.5
--- game/game.cpp 27 Nov 2007 18:01:06 -0000 1.31.2.4
+++ game/game.cpp 4 Dec 2007 16:07:25 -0000 1.31.2.5
@@ -39,7 +39,7 @@
const int Game::BONUS_POINTS = 50;
Game::Game(const Dictionary &iDic):
- m_dic(&iDic), m_bag(iDic)
+ m_dic(iDic), m_bag(iDic)
{
m_variant = kNONE;
m_points = 0;
@@ -93,7 +93,7 @@
// Is the represented letter still available in the bag?
// FIXME: this way to get the represented letter sucks...
Tile t(towupper(iRound.getTile(i).toChar()));
- Bag bag(*m_dic);
+ Bag bag(m_dic);
realBag(bag);
// FIXME: realBag() does not give us a real bag in this
// particular case! This is because Player::endTurn() is called
@@ -147,7 +147,7 @@
}
}
}
- m_board.addRound(*m_dic, iRound);
+ m_board.addRound(m_dic, iRound);
return 0;
}
@@ -175,7 +175,7 @@
convertToMb(lastround.toString()).c_str());
/* Remove the word from the board, and put its letters back
* into the bag */
- m_board.removeRound(*m_dic, lastround);
+ m_board.removeRound(m_dic, lastround);
for (j = 0; j < lastround.getWordLen(); j++)
{
if (lastround.isPlayedFromRack(j))
@@ -252,7 +252,7 @@
// Create a copy of the bag in which we can do everything we want,
// and take from it the tiles of the players rack so that "bag"
// contains the right number of tiles.
- Bag bag(*m_dic);
+ Bag bag(m_dic);
realBag(bag);
if (mode == RACK_NEW && nold != 0)
@@ -403,7 +403,7 @@
*/
bool Game::rackInBag(const Rack &iRack, const Bag &iBag) const
{
- const vector<Tile>& allTiles = m_dic->getAllTiles();
+ const vector<Tile>& allTiles = m_dic.getAllTiles();
vector<Tile>::const_iterator it;
for (it = allTiles.begin(); it != allTiles.end(); it++)
{
@@ -537,7 +537,7 @@
}
/* Check the existence of the word */
- if (DicSearch::searchWord(*m_dic, iWord) == 0)
+ if (DicSearch::searchWord(m_dic, iWord) == 0)
{
return 3;
}
Index: game/game.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.h,v
retrieving revision 1.29.2.3
retrieving revision 1.29.2.4
diff -u -b -r1.29.2.3 -r1.29.2.4
--- game/game.h 11 Nov 2007 19:56:59 -0000 1.29.2.3
+++ game/game.h 4 Dec 2007 16:07:25 -0000 1.29.2.4
@@ -83,8 +83,7 @@
* Dictionary associated with the game.
* The dictionary can be changed during a game without problem
*/
- const Dictionary & getDic() const { return *m_dic; }
- void setDic(const Dictionary &iDic) { m_dic = &iDic; }
+ const Dictionary & getDic() const { return m_dic; }
const Board& getBoard() const { return m_board; }
const Bag& getBag() const { return m_bag; }
@@ -181,7 +180,7 @@
GameVariant m_variant;
/// Dictionary currently associated to the game
- const Dictionary * m_dic;
+ const Dictionary & m_dic;
/// Bag
Bag m_bag;
Index: game/training.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.cpp,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -b -r1.17 -r1.17.2.1
--- game/training.cpp 11 Aug 2006 22:15:13 -0000 1.17
+++ game/training.cpp 4 Dec 2007 16:07:25 -0000 1.17.2.1
@@ -159,7 +159,7 @@
Rack r;
m_players[m_currPlayer]->getCurrentRack().getRack(r);
debug("Training::search for %s\n", convertToMb(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());
}
Index: test/.cvsignore
===================================================================
RCS file: /cvsroot/eliot/eliot/test/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.1.6.1
diff -u -b -r1.1 -r1.1.6.1
--- test/.cvsignore 16 Apr 2005 15:47:59 -0000 1.1
+++ test/.cvsignore 4 Dec 2007 16:07:25 -0000 1.1.6.1
@@ -1 +1,2 @@
*.run
+load_saved_game.elt
Index: test/driver
===================================================================
RCS file: /cvsroot/eliot/eliot/test/driver,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -b -r1.5.2.1 -r1.5.2.2
--- test/driver 5 Nov 2006 17:27:03 -0000 1.5.2.1
+++ test/driver 4 Dec 2007 16:07:25 -0000 1.5.2.2
@@ -20,6 +20,12 @@
training_bag 0 # randseed unused
# Enter a rack, then display all the possibilities
training_search 0 # randseed unused
+# Display the benjamins for several words
+training_benj 0 # randseed unused
+# Display the "raccords" for several words
+training_racc 0 # randseed unused
+# Test the 7 + 1 feature
+training_7pl1 0 # randseed unused
# Several ways of getting a rack and playing a word
training_play 4
# Training rack+search+play+back
Index: utils/eliottxt.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/eliottxt.cpp,v
retrieving revision 1.16.2.8
retrieving revision 1.16.2.9
diff -u -b -r1.16.2.8 -r1.16.2.9
--- utils/eliottxt.cpp 30 Nov 2007 17:53:47 -0000 1.16.2.8
+++ utils/eliottxt.cpp 4 Dec 2007 16:07:26 -0000 1.16.2.9
@@ -220,6 +220,10 @@
printf(" S -- score de tous les joueurs\n");
printf(" t -- tirage\n");
printf(" d [] : vérifier le mot []\n");
+ printf(" b [b|p|r] [] : effectuer une recherche speciale à partir de
[]\n");
+ printf(" b -- benjamins\n");
+ printf(" p -- 7 + 1\n");
+ printf(" r -- raccords\n");
printf(" * : tirage aléatoire\n");
printf(" + : tirage aléatoire ajouts\n");
printf(" t [] : changer le tirage\n");
@@ -409,6 +413,58 @@
case L'a':
display_data(iGame, delim, &state);
break;
+ case L'b':
+ token = next_token_alpha(NULL, delim, &state);
+ if (token == NULL)
+ help_training();
+ else
+ {
+ const wchar_t *word = next_token_alpha(NULL, delim,
&state);
+ if (word == NULL)
+ help_training();
+ else
+ {
+ switch (token[0])
+ {
+ case L'b':
+ {
+ list<wstring> wordList;
+ DicSearch::searchBenj(iGame.getDic(),
word, wordList);
+ list<wstring>::const_iterator it;
+ for (it = wordList.begin(); it !=
wordList.end(); ++it)
+ cout << convertToMb(*it) << endl;
+ break;
+ }
+ case L'p':
+ {
+ map<wchar_t, list<wstring> > wordMap;
+ DicSearch::search7pl1(iGame.getDic(),
word, wordMap, false);
+ map<wchar_t, list<wstring>
>::const_iterator it;
+ for (it = wordMap.begin(); it !=
wordMap.end(); ++it)
+ {
+ if (it->first)
+ cout << "+" <<
convertToMb(it->first) << endl;
+ list<wstring>::const_iterator itWord;;
+ for (itWord = it->second.begin();
itWord != it->second.end(); itWord++)
+ {
+ cout << " " <<
convertToMb(*itWord) << endl;
+ }
+ }
+ break;
+ }
+ case L'r':
+ {
+ list<wstring> wordList;
+ DicSearch::searchRacc(iGame.getDic(),
word, wordList);
+ list<wstring>::const_iterator it;
+ for (it = wordList.begin(); it !=
wordList.end(); ++it)
+ cout << convertToMb(*it) << endl;
+ break;
+ }
+ }
+ }
+ }
+ break;
case L'd':
token = next_token_alpha(NULL, delim, &state);
if (token == NULL)
Index: test/training_7pl1.input
===================================================================
RCS file: test/training_7pl1.input
diff -N test/training_7pl1.input
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/training_7pl1.input 4 Dec 2007 16:07:25 -0000 1.1.2.1
@@ -0,0 +1,6 @@
+e
+b p maison
+b p noword
+b p zeuer
+q
+q
Index: test/training_7pl1.ref
===================================================================
RCS file: test/training_7pl1.ref
diff -N test/training_7pl1.ref
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/training_7pl1.ref 4 Dec 2007 16:07:26 -0000 1.1.2.1
@@ -0,0 +1,84 @@
+[?] pour l'aide
+commande> e
+mode entraînement
+[?] pour l'aide
+commande> b p maison
+ AIMONS
+ AMNIOS
+ MAISON
++A
+ OMANAIS
++B
+ ABIMONS
++C
+ CAMIONS
+ MANIOCS
++D
+ AMIDONS
+ DAMIONS
+ DOMINAS
+ MADISON
+ MONDAIS
++E
+ ANOMIES
+ ANOSMIE
++G
+ GOMINAS
++I
+ AIMIONS
++L
+ LAMIONS
+ OSMANLI
++M
+ NOMMAIS
++N
+ ANIMONS
+ MANIONS
+ MANNOIS
+ MANSION
+ NOMINAS
++P
+ PAMIONS
++R
+ ARMIONS
+ MANOIRS
+ MARIONS
+ MINORAS
+ NORMAIS
+ RAMIONS
+ ROMAINS
+ ROMANIS
++S
+ MAISONS
++T
+ MATIONS
+ MOISANT
+ MONTAIS
++Z
+ MAZIONS
+commande> b p noword
+commande> b p zeuer
++A
+ AZUREE
++C
+ ECUREZ
++H
+ HUEREZ
++M
+ MUEREZ
+ REMUEZ
++N
+ NUEREZ
++P
+ EPUREZ
+ PUEREZ
++R
+ RUEREZ
++S
+ SUEREZ
+ USEREZ
++T
+ TUEREZ
+commande> q
+fin du mode entraînement
+commande> q
Index: test/training_benj.input
===================================================================
RCS file: test/training_benj.input
diff -N test/training_benj.input
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/training_benj.input 4 Dec 2007 16:07:26 -0000 1.1.2.1
@@ -0,0 +1,6 @@
+e
+b b maison
+b b animal
+b b jures
+q
+q
Index: test/training_benj.ref
===================================================================
RCS file: test/training_benj.ref
diff -N test/training_benj.ref
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/training_benj.ref 4 Dec 2007 16:07:26 -0000 1.1.2.1
@@ -0,0 +1,14 @@
+[?] pour l'aide
+commande> e
+mode entraînement
+[?] pour l'aide
+commande> b b maison
+PLUmaison
+commande> b b animal
+commande> b b jures
+CONjures
+GOUjures
+PARjures
+commande> q
+fin du mode entraînement
+commande> q
Index: test/training_racc.input
===================================================================
RCS file: test/training_racc.input
diff -N test/training_racc.input
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/training_racc.input 4 Dec 2007 16:07:26 -0000 1.1.2.1
@@ -0,0 +1,6 @@
+e
+b r ave
+b r yeux
+b r ka
+q
+q
Index: test/training_racc.ref
===================================================================
RCS file: test/training_racc.ref
diff -N test/training_racc.ref
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/training_racc.ref 4 Dec 2007 16:07:26 -0000 1.1.2.1
@@ -0,0 +1,26 @@
+[?] pour l'aide
+commande> e
+mode entraînement
+[?] pour l'aide
+commande> b r ave
+Bave
+Cave
+Gave
+Have
+Lave
+Nave
+Pave
+Rave
+aveC
+aveN
+aveU
+aveZ
+commande> b r yeux
+commande> b r ka
+Oka
+Ska
+kaN
+kaS
+commande> q
+fin du mode entraînement
+commande> q
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot dic/dic_search.cpp game/duplicate.cpp gam... [cppdic],
eliot-dev <=