[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] Changes to eliot/game/training.cpp [antoine-1]
From: |
eliot-dev |
Subject: |
[Eliot-dev] Changes to eliot/game/training.cpp [antoine-1] |
Date: |
Sun, 23 Oct 2005 13:16:40 -0400 |
Index: eliot/game/training.cpp
diff -u /dev/null eliot/game/training.cpp:1.8.2.1
--- /dev/null Sun Oct 23 17:16:40 2005
+++ eliot/game/training.cpp Sun Oct 23 17:16:24 2005
@@ -0,0 +1,166 @@
+/*****************************************************************************
+ * Copyright (C) 1999-2005 Eliot
+ * Authors: Antoine Fraboulet <address@hidden>
+ * Olivier Teuliere <address@hidden>
+ *
+<<<<<<< training.cpp
+=======
+ * $Id: training.cpp,v 1.8.2.1 2005/10/23 17:16:24 afrab Exp $
+ *
+>>>>>>> 1.8
+ * 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: training.cpp,v 1.8.2.1 2005/10/23 17:16:24 afrab Exp $ */
+
+#include "dic.h"
+#include "tile.h"
+#include "rack.h"
+#include "round.h"
+#include "pldrack.h"
+#include "player.h"
+#include "training.h"
+
+#include "debug.h"
+
+
+Training::Training(const Dictionary iDic): Game(iDic)
+{
+ addHumanPlayer();
+}
+
+
+Training::~Training()
+{
+}
+
+
+int Training::play(int player, Round& round)
+{
+ gdebug("Training::play\n");
+ int res = checkPlayedWord(round);
+ if (res != 0)
+ {
+ gdebug("Training::play - error in checkPlayedWord (code %d)\n",res);
+ return res;
+ }
+
+ int player_num = 0;
+ int turn_num = m_history.getSize();
+ /* Update the board */
+ m_board.addRound(m_dic,round);
+ /* Update the game history */
+
m_history.setCurrentRack(m_players[player_num]->getHistory().getCurrentRack());
+ m_history.playRound(player_num,turn_num,round);
+ /* Update the rack and the score of the current player */
+ m_players[player_num]->playRound(turn_num,round);
+ /* reset the search */
+ m_results.clear();
+ return 0;
+}
+
+
+int Training::back()
+{
+ gdebug("Training::back\n");
+ int res = 0;
+ int player_num = 0;
+ if (m_history.getSize() > 1)
+ {
+ const PlayedRack current_rack = m_history.getCurrentRack();
+ const Turn last_turn = m_history.getPreviousTurn();
+
+ /* remove the turn for the player */
+ ASSERT(0,"player history\n");
+ // m_players[player_num]->getHistory().removeLastTurn();
+
+ /* remove the turn for the game history */
+ m_history.removeLastTurn();
+ /* Remove the word from the board */
+ m_board.removeRound(m_dic, last_turn.getRound());
+ /* Put back the letter in the bag */
+ ASSERT(0,"put back tiles in bag\n");
+#if 0
+ for (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));
+ }
+ }
+#endif
+ }
+ else
+ {
+ res = 1;
+ }
+ return res;
+}
+
+
+void Training::search()
+{
+ Rack rack;
+ getCurrentPlayer().getCurrentRack().getRack(rack);
+ std::cerr << "Training::search() for " << rack.toString()
+ << " with history size " << m_history.getSize() << std::endl;
+ m_results.search(m_dic, m_board, rack, m_history.getSize() - 1);
+ m_results.sort_by_points();
+}
+
+
+int Training::playResult(int n)
+{
+ ASSERT(0 <= n && n < m_results.size(),"Wrong result number");
+ Round round = m_results.get(n);
+ return play(0,round);
+}
+
+
+void Training::testPlay(int num)
+{
+ ASSERT(0 <= num && num < m_results.size(), "Wrong result number");
+ testRound = m_results.get(num);
+ m_board.testRound(testRound);
+}
+
+
+void Training::removeTestPlay()
+{
+ m_board.removeTestRound();
+ testRound = Round();
+}
+
+
+std::string Training::getTestPlayWord()
+{
+ return testRound.getWord();
+}
+
+
+int Training::setRack(PlayedRack::set_rack_mode mode, bool check, std::string
rack)
+{
+ return Game::setRack(0,mode,check,rack);
+}
+
+
+
+/// Local Variables:
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// End:
- [Eliot-dev] Changes to eliot/game/training.cpp [antoine-1],
eliot-dev <=