From d3e9d1e0acce2490d5ca5f3cd67247fdd6da40cc Mon Sep 17 00:00:00 2001 From: Antoine Fraboulet Date: Tue, 27 Dec 2005 00:06:23 +0000 Subject: [PATCH] - off by one in History. corrected. all regression tests ok. Scenario: training_dict Scenario: training_bag Scenario: training_search Scenario: training_play Scenario: duplicate_2_ai Scenario: freegame_passing Scenario: freegame_change Scenario: freegame_3_ai Summary: Everything was OK. --- game/game.h | 2 +- game/history.cpp | 4 ++-- game/history.h | 11 ++++++----- game/results.cpp | 3 +-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/game/game.h b/game/game.h index 16c2fb0..f950121 100644 --- a/game/game.h +++ b/game/game.h @@ -133,7 +133,7 @@ public: * Methods to access already played words. * The int parameter should be 0 <= int < getNTurns() */ - const History& getHistory() { return m_history; } + const History& getHistory() const { return m_history; } /** * Methods to access players. diff --git a/game/history.cpp b/game/history.cpp index d34a56a..8241835 100644 --- a/game/history.cpp +++ b/game/history.cpp @@ -60,7 +60,7 @@ History::~History() int History::getSize() const { - return m_history.size(); + return m_history.size() - 1; } @@ -79,7 +79,7 @@ void History::setCurrentRack(const PlayedRack &iPld) const Turn& History::getPreviousTurn() const { int idx = m_history.size() - 2; - ASSERT(0 <= idx , "Wrong turn number"); + ASSERT(0 <= idx , "No previous turn"); return *(m_history[idx]); } diff --git a/game/history.h b/game/history.h index 00d5c07..22c4472 100644 --- a/game/history.h +++ b/game/history.h @@ -28,10 +28,9 @@ #define _HISTORY_H #include - -class Turn; -class PlayedRack; -class Round; +#include "pldrack.h" +#include "round.h" +#include "turn.h" /** * History stores all the turns that have been played @@ -39,9 +38,11 @@ class Round; * - one for the complete game * - one for each of the players * - * A History is never empty (getSize() can be used as the is the current turn + * A History is never void (getSize() can be used as the is the current turn * number for the complete game history). * + * History starts at zero. + * * The top of the history is an empty * Turn until it has been filled and game is up to a new round. * diff --git a/game/results.cpp b/game/results.cpp index 6ec5735..4563295 100644 --- a/game/results.cpp +++ b/game/results.cpp @@ -58,8 +58,7 @@ void Results::search(const Dictionary &iDic, Board &iBoard, { clear(); - /* we start at round 1 */ - if (iTurn == 1) + if (iTurn == 0) { iBoard.searchFirst(iDic, iRack, *this); }