From b2508b217db420ac57eddf15f8a38074e387a0db Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 3 Feb 2023 11:20:04 -0500 Subject: If a top clue works as middle or vice versa, it is expanded to both --- lingo.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'lingo.cpp') diff --git a/lingo.cpp b/lingo.cpp index 6ba60a9..e56fa26 100644 --- a/lingo.cpp +++ b/lingo.cpp @@ -624,6 +624,8 @@ private: std::cout << "Solution decided: " << solution.getText() << std::endl; + std::array, kHeightCount> chosenHints; + bool made_puzzle = false; for (int i=0; i<10; i++) { @@ -636,12 +638,12 @@ private: if (colour.has_value()) { if (*colour == kOrange) { - msg_stream << COLOUR_EMOTES[*colour] << " " << orange_clue << std::endl; + chosenHints[i] = orange_clue; admissible &= (verbly::form::text == orange_solution); } else { verbly::filter questionFilter = makeHintFilter(solution, height, *colour, kTowardQuestion); verbly::form questionPart = database_->forms(questionFilter && cleanFilter && wordFilter).first(); - msg_stream << COLOUR_EMOTES[*colour] << " " << questionPart.getText() << std::endl; + chosenHints[i] = questionPart.getText(); if (isClueTrivial(height, *colour, questionPart, solution)) { @@ -651,8 +653,6 @@ private: admissible &= makeHintFilter(questionPart, height, *colour, kTowardSolution); } - } else { - msg_stream << NONE_EMOTE << std::endl; } } @@ -662,6 +662,47 @@ private: continue; } + if (parts[static_cast(kTop)].has_value() + && !parts[static_cast(kMiddle)].has_value() + && filters.count({kMiddle, *parts[static_cast(kTop)]})) + { + verbly::filter questionFilter = + makeHintFilter(solution, kMiddle, *parts[static_cast(kTop)], kTowardQuestion) + && (verbly::form::text == *chosenHints[static_cast(kTop)]); + if (!database_->forms(questionFilter).all().empty()) + { + std::cout << "Expanding top to middle" << std::endl; + parts[static_cast(kMiddle)] = parts[static_cast(kTop)]; + chosenHints[static_cast(kMiddle)] = chosenHints[static_cast(kTop)]; + } + } else if (!parts[static_cast(kTop)].has_value() + && parts[static_cast(kMiddle)].has_value() + && filters.count({kTop, *parts[static_cast(kMiddle)]})) + { + verbly::filter questionFilter = + makeHintFilter(solution, kTop, *parts[static_cast(kMiddle)], kTowardQuestion) + && (verbly::form::text == *chosenHints[static_cast(kMiddle)]); + if (!database_->forms(questionFilter).all().empty()) + { + std::cout << "Expanding middle to top" << std::endl; + parts[static_cast(kTop)] = parts[static_cast(kMiddle)]; + chosenHints[static_cast(kTop)] = chosenHints[static_cast(kMiddle)]; + } + } + + for (int i=0; i(kHeightCount); i++) + { + Height height = static_cast(i); + std::optional& colour = parts[i]; + std::optional& hint = chosenHints[i]; + if (colour.has_value() && hint.has_value()) + { + msg_stream << COLOUR_EMOTES[*colour] << " " << *hint << std::endl; + } else { + msg_stream << NONE_EMOTE << std::endl; + } + } + auto byspace = hatkirby::split>(solution.getText(), " "); std::list lens; for (const std::string& wordpart : byspace) -- cgit 1.4.1