summary refs log tree commit diff stats
path: root/lingo.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-02-03 11:20:04 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2023-02-03 11:20:04 -0500
commitb2508b217db420ac57eddf15f8a38074e387a0db (patch)
tree6a962305307a2f4b74c11999b1eab7d1b5af9e40 /lingo.cpp
parenta8d77b2e38fe5a26948064d980cdb43ace089e4c (diff)
downloadlingo-b2508b217db420ac57eddf15f8a38074e387a0db.tar.gz
lingo-b2508b217db420ac57eddf15f8a38074e387a0db.tar.bz2
lingo-b2508b217db420ac57eddf15f8a38074e387a0db.zip
If a top clue works as middle or vice versa, it is expanded to both
Diffstat (limited to 'lingo.cpp')
-rw-r--r--lingo.cpp49
1 files changed, 45 insertions, 4 deletions
diff --git a/lingo.cpp b/lingo.cpp index 6ba60a9..e56fa26 100644 --- a/lingo.cpp +++ b/lingo.cpp
@@ -624,6 +624,8 @@ private:
624 624
625 std::cout << "Solution decided: " << solution.getText() << std::endl; 625 std::cout << "Solution decided: " << solution.getText() << std::endl;
626 626
627 std::array<std::optional<std::string>, kHeightCount> chosenHints;
628
627 bool made_puzzle = false; 629 bool made_puzzle = false;
628 for (int i=0; i<10; i++) 630 for (int i=0; i<10; i++)
629 { 631 {
@@ -636,12 +638,12 @@ private:
636 if (colour.has_value()) { 638 if (colour.has_value()) {
637 if (*colour == kOrange) 639 if (*colour == kOrange)
638 { 640 {
639 msg_stream << COLOUR_EMOTES[*colour] << " " << orange_clue << std::endl; 641 chosenHints[i] = orange_clue;
640 admissible &= (verbly::form::text == orange_solution); 642 admissible &= (verbly::form::text == orange_solution);
641 } else { 643 } else {
642 verbly::filter questionFilter = makeHintFilter(solution, height, *colour, kTowardQuestion); 644 verbly::filter questionFilter = makeHintFilter(solution, height, *colour, kTowardQuestion);
643 verbly::form questionPart = database_->forms(questionFilter && cleanFilter && wordFilter).first(); 645 verbly::form questionPart = database_->forms(questionFilter && cleanFilter && wordFilter).first();
644 msg_stream << COLOUR_EMOTES[*colour] << " " << questionPart.getText() << std::endl; 646 chosenHints[i] = questionPart.getText();
645 647
646 if (isClueTrivial(height, *colour, questionPart, solution)) 648 if (isClueTrivial(height, *colour, questionPart, solution))
647 { 649 {
@@ -651,8 +653,6 @@ private:
651 653
652 admissible &= makeHintFilter(questionPart, height, *colour, kTowardSolution); 654 admissible &= makeHintFilter(questionPart, height, *colour, kTowardSolution);
653 } 655 }
654 } else {
655 msg_stream << NONE_EMOTE << std::endl;
656 } 656 }
657 } 657 }
658 658
@@ -662,6 +662,47 @@ private:
662 continue; 662 continue;
663 } 663 }
664 664
665 if (parts[static_cast<int>(kTop)].has_value()
666 && !parts[static_cast<int>(kMiddle)].has_value()
667 && filters.count({kMiddle, *parts[static_cast<int>(kTop)]}))
668 {
669 verbly::filter questionFilter =
670 makeHintFilter(solution, kMiddle, *parts[static_cast<int>(kTop)], kTowardQuestion)
671 && (verbly::form::text == *chosenHints[static_cast<int>(kTop)]);
672 if (!database_->forms(questionFilter).all().empty())
673 {
674 std::cout << "Expanding top to middle" << std::endl;
675 parts[static_cast<int>(kMiddle)] = parts[static_cast<int>(kTop)];
676 chosenHints[static_cast<int>(kMiddle)] = chosenHints[static_cast<int>(kTop)];
677 }
678 } else if (!parts[static_cast<int>(kTop)].has_value()
679 && parts[static_cast<int>(kMiddle)].has_value()
680 && filters.count({kTop, *parts[static_cast<int>(kMiddle)]}))
681 {
682 verbly::filter questionFilter =
683 makeHintFilter(solution, kTop, *parts[static_cast<int>(kMiddle)], kTowardQuestion)
684 && (verbly::form::text == *chosenHints[static_cast<int>(kMiddle)]);
685 if (!database_->forms(questionFilter).all().empty())
686 {
687 std::cout << "Expanding middle to top" << std::endl;
688 parts[static_cast<int>(kTop)] = parts[static_cast<int>(kMiddle)];
689 chosenHints[static_cast<int>(kTop)] = chosenHints[static_cast<int>(kMiddle)];
690 }
691 }
692
693 for (int i=0; i<static_cast<int>(kHeightCount); i++)
694 {
695 Height height = static_cast<Height>(i);
696 std::optional<Colour>& colour = parts[i];
697 std::optional<std::string>& hint = chosenHints[i];
698 if (colour.has_value() && hint.has_value())
699 {
700 msg_stream << COLOUR_EMOTES[*colour] << " " << *hint << std::endl;
701 } else {
702 msg_stream << NONE_EMOTE << std::endl;
703 }
704 }
705
665 auto byspace = hatkirby::split<std::list<std::string>>(solution.getText(), " "); 706 auto byspace = hatkirby::split<std::list<std::string>>(solution.getText(), " ");
666 std::list<std::string> lens; 707 std::list<std::string> lens;
667 for (const std::string& wordpart : byspace) 708 for (const std::string& wordpart : byspace)