eliot-dev
[Top][All Lists]
Advanced

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

[Eliot-dev] eliot game/game.cpp test/driver test/duplicate_...


From: Olivier Teulière
Subject: [Eliot-dev] eliot game/game.cpp test/driver test/duplicate_...
Date: Sun, 23 Nov 2008 18:18:08 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>      08/11/23 18:18:07

Modified files:
        game           : game.cpp 
        test           : driver 
Added files:
        test           : duplicate_1_player.input duplicate_1_player.ref 
                         duplicate_invalid_turn.input 
                         duplicate_invalid_turn.ref 

Log message:
         - Really fixed duplicate games when noone plays a valid move
         - Added a unit test to ensure it
         - Fixed Game::back() (this fixes some unit tests broken by a previous 
commit)
         - Added a unit test for a duplicate game with only one player

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.cpp?cvsroot=eliot&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/eliot/test/driver?cvsroot=eliot&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/eliot/test/duplicate_1_player.input?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/duplicate_1_player.ref?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/duplicate_invalid_turn.input?cvsroot=eliot&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/eliot/test/duplicate_invalid_turn.ref?cvsroot=eliot&rev=1.1

Patches:
Index: game/game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- game/game.cpp       23 Nov 2008 17:07:42 -0000      1.47
+++ game/game.cpp       23 Nov 2008 18:18:02 -0000      1.48
@@ -80,41 +80,11 @@
     if (m_history.getSize() < n)
         throw GameException("Cannot go back that far");
 
-    for (unsigned int i = 0; i < n+1; ++i)
+    for (unsigned int i = 0; i < n; ++i)
     {
         m_navigation.prevTurn();
     }
     m_navigation.clearFuture();
-#if 0
-    for (unsigned int i = 0; i < n; i++)
-    {
-        prevPlayer();
-        const Move &lastMove = m_history.getPreviousTurn().getMove();
-        // Nothing to cancel if the move was not a valid round
-        if (lastMove.getType() != Move::VALID_ROUND)
-            continue;
-
-        const Round &lastround = lastMove.getRound();
-        // Remove the word from the board, and put its letters back
-        // into the bag
-        m_board.removeRound(m_dic, lastround);
-        for (unsigned int j = 0; j < lastround.getWordLen(); j++)
-        {
-            if (lastround.isPlayedFromRack(j))
-            {
-                if (lastround.isJoker(j))
-                    m_bag.replaceTile(Tile::Joker());
-                else
-                    m_bag.replaceTile(lastround.getTile(j));
-            }
-        }
-        // Remove the points of this round
-        m_points -= lastround.getPoints();
-        // Remove the turns
-        m_players[m_currPlayer]->removeLastTurn();
-        m_history.removeLastTurn();
-    }
-#endif
     return 0;
 }
 
@@ -224,8 +194,10 @@
     // Get the tiles remaining on the rack
     vector<Tile> tiles;
     pld.getOldTiles(tiles);
-    ASSERT(tiles.size() < RACK_SIZE,
-           "Cannot complete the rack, it is already complete");
+    // The rack is already complete, there is nothing to do
+    // TODO: add a log here
+    if (tiles.size() >= RACK_SIZE)
+        return iPld;
 
     bool jokerAdded = false;
     // Are we dealing with a normal game or a joker game?

Index: test/driver
===================================================================
RCS file: /cvsroot/eliot/eliot/test/driver,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- test/driver 15 Oct 2008 19:43:24 -0000      1.10
+++ test/driver 23 Nov 2008 18:18:04 -0000      1.11
@@ -57,6 +57,10 @@
 duplicate_2_ai      5
 # 2 human players, one IA, with manual change of human player
 duplicate_humans_ai 6
+# Only one player
+duplicate_1_player  8
+# One complete turn without a valid move
+duplicate_invalid_turn 9
 
 #################
 # Free game mode

Index: test/duplicate_1_player.input
===================================================================
RCS file: test/duplicate_1_player.input
diff -N test/duplicate_1_player.input
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test/duplicate_1_player.input       23 Nov 2008 18:18:05 -0000      1.1
@@ -0,0 +1,13 @@
+d 1 0
+a T
+j SEAUX H8
+a S
+a T
+j HUTIN i9
+a S
+a t
+a g
+a p
+q
+q
+

Index: test/duplicate_1_player.ref
===================================================================
RCS file: test/duplicate_1_player.ref
diff -N test/duplicate_1_player.ref
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test/duplicate_1_player.ref 23 Nov 2008 18:18:06 -0000      1.1
@@ -0,0 +1,51 @@
+Using seed: 8
+[?] pour l'aide
+commande> d 1 0
+mode duplicate
+[?] pour l'aide
+commande> a T
+Joueur 0: UAXEHTS
+commande> j SEAUX H8
+commande> a S
+Joueur 0:   48
+commande> a T
+Joueur 0: HTIUONU
+commande> j HUTIN i9
+commande> a S
+Joueur 0:   85
+commande> a t
+OUNEUNE
+commande> a g
+     1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
+ A   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ B   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ C   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ D   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ E   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ F   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ G   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ H   -  -  -  -  -  -  -  S  E  A  U  X  -  -  -
+ I   -  -  -  -  -  -  -  -  H  U  T  I  N  -  -
+ J   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ K   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ L   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ M   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ N   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+ O   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+commande> a p
+Eliot 1.5
+
+Game type: Duplicate
+Player 0: Human
+
+    N |   RACK   |    SOLUTION     | REF | PTS | P | BONUS
+   ===|==========|=================|=====|=====|===|======
+    1 |  UAXEHTS | SEAUX           |  H8 |  48 | 0 |  
+    2 | HT+IUONU | HUTIN           |  I9 |  37 | 0 |  
+
+   Total: 85
+
+Rack 0: OU+NEUNE
+commande> q
+fin du mode duplicate
+commande> q

Index: test/duplicate_invalid_turn.input
===================================================================
RCS file: test/duplicate_invalid_turn.input
diff -N test/duplicate_invalid_turn.input
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test/duplicate_invalid_turn.input   23 Nov 2008 18:18:06 -0000      1.1
@@ -0,0 +1,15 @@
+d 2 0
+a t
+j ERROR H1
+j ERROR H2
+a T
+a S
+a p
+j RELIURE h4
+j RELIEUR h4
+a S
+a T
+a p
+q
+q
+

Index: test/duplicate_invalid_turn.ref
===================================================================
RCS file: test/duplicate_invalid_turn.ref
diff -N test/duplicate_invalid_turn.ref
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ test/duplicate_invalid_turn.ref     23 Nov 2008 18:18:07 -0000      1.1
@@ -0,0 +1,55 @@
+Using seed: 9
+[?] pour l'aide
+commande> d 2 0
+mode duplicate
+[?] pour l'aide
+commande> a t
+ILERERU
+commande> j ERROR H1
+commande> j ERROR H2
+commande> a T
+Joueur 0: EEILRRU
+Joueur 1: EEILRRU
+commande> a S
+Joueur 0:    0
+Joueur 1:    0
+commande> a p
+Eliot 1.5
+
+Game type: Duplicate
+Player 0: Human
+Player 1: Human
+
+    N |   RACK   |    SOLUTION     | REF | PTS | P | BONUS
+   ===|==========|=================|=====|=====|===|======
+
+   Total: 0
+
+Rack 0: EEILRRU
+Rack 1: EEILRRU
+commande> j RELIURE h4
+commande> j RELIEUR h4
+commande> a S
+Joueur 0:   66
+Joueur 1:   66
+commande> a T
+Joueur 0: GUAUVBP
+Joueur 1: GUAUVBP
+commande> a p
+Eliot 1.5
+
+Game type: Duplicate
+Player 0: Human
+Player 1: Human
+
+    N |   RACK   |    SOLUTION     | REF | PTS | P | BONUS
+   ===|==========|=================|=====|=====|===|======
+    1 |  EEILRRU | RELIURE         |  H4 |  66 | 0 | *
+
+   Total: 66
+
+Rack 0: GUAUVBP
+Rack 1: GUAUVBP
+commande> q
+fin du mode duplicate
+commande> q




reply via email to

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