From 480463aac0ca53ea56d6017724632fee32146724 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 15 Feb 2023 12:03:43 -0500 Subject: Added hint obscuring (and also middle white/black) fixes #17 --- lingo.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lingo.cpp b/lingo.cpp index a963ca8..137d6e7 100644 --- a/lingo.cpp +++ b/lingo.cpp @@ -89,6 +89,9 @@ verbly::filter makeHintFilter(verbly::filter subfilter, Height height, Colour co verbly::filter::comparison::field_does_not_equal, verbly::form::id))))); } + case kMiddle: { + return subfilter; + } default: break; // Not supported yet. } break; @@ -525,6 +528,8 @@ private: {kMiddle, kPurple}, {kMiddle, kGreen}, {kMiddle, kOrange}, + {kMiddle, kWhite}, + {kMiddle, kBlack}, {kBottom, kWhite}, {kBottom, kBlack}, {kBottom, kRed}, @@ -692,7 +697,25 @@ private: } else { verbly::filter questionFilter = makeHintFilter(solution, height, *colour, kTowardQuestion); verbly::form questionPart = database_->forms(questionFilter && cleanFilter && wordFilter).first(); - chosenHints[i] = questionPart.getText(); + + if (height == kMiddle && (*colour == kWhite || *colour == kBlack)) { + std::string question = questionPart.getText(); + int ceiling = (hints == 1) ? question.size()/3 : question.size()*2/3; + int numToObscure = (ceiling > 0) ? std::uniform_int_distribution(1, ceiling)(rng_) : 1; + std::vector indicies(question.size()); + std::iota(indicies.begin(), indicies.end(), 0); + std::shuffle(indicies.begin(), indicies.end(), rng_); + + for (int i=0; i