[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot game/game.cpp test/duplicate_2_ai.ref wxw...
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot game/game.cpp test/duplicate_2_ai.ref wxw... |
Date: |
Thu, 10 Jan 2008 10:23:36 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 08/01/10 10:23:36
Modified files:
game : game.cpp
test : duplicate_2_ai.ref
wxwin : mainframe.cc
Log message:
- wxwin/mainframe.cc: Fixed a crash occurring when no config file is
found
- Fixed a bug occurring in duplicate mode: sometimes the game ended
too early,
while it was still allowed to go on.
Also updated the corresponding regression scenario
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.cpp?cvsroot=eliot&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/eliot/test/duplicate_2_ai.ref?cvsroot=eliot&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/eliot/wxwin/mainframe.cc?cvsroot=eliot&r1=1.23&r2=1.24
Patches:
Index: game/game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- game/game.cpp 8 Jan 2008 13:52:38 -0000 1.34
+++ game/game.cpp 10 Jan 2008 10:23:36 -0000 1.35
@@ -336,16 +336,36 @@
}
}
+ // Count the needed consonants and vowels in the rack
+ // (i.e. minimum required, minus what we already have in the rack)
+ unsigned int neededVowels = min;
+ unsigned int neededConsonants = min;
+ for (unsigned int i = 0; i < tiles.size(); ++i)
+ {
+ if (neededVowels > 0 && tiles[i].isVowel())
+ neededVowels--;
+ if (neededConsonants > 0 && tiles[i].isConsonant())
+ neededConsonants--;
+ }
+
// Nothing in the rack, nothing in the bag --> end of the (free)game
if (bag.getNbTiles() == 0 && pld.getNbTiles() == 0)
{
return 1;
}
+
+ // Check whether it is possible to complete the rack properly
+ if (bag.getNbVowels() < neededVowels ||
+ bag.getNbConsonants() < neededConsonants)
+ {
+ return 1;
+ }
// End of game condition
if (iCheck)
{
- if (bag.getNbVowels() == 0 || bag.getNbConsonants() == 0 ||
- bag.getNbTiles() == 1)
+ if (bag.getNbVowels() < neededVowels ||
+ bag.getNbConsonants() < neededConsonants ||
+ (bag.getNbTiles() + tiles.size()) == 1)
{
return 1;
}
@@ -383,25 +403,6 @@
if (jokerAdded)
pld.addNew(Tile::Joker());
- // Count the needed consonants and vowels in the rack
- // (i.e. minimum required, minus what we already have in the rack)
- unsigned int neededVowels = min;
- unsigned int neededConsonants = min;
- for (unsigned int i = 0; i < tiles.size(); ++i)
- {
- if (neededVowels > 0 && tiles[i].isVowel())
- neededVowels--;
- if (neededConsonants > 0 && tiles[i].isConsonant())
- neededConsonants--;
- }
-
- // Check whether it is possible to complete the rack properly
- if (bag.getNbVowels() < neededVowels ||
- bag.getNbConsonants() < neededConsonants)
- {
- return 1;
- }
-
// RACK_SIZE - tiles.size() is the number of letters to add to the rack
if (neededVowels > RACK_SIZE - tiles.size() ||
neededConsonants > RACK_SIZE - tiles.size())
Index: test/duplicate_2_ai.ref
===================================================================
RCS file: /cvsroot/eliot/eliot/test/duplicate_2_ai.ref,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- test/duplicate_2_ai.ref 8 Jan 2008 13:52:41 -0000 1.4
+++ test/duplicate_2_ai.ref 10 Jan 2008 10:23:36 -0000 1.5
@@ -3,14 +3,14 @@
mode duplicate
[?] pour l'aide
commande> a S
-Joueur 0: 918
-Joueur 1: 918
+Joueur 0: 931
+Joueur 1: 931
commande> a T
-Joueur 0: DQRU
-Joueur 1: DQRU
+Joueur 0: R
+Joueur 1: R
commande> a l
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ?
- 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
commande> a p
Eliot 1.5
@@ -42,11 +42,12 @@
20 | TOEHLRT | PHOT | 8L | 27 | 0 |
21 | ELRT+NME | REMELENT | C2 | 70 | 0 | *
22 | QDRMUTI | MITAN | 5E | 20 | 0 |
+ 23 | DQRU | QUID | 13H | 13 | 0 |
- Total: 918
+ Total: 931
-Rack 0: DQRU
-Rack 1: DQRU
+Rack 0: R
+Rack 1: R
commande> a g
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A - - - - - - - - - - - H A V A
@@ -56,10 +57,10 @@
E - - - - M - R - L - E - - - -
F - - - - I C I - O K A - - - -
G - - - - T U S - P I N - - - -
- H - - - F A B A c E E S - - - -
- I - - V I N E S - - F - - - - -
+ H - - - F A B A c E E S - Q - -
+ I - - V I N E S - - F - - U - -
J - W A X - B - - - S E R I N S
- K D U N E - E - - - - - - - - T
+ K D U N E - E - - - - - - D - T
L O - - E - S E P T I m E - - Y
M U - - - - - - H - - - - - - L
N M O L L I T - O - C A R G U E
Index: wxwin/mainframe.cc
===================================================================
RCS file: /cvsroot/eliot/eliot/wxwin/mainframe.cc,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- wxwin/mainframe.cc 8 Jan 2008 13:52:43 -0000 1.23
+++ wxwin/mainframe.cc 10 Jan 2008 10:23:36 -0000 1.24
@@ -178,24 +178,6 @@
listsizer->Add(reslist, 1, wxEXPAND | wxLEFT | wxRIGHT, 1);
#endif
- wxString dicpath = config.getDicPath();
- try
- {
- Dictionary *dic = new Dictionary(dicpath.mb_str().data());
- m_dic = dic;
- m_game = GameFactory::Instance()->createTraining(*m_dic);
- if (m_game)
- {
- m_game->start();
- }
- }
- catch (std::exception &e)
- {
- wxCommandEvent event;
- // This will also start a new training game indirectly
- OnMenuConfGameDic(event);
- }
-
InitMenu();
statusbar = CreateStatusBar(2, 0, Status_ID);
@@ -239,6 +221,24 @@
SetClientSize(size_);
Move(config.getFramePos(wxT(APPNAME)));
+ wxString dicpath = config.getDicPath();
+ try
+ {
+ Dictionary *dic = new Dictionary(dicpath.mb_str().data());
+ m_dic = dic;
+ m_game = GameFactory::Instance()->createTraining(*m_dic);
+ if (m_game)
+ {
+ m_game->start();
+ }
+ }
+ catch (std::exception &e)
+ {
+ wxCommandEvent event;
+ // This will also start a new training game indirectly
+ OnMenuConfGameDic(event);
+ }
+
InitFrames();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot game/game.cpp test/duplicate_2_ai.ref wxw...,
eliot-dev <=