eliot-dev
[Top][All Lists]
Advanced

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

[Eliot-dev] Changes to eliot/game/duplicate.h [antoine-1]


From: eliot-dev
Subject: [Eliot-dev] Changes to eliot/game/duplicate.h [antoine-1]
Date: Sun, 23 Oct 2005 13:16:31 -0400

Index: eliot/game/duplicate.h
diff -u /dev/null eliot/game/duplicate.h:1.9.2.1
--- /dev/null   Sun Oct 23 17:16:31 2005
+++ eliot/game/duplicate.h      Sun Oct 23 17:16:24 2005
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (C) 2005 Eliot
+ * Authors: Olivier Teuliere  <address@hidden>
+ *
+<<<<<<< duplicate.h
+=======
+ * $Id: duplicate.h,v 1.9.2.1 2005/10/23 17:16:24 afrab Exp $
+ *
+>>>>>>> 1.9
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *****************************************************************************/
+
+/* $Id: duplicate.h,v 1.9.2.1 2005/10/23 17:16:24 afrab Exp $ */
+
+#ifndef _DUPLICATE_H_
+#define _DUPLICATE_H_
+
+#include "game.h"
+
+/**
+ * This class handles the logic specific to a duplicate game.
+ * The trick in this mode is that the players will not necessarily play they
+ * word always in the same order, so we need to implement a "synchronization":
+ *   - when a human player wants to play a word, he plays it, and its score
+ *     and rack are updated. He cannot change his word afterwards.
+ *   - if there is still a human player who has not played for the current
+ *     turn, we wait for him
+ *   - if all the human players have played, it's the turn to the AI players
+ *     (currently handled in a loop, but we could imagine that they are running
+ *     in their own thread).
+ *   - once all the players have played, we can really end the turn:
+ *     the best word is played on the board, the history of the game is
+ *     updated, and the new rack is chosen.
+ *
+ * AI players play after human ones, because with the current implementation
+ * of the interfaces it is too easy for a player to see the rack of other
+ * players, and in particular a human player could take advantage of that to
+ * have more clues about the best word.
+ * TODO: better isolation of the players...
+ */
+class Duplicate: public Game
+{
+    friend class GameFactory;
+public:
+    virtual GameMode getMode() const { return kDUPLICATE; }
+    virtual std::string getModeAsString() const { return "Duplicate"; }
+
+    /*************************
+     * Game handling
+     *************************/
+    virtual int play(int player, Round& round);
+    virtual int back();
+
+private:
+    // Private constructor and destructor to force using the GameFactory class
+    Duplicate(const Dictionary iDic);
+    virtual ~Duplicate();
+
+    // m_hasPlayed[p] is true iff player p has played for this turn
+    std::map <int, bool> m_hasPlayed;
+};
+
+#endif /* _DUPLICATE_H_ */




reply via email to

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