diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-01-07 19:06:15 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-01-07 19:06:15 -0500 |
commit | b3ae14d99ae8f656a176a8bbc98b3cbb67051e06 (patch) | |
tree | 11f0ad6ababccd100118654ad52e1d05bbd344bc /generator | |
parent | 7efd7095f9a52eb67f697dd1762906c0f1610a54 (diff) | |
download | lingo-randomizer-b3ae14d99ae8f656a176a8bbc98b3cbb67051e06.tar.gz lingo-randomizer-b3ae14d99ae8f656a176a8bbc98b3cbb67051e06.tar.bz2 lingo-randomizer-b3ae14d99ae8f656a176a8bbc98b3cbb67051e06.zip |
fix synonyms problem + add restrictions
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/generator/generator.cpp b/generator/generator.cpp index f48d667..b13dea2 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp | |||
@@ -375,9 +375,20 @@ void generator::run() { | |||
375 | if (f_id1 != f_id2) { | 375 | if (f_id1 != f_id2) { |
376 | Form& form = forms_.at(f_id1); | 376 | Form& form = forms_.at(f_id1); |
377 | Form& form2 = forms_.at(f_id2); | 377 | Form& form2 = forms_.at(f_id2); |
378 | // Top yellow should not be mid yellow. | ||
378 | if (form.anagram_set_id == form2.anagram_set_id) { | 379 | if (form.anagram_set_id == form2.anagram_set_id) { |
379 | continue; | 380 | continue; |
380 | } | 381 | } |
382 | // Top yellow should not be top white. | ||
383 | if (std::any_of( | ||
384 | form.pronunciation_ids.begin(), | ||
385 | form.pronunciation_ids.end(), [&form2](size_t p_id) { | ||
386 | return std::find(form2.pronunciation_ids.begin(), | ||
387 | form2.pronunciation_ids.end(), | ||
388 | p_id) == form2.pronunciation_ids.end(); | ||
389 | })) { | ||
390 | continue; | ||
391 | } | ||
381 | form.puzzles[kYellowTop].insert(f_id2); | 392 | form.puzzles[kYellowTop].insert(f_id2); |
382 | } | 393 | } |
383 | } | 394 | } |
@@ -811,8 +822,10 @@ void generator::run() { | |||
811 | Form& holonym_form = forms_.at(holonym_word.base_form_id); | 822 | Form& holonym_form = forms_.at(holonym_word.base_form_id); |
812 | Form& meronym_form = forms_.at(meronym_word.base_form_id); | 823 | Form& meronym_form = forms_.at(meronym_word.base_form_id); |
813 | 824 | ||
814 | holonym_form.puzzles[kBlueBottom].insert(meronym_form.id); | 825 | // There must be some mis-naming somewhere, because things are reversed |
815 | meronym_form.puzzles[kRedBottom].insert(holonym_form.id); | 826 | // if we do red with holonym and blue with meronym. |
827 | holonym_form.puzzles[kRedBottom].insert(meronym_form.id); | ||
828 | meronym_form.puzzles[kBlueBottom].insert(holonym_form.id); | ||
816 | } | 829 | } |
817 | } | 830 | } |
818 | } | 831 | } |
@@ -844,6 +857,12 @@ void generator::run() { | |||
844 | Form& form1 = forms_.at(f_id1); | 857 | Form& form1 = forms_.at(f_id1); |
845 | const Form& form2 = forms_.at(f_id2); | 858 | const Form& form2 = forms_.at(f_id2); |
846 | 859 | ||
860 | // Top purple should not be mid red/blue. | ||
861 | if (form1.text.find(form2.text) != std::string::npos || | ||
862 | form2.text.find(form1.text) != std::string::npos) { | ||
863 | continue; | ||
864 | } | ||
865 | |||
847 | if (std::abs(static_cast<int>(form1.text.size()) - | 866 | if (std::abs(static_cast<int>(form1.text.size()) - |
848 | static_cast<int>(form2.text.size())) <= 4) { | 867 | static_cast<int>(form2.text.size())) <= 4) { |
849 | form1.puzzles[kPurpleTop].insert(f_id2); | 868 | form1.puzzles[kPurpleTop].insert(f_id2); |
@@ -1251,11 +1270,10 @@ void generator::FindComboPuzzles(std::string text, PuzzleType left_type, | |||
1251 | continue; | 1270 | continue; |
1252 | 1271 | ||
1253 | for (Form& right_form : forms_) { | 1272 | for (Form& right_form : forms_) { |
1254 | if (right_type == kWhiteBottom && | ||
1255 | right_form.puzzles[right_type].size() > 3) | ||
1256 | continue; | ||
1257 | if (right_form.text.size() >= 3 && right_form.puzzles.count(right_type) && | 1273 | if (right_form.text.size() >= 3 && right_form.puzzles.count(right_type) && |
1258 | form_by_text_.count(left_form.text + right_form.text)) { | 1274 | form_by_text_.count(left_form.text + right_form.text) && |
1275 | !(right_type == kWhiteBottom && | ||
1276 | right_form.puzzles[right_type].size() > 3)) { | ||
1259 | for (size_t left_hint_id : left_form.puzzles[left_type]) { | 1277 | for (size_t left_hint_id : left_form.puzzles[left_type]) { |
1260 | Form& left_hint = forms_[left_hint_id]; | 1278 | Form& left_hint = forms_[left_hint_id]; |
1261 | for (size_t right_hint_id : right_form.puzzles[right_type]) { | 1279 | for (size_t right_hint_id : right_form.puzzles[right_type]) { |