summaryrefslogtreecommitdiff
path: root/strategyparameters.cpp
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2017-08-14 11:31:36 -0500
committerJohn Fultz <jfultz@wolfram.com>2017-08-14 11:31:36 -0500
commite23f1b73d77f5cc80ba9ef07d9877111b4ded349 (patch)
tree4d08a5966fb4dc640517379e494e2be8bf93f9ea /strategyparameters.cpp
parente985f7f07f91e172061c9c99bf68770c5e785d66 (diff)
Fixes #50 and related non-English strategy issues.
Specifically... * Bogowin was only being used for English-like dictionaries. I suppose the bogowin numbers might change a bit from dictionary to dictionary, but I think it's quite plausible that the numbers are similar for all dictionaries. * This fixes bogowin always returning 100 or 0. * Make the strategy code more fine-grained, so that if it has some strategy files and not others, it will use what it has. JKB recommended a long time ago that I add a generic worths file to give the blank a high worth, but it wasn't being used because most languages didn't also have a syn2 or a superleaves. Now it will. Also, the vowel-consonant balance computations don't use any strategy files at all, but they were also being skipped if you didn't have every single strategy file. Oops. * The strategy computations would sometimes do unexpected things if the leaves weren't alphabetized. They now look at the alphabetized version of the leave. * A couple more conversions to ranged-for loops.
Diffstat (limited to 'strategyparameters.cpp')
-rw-r--r--strategyparameters.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/strategyparameters.cpp b/strategyparameters.cpp
index f9576d1..d936afa 100644
--- a/strategyparameters.cpp
+++ b/strategyparameters.cpp
@@ -27,18 +27,21 @@
using namespace Quackle;
StrategyParameters::StrategyParameters()
- : m_initialized(false)
+ : m_hasSyn2(false)
+ , m_hasWorths(false)
+ , m_hasVcPlace(false)
+ , m_hasBogowin(false)
+ , m_hasSuperleaves(false)
{
}
void StrategyParameters::initialize(const string &lexicon)
{
- bool hasSyn2 = loadSyn2(DataManager::self()->findDataFile("strategy", lexicon, "syn2"));
- bool hasWorths = loadWorths(DataManager::self()->findDataFile("strategy", lexicon, "worths"));
- bool hasVcPlace = loadVcPlace(DataManager::self()->findDataFile("strategy", lexicon, "vcplace"));
- bool hasBogowin = loadBogowin(DataManager::self()->findDataFile("strategy", lexicon, "bogowin"));
- bool hasSuperleaves = loadSuperleaves(DataManager::self()->findDataFile("strategy", lexicon, "superleaves"));
- m_initialized = hasSyn2 && hasWorths && hasVcPlace && hasBogowin && hasSuperleaves;
+ m_hasSyn2 = loadSyn2(DataManager::self()->findDataFile("strategy", lexicon, "syn2"));
+ m_hasWorths = loadWorths(DataManager::self()->findDataFile("strategy", lexicon, "worths"));
+ m_hasVcPlace = loadVcPlace(DataManager::self()->findDataFile("strategy", lexicon, "vcplace"));
+ m_hasBogowin = loadBogowin(DataManager::self()->findDataFile("strategy", lexicon, "bogowin"));
+ m_hasSuperleaves = loadSuperleaves(DataManager::self()->findDataFile("strategy", lexicon, "superleaves"));
}
bool StrategyParameters::loadSyn2(const string &filename)