From b3ae14d99ae8f656a176a8bbc98b3cbb67051e06 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 7 Jan 2024 19:06:15 -0500 Subject: fix synonyms problem + add restrictions --- generator/generator.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'generator') 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() { if (f_id1 != f_id2) { Form& form = forms_.at(f_id1); Form& form2 = forms_.at(f_id2); + // Top yellow should not be mid yellow. if (form.anagram_set_id == form2.anagram_set_id) { continue; } + // Top yellow should not be top white. + if (std::any_of( + form.pronunciation_ids.begin(), + form.pronunciation_ids.end(), [&form2](size_t p_id) { + return std::find(form2.pronunciation_ids.begin(), + form2.pronunciation_ids.end(), + p_id) == form2.pronunciation_ids.end(); + })) { + continue; + } form.puzzles[kYellowTop].insert(f_id2); } } @@ -811,8 +822,10 @@ void generator::run() { Form& holonym_form = forms_.at(holonym_word.base_form_id); Form& meronym_form = forms_.at(meronym_word.base_form_id); - holonym_form.puzzles[kBlueBottom].insert(meronym_form.id); - meronym_form.puzzles[kRedBottom].insert(holonym_form.id); + // There must be some mis-naming somewhere, because things are reversed + // if we do red with holonym and blue with meronym. + holonym_form.puzzles[kRedBottom].insert(meronym_form.id); + meronym_form.puzzles[kBlueBottom].insert(holonym_form.id); } } } @@ -844,6 +857,12 @@ void generator::run() { Form& form1 = forms_.at(f_id1); const Form& form2 = forms_.at(f_id2); + // Top purple should not be mid red/blue. + if (form1.text.find(form2.text) != std::string::npos || + form2.text.find(form1.text) != std::string::npos) { + continue; + } + if (std::abs(static_cast(form1.text.size()) - static_cast(form2.text.size())) <= 4) { form1.puzzles[kPurpleTop].insert(f_id2); @@ -1251,11 +1270,10 @@ void generator::FindComboPuzzles(std::string text, PuzzleType left_type, continue; for (Form& right_form : forms_) { - if (right_type == kWhiteBottom && - right_form.puzzles[right_type].size() > 3) - continue; if (right_form.text.size() >= 3 && right_form.puzzles.count(right_type) && - form_by_text_.count(left_form.text + right_form.text)) { + form_by_text_.count(left_form.text + right_form.text) && + !(right_type == kWhiteBottom && + right_form.puzzles[right_type].size() > 3)) { for (size_t left_hint_id : left_form.puzzles[left_type]) { Form& left_hint = forms_[left_hint_id]; for (size_t right_hint_id : right_form.puzzles[right_type]) { -- cgit 1.4.1