eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot game/game.cpp game/game.h game/training.c...


From: eliot-dev
Subject: [Eliot-dev] eliot game/game.cpp game/game.h game/training.c...
Date: Tue, 15 Jan 2008 14:56:38 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>      08/01/15 14:56:38

Modified files:
        game           : game.cpp game.h training.cpp 
        test           : driver load_saved_game.input 
                         load_saved_game.ref training_back.input 
                         training_back.ref training_play.input 
                         training_play.ref 

Log message:
         - Removed Game::setRackRandomOld() (replaced by Game::setRackRandom())
         - Adapted regression scenarii

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.cpp?cvsroot=eliot&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.h?cvsroot=eliot&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.cpp?cvsroot=eliot&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/eliot/test/driver?cvsroot=eliot&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/eliot/test/load_saved_game.input?cvsroot=eliot&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/eliot/test/load_saved_game.ref?cvsroot=eliot&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_back.input?cvsroot=eliot&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_back.ref?cvsroot=eliot&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_play.input?cvsroot=eliot&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/eliot/test/training_play.ref?cvsroot=eliot&r1=1.3&r2=1.4

Patches:
Index: game/game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- game/game.cpp       10 Jan 2008 10:23:36 -0000      1.35
+++ game/game.cpp       15 Jan 2008 14:56:38 -0000      1.36
@@ -460,158 +460,6 @@
 }
 
 
-int Game::helperSetRackRandomOld(unsigned int p, bool iCheck, set_rack_mode 
mode)
-{
-    ASSERT(p < getNPlayers(), "Wrong player number");
-
-    // Make a copy of the current player's rack
-    PlayedRack pld = getPlayer(p).getCurrentRack();
-    int nold = pld.getNbOld();
-
-    // 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);
-    realBag(bag);
-
-    if (mode == RACK_NEW && nold != 0)
-    {
-        // We may have removed too many letters from the bag (i.e. the 'new'
-        // letters of the player)
-        vector<Tile> tiles;
-        pld.getNewTiles(tiles);
-        for (unsigned int i = 0; i < tiles.size(); i++)
-        {
-            bag.replaceTile(tiles[i]);
-        }
-        pld.resetNew();
-    }
-    else if (mode == RACK_NEW && nold == 0 || mode == RACK_ALL)
-    {
-        // Replace all the tiles in the bag before choosing random ones
-        vector<Tile> tiles;
-        pld.getAllTiles(tiles);
-        for (unsigned int i = 0; i < tiles.size(); i++)
-        {
-            bag.replaceTile(tiles[i]);
-        }
-        // RACK_NEW with an empty rack is equivalent to RACK_ALL
-        pld.reset();
-        // Do not forget to update nold, for the RACK_ALL case
-        nold = 0;
-    }
-    else
-    {
-        debug("Game::helperSetRackRandomOld not a random mode\n");
-    }
-
-    // Nothing in the rack, nothing in the bag --> end of the game
-    if (bag.getNbTiles() == 0 && pld.getNbTiles() == 0)
-    {
-        return 1;
-    }
-
-    // When iCheck is true, we must make sure that there are at least 2 vowels
-    // and 2 consonants in the rack up to the 15th turn, and at least one of
-    // them from the 16th turn.
-    // So before trying to fill the rack, we'd better make sure there is a way
-    // to complete the rack with these constraints...
-    unsigned int min = 0;
-    if (iCheck)
-    {
-        unsigned int oldc, oldv;
-
-        if (bag.getNbVowels() == 0 || bag.getNbConsonants() == 0)
-        {
-            return 1;
-        }
-        // 2 vowels and 2 consonants are needed up to the 15th turn
-        if (bag.getNbVowels() > 1 && bag.getNbConsonants() > 1
-            && m_history.getSize() < 15)
-            min = 2;
-        else
-            min = 1;
-
-        // Count the remaining consonants and vowels in the rack
-        vector<Tile> tiles;
-        pld.getOldTiles(tiles);
-        oldc = 0;
-        oldv = 0;
-        for (unsigned int i = 0; i < tiles.size(); i++)
-        {
-            if (tiles[i].isConsonant())
-                oldc++;
-            if (tiles[i].isVowel())
-                oldv++;
-        }
-
-        // RACK_SIZE - nold is the number of letters to add
-        if (min > oldc + RACK_SIZE - nold ||
-            min > oldv + RACK_SIZE - nold)
-        {
-            // We cannot fill the rack with enough vowels or consonants!
-            return 3;
-        }
-    }
-
-    // Are we dealing with a normal game or a joker game?
-    if (m_variant == kJOKER)
-    {
-        // 1) Is there already a joker in the remaining letters of the rack?
-        bool jokerFound = false;
-        vector<Tile> tiles;
-        pld.getOldTiles(tiles);
-        for (unsigned int i = 0; i < tiles.size(); i++)
-        {
-            if (tiles[i].isJoker())
-            {
-                jokerFound = true;
-                break;
-            }
-        }
-
-        // 2) If there was no joker, we add one if possible
-        if (!jokerFound && bag.in(Tile::Joker()))
-        {
-            bag.takeTile(Tile::Joker());
-            pld.addNew(Tile::Joker());
-        }
-
-        // 3) Complete the rack normally... but without any joker!
-        Tile l;
-        // FIXME: this can be an infinite loop if the only tile left in the
-        // bag is a joker!
-        while (bag.getNbTiles() != 0 && pld.getNbTiles() != RACK_SIZE)
-        {
-            l = bag.selectRandom();
-            if (!l.isJoker())
-            {
-                bag.takeTile(l);
-                pld.addNew(l);
-            }
-        }
-    }
-    else // Normal game
-    {
-        // Get new tiles from the bag
-        Tile l;
-        while (bag.getNbTiles() != 0 && pld.getNbTiles() != RACK_SIZE)
-        {
-            l = bag.selectRandom();
-            bag.takeTile(l);
-            pld.addNew(l);
-        }
-    }
-
-    if (iCheck && !pld.checkRack(min, min))
-        return 2;
-
-    m_players[p]->setCurrentRack(pld);
-
-    return 0;
-}
-
-
 bool Game::rackInBag(const Rack &iRack, const Bag &iBag) const
 {
     const vector<Tile>& allTiles = m_dic.getAllTiles();

Index: game/game.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- game/game.h 8 Jan 2008 13:52:38 -0000       1.32
+++ game/game.h 15 Jan 2008 14:56:38 -0000      1.33
@@ -258,20 +258,6 @@
     int helperSetRackRandom(unsigned int p, bool iCheck, set_rack_mode mode);
 
     /**
-     * Set the rack randomly for the player p
-     * Possible return values:
-     *  0: everything went fine
-     *  1: the game is over
-     *  2: the rack was checked and was not correct (try calling the
-     *     function again)
-     *  3: there is no chance to set the rack with the vowels/consonants
-     *     constraints
-     *
-     * @deprecated: use helperSetRackRandom instead
-     */
-    int helperSetRackRandomOld(unsigned int p, bool iCheck, set_rack_mode 
mode);
-
-    /**
      * Set the rack for the player p with the given letters
      * Possible return values:
      *  0: everything went fine

Index: game/training.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- game/training.cpp   8 Jan 2008 13:52:40 -0000       1.18
+++ game/training.cpp   15 Jan 2008 14:56:38 -0000      1.19
@@ -42,20 +42,8 @@
 
 int Training::setRackRandom(bool iCheck, set_rack_mode mode)
 {
-#define MAX_RANDOM_TRY 5
-
-    int res;
-    int try_number = 0;
     m_results.clear();
-    do
-    {
-        res = helperSetRackRandomOld(m_currPlayer, iCheck, mode);
-        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)
-    return res;
+    return helperSetRackRandom(m_currPlayer, iCheck, mode);
 }
 
 

Index: test/driver
===================================================================
RCS file: /cvsroot/eliot/eliot/test/driver,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- test/driver 8 Jan 2008 13:52:41 -0000       1.7
+++ test/driver 15 Jan 2008 14:56:38 -0000      1.8
@@ -27,9 +27,9 @@
 # Test the 7 + 1 feature
 training_7pl1       0  # randseed unused
 # Several ways of getting a rack and playing a word
-training_play       4
+training_play       0  # randseed unused
 # Training rack+search+play+back
-training_back       5
+training_back       0  # randseed unused
 # Joker problem on game search
 training_rosace     0
 
@@ -74,7 +74,7 @@
 # load a standard training game (fumee)
 load_game           0
 # save and reload a training game, standard format
-load_saved_game     5
+load_saved_game     0  # randseed unused
 # load a training game with advanced format (test.elt)
 # load_test_adv       0 # We need to specifie a much more complete file format
                         # before we can handle load/save on duplicate and

Index: test/load_saved_game.input
===================================================================
RCS file: /cvsroot/eliot/eliot/test/load_saved_game.input,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- test/load_saved_game.input  1 Jan 2006 19:25:10 -0000       1.1
+++ test/load_saved_game.input  15 Jan 2008 14:56:38 -0000      1.2
@@ -1,10 +1,8 @@
 e
-*
-a t
+t EA?AEBF
 r
 n 1
-+
-a t
+t LMUAEYE
 r
 a r
 n 2
@@ -15,15 +13,13 @@
 r
 n 1
 
-+
-a t
+t EELMUJE
 r
 a r
 n 1
 a g
 
-+
-a t
+t EEIGLEH
 r
 a r
 n 3

Index: test/load_saved_game.ref
===================================================================
RCS file: /cvsroot/eliot/eliot/test/load_saved_game.ref,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- test/load_saved_game.ref    8 Jan 2008 13:52:41 -0000       1.2
+++ test/load_saved_game.ref    15 Jan 2008 14:56:38 -0000      1.3
@@ -2,14 +2,10 @@
 commande> e
 mode entraînement
 [?] pour l'aide
-commande> *
-commande> a t
-EA?AEBF
+commande> t EA?AEBF
 commande> r
 commande> n 1
-commande> +
-commande> a t
-LMUAEYE
+commande> t LMUAEYE
 commande> r
 commande> a r
   1: AY                 46 I6
@@ -46,9 +42,7 @@
 commande> r
 commande> n 1
 commande> 
-commande> +
-commande> a t
-EELMUJE
+commande> t EELMUJE
 commande> r
 commande> a r
   1: JUMEL              38 J2
@@ -80,9 +74,7 @@
  N   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
  O   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
 commande> 
-commande> +
-commande> a t
-EEIGLEH
+commande> t EEIGLEH
 commande> r
 commande> a r
   1: HELIEE             34 K5
@@ -124,8 +116,8 @@
    ===|==========|=================|=====|=====|===|======
     1 |  EA?AEBF | FABAcEE         |  H4 |  80 | 0 | *
     2 |  LMUAEYE | AY              |  I6 |  46 | 0 |  
-    3 | EELMU+JE | JUMEL           |  J2 |  38 | 0 |  
-    4 | EE+IGLEH | EGAYEE          |  7F |  32 | 0 |  
+    3 |  EELMUJE | JUMEL           |  J2 |  38 | 0 |  
+    4 |  EEIGLEH | EGAYEE          |  7F |  32 | 0 |  
 
    Total: 196
 
@@ -168,8 +160,8 @@
    ===|==========|=================|=====|=====|===|======
     1 |  EA?AEBF | FABAcEE         |  H4 |  80 | 0 | *
     2 |  LMUAEYE | AY              |  I6 |  46 | 0 |  
-    3 | EELMU+JE | JUMEL           |  J2 |  38 | 0 |  
-    4 | EE+IGLEH | EGAYEE          |  7F |  32 | 0 |  
+    3 |  EELMUJE | JUMEL           |  J2 |  38 | 0 |  
+    4 |  EEIGLEH | EGAYEE          |  7F |  32 | 0 |  
 
    Total: 196
 

Index: test/training_back.input
===================================================================
RCS file: /cvsroot/eliot/eliot/test/training_back.input,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- test/training_back.input    8 Jan 2008 13:52:41 -0000       1.2
+++ test/training_back.input    15 Jan 2008 14:56:38 -0000      1.3
@@ -1,10 +1,8 @@
 e
-*
-a t
+t EA?AEBF
 r
 n 1
-+
-a t
+t LMUAEYE
 r
 a r
 n 2
@@ -21,7 +19,7 @@
 a l
 n -1
 a s
-*
+t IEIEIEF
 r
 n 1
 a s

Index: test/training_back.ref
===================================================================
RCS file: /cvsroot/eliot/eliot/test/training_back.ref,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- test/training_back.ref      8 Jan 2008 13:52:42 -0000       1.3
+++ test/training_back.ref      15 Jan 2008 14:56:38 -0000      1.4
@@ -2,14 +2,10 @@
 commande> e
 mode entraînement
 [?] pour l'aide
-commande> *
-commande> a t
-EA?AEBF
+commande> t EA?AEBF
 commande> r
 commande> n 1
-commande> +
-commande> a t
-LMUAEYE
+commande> t LMUAEYE
 commande> r
 commande> a r
   1: AY                 46 I6
@@ -113,7 +109,7 @@
 commande> n -1
 commande> a s
 0
-commande> *
+commande> t IEIEIEF
 commande> r
 commande> n 1
 commande> a s

Index: test/training_play.input
===================================================================
RCS file: /cvsroot/eliot/eliot/test/training_play.input,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- test/training_play.input    16 Apr 2005 15:47:59 -0000      1.1
+++ test/training_play.input    15 Jan 2008 14:56:38 -0000      1.2
@@ -1,6 +1,5 @@
 e
-*
-a t
+t IEJDEUE
 j INVALID XX
 j INVALID H5
 j MAUVAIS H5
@@ -10,8 +9,7 @@
 n 0
 n 6
 a t
-+
-a t
+t DEEIPEG
 j PIEGEE H4
 j PIEGEE A1
 j PIEGEE 7C

Index: test/training_play.ref
===================================================================
RCS file: /cvsroot/eliot/eliot/test/training_play.ref,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- test/training_play.ref      24 Dec 2005 17:50:11 -0000      1.3
+++ test/training_play.ref      15 Jan 2008 14:56:38 -0000      1.4
@@ -2,9 +2,7 @@
 commande> e
 mode entraînement
 [?] pour l'aide
-commande> *
-commande> a t
-UDEEEIJ
+commande> t IEJDEUE
 commande> j INVALID XX
 Mot incorrect ou mal placé (2)
 commande> j INVALID H5
@@ -20,9 +18,7 @@
 commande> n 6
 commande> a t
 DEEI
-commande> +
-commande> a t
-DEEIPEG
+commande> t DEEIPEG
 commande> j PIEGEE H4
 Mot incorrect ou mal placé (6)
 commande> j PIEGEE A1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]