mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-17 06:11:49 +01:00
Sort the training results using the dictionary order as alphabetical order
This commit is contained in:
parent
08c9816d32
commit
bb13f634b3
2 changed files with 15 additions and 14 deletions
|
@ -32,9 +32,9 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
bool wcharCompare(wchar_t c1, wchar_t c2)
|
bool tileCompare(const Tile &t1, const Tile &t2)
|
||||||
{
|
{
|
||||||
return towlower(c1) < towlower(c2);
|
return t1.toCode() < t2.toCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct less_points : public binary_function<const Round&, const Round&, bool>
|
struct less_points : public binary_function<const Round&, const Round&, bool>
|
||||||
|
@ -48,23 +48,23 @@ struct less_points : public binary_function<const Round&, const Round&, bool>
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the scores are equal, sort alphabetically, ignoring
|
// If the scores are equal, sort alphabetically (i.e. in the
|
||||||
// the case
|
// order of the letters in the dictionary), ignoring the case
|
||||||
const wstring &s1 = r1.getWord();
|
const wstring &s1 = r1.getWord();
|
||||||
const wstring &s2 = r2.getWord();
|
const wstring &s2 = r2.getWord();
|
||||||
if (std::lexicographical_compare(s1.begin(),
|
if (std::lexicographical_compare(r1.getTiles().begin(),
|
||||||
s1.end(),
|
r1.getTiles().end(),
|
||||||
s2.begin(),
|
r2.getTiles().begin(),
|
||||||
s2.end(),
|
r2.getTiles().end(),
|
||||||
wcharCompare))
|
tileCompare))
|
||||||
{
|
{
|
||||||
return true;;
|
return true;;
|
||||||
}
|
}
|
||||||
else if (std::lexicographical_compare(s2.begin(),
|
else if (std::lexicographical_compare(r2.getTiles().begin(),
|
||||||
s2.end(),
|
r2.getTiles().end(),
|
||||||
s1.begin(),
|
r1.getTiles().begin(),
|
||||||
s1.end(),
|
r1.getTiles().end(),
|
||||||
wcharCompare))
|
tileCompare))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
unsigned int getWordLen() const { return m_word.size(); }
|
unsigned int getWordLen() const { return m_word.size(); }
|
||||||
int getPoints() const { return m_points; }
|
int getPoints() const { return m_points; }
|
||||||
int getBonus() const { return m_bonus; }
|
int getBonus() const { return m_bonus; }
|
||||||
|
const vector<Tile> &getTiles() const { return m_word; }
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
* Coordinates
|
* Coordinates
|
||||||
|
|
Loading…
Reference in a new issue