mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-12-25 21:59:30 +01:00
Results: add a isEmpty() method, and use it where possible
This commit is contained in:
parent
a881789676
commit
1e0de63ef8
9 changed files with 10 additions and 9 deletions
|
@ -65,7 +65,7 @@ void AIPercent::compute(const Dictionary &iDic, const Board &iBoard, bool iFirst
|
|||
|
||||
Move AIPercent::getMove() const
|
||||
{
|
||||
if (m_results->size() == 0)
|
||||
if (m_results->isEmpty())
|
||||
{
|
||||
// If there is no result, pass the turn.
|
||||
// FIXME: in duplicate mode, we should return a move of type NO_MOVE
|
||||
|
|
|
@ -280,7 +280,7 @@ void Duplicate::endTurn()
|
|||
const Rack &rack =
|
||||
m_players[REF_PLAYER_ID]->getLastRack().getRack();
|
||||
results.search(getDic(), getBoard(), rack, getHistory().beforeFirstRound());
|
||||
if (results.size() == 0)
|
||||
if (results.isEmpty())
|
||||
{
|
||||
// This would be very bad luck that no move is possible...
|
||||
// It's probably not even possible, but let's be safe.
|
||||
|
|
|
@ -453,7 +453,7 @@ PlayedRack Game::helperSetRackRandom(const PlayedRack &iPld,
|
|||
|
||||
BestResults res;
|
||||
res.search(getDic(), getBoard(), rack, getHistory().beforeFirstRound());
|
||||
if (res.size())
|
||||
if (!res.isEmpty())
|
||||
{
|
||||
PlayedRack pldCopy = pld;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
virtual ~Results() {}
|
||||
unsigned int size() const { return m_rounds.size(); }
|
||||
const Round & get(unsigned int) const;
|
||||
bool isEmpty() const { return m_rounds.empty(); }
|
||||
|
||||
/**
|
||||
* Perform a search on the board. Every time a word is found,
|
||||
|
|
|
@ -216,7 +216,7 @@ Move Topping::getTopMove() const
|
|||
BestResults results;
|
||||
results.search(getDic(), getBoard(), getHistory().getCurrentRack().getRack(),
|
||||
getHistory().beforeFirstRound());
|
||||
ASSERT(results.size() != 0, "No top move found");
|
||||
ASSERT(!results.isEmpty(), "No top move found");
|
||||
return Move(results.get(0));
|
||||
}
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ void ArbitAssignments::setMasterMove()
|
|||
results.search(m_game->getDic(), m_game->getBoard(),
|
||||
m_game->getCurrentRack().getRack(),
|
||||
m_game->getHistory().beforeFirstRound());
|
||||
ASSERT(results.size() != 0, "No possible valid move");
|
||||
ASSERT(!results.isEmpty(), "No possible valid move");
|
||||
int bestScore = results.get(0).getPoints();
|
||||
if (bestScore > move.getScore())
|
||||
{
|
||||
|
@ -530,7 +530,7 @@ void ArbitAssignments::setDefaultMasterMove()
|
|||
m_game->getCurrentRack().getRack(),
|
||||
m_game->getHistory().beforeFirstRound());
|
||||
// XXX: End of game
|
||||
if (results.size() == 0)
|
||||
if (results.isEmpty())
|
||||
return;
|
||||
|
||||
unsigned currIndex = 0;
|
||||
|
|
|
@ -721,7 +721,7 @@ int ArbitrationWidget::getBestScore() const
|
|||
results.search(m_game->getDic(), m_game->getBoard(),
|
||||
m_game->getCurrentRack().getRack(),
|
||||
m_game->getHistory().beforeFirstRound());
|
||||
ASSERT(results.size() != 0, "No possible valid move");
|
||||
ASSERT(!results.isEmpty(), "No possible valid move");
|
||||
return results.get(0).getPoints();
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ void TrainingWidget::updateModel()
|
|||
const Results &results = m_game->trainingGetResults();
|
||||
// Find the highest score
|
||||
int bestScore = -1;
|
||||
if (results.size() != 0)
|
||||
if (!results.isEmpty())
|
||||
bestScore = results.get(0).getPoints();
|
||||
for (unsigned int i = 0; i < results.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -339,7 +339,7 @@ void CursesIntf::drawScoresRacks(WINDOW *win, int y, int x) const
|
|||
|
||||
// Display a message when the search is complete
|
||||
if (m_game->getMode() == PublicGame::kTRAINING &&
|
||||
m_game->trainingGetResults().size())
|
||||
!m_game->trainingGetResults().isEmpty())
|
||||
{
|
||||
mvwprintw(win, y + 2*yOff - 1, x + 2, _("Search complete"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue