From 6ce1edf606a384f0722f15ab25caad899c271280 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 17 Feb 2023 11:13:56 -0500 Subject: allow_top_expansion When this flag is unset (which is in most cases), top clues must be distinct from middle clues. also we forgot to have the common word filter lol --- generator.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'generator.cpp') diff --git a/generator.cpp b/generator.cpp index c4dd76f..6b6c1be 100644 --- a/generator.cpp +++ b/generator.cpp @@ -5,7 +5,7 @@ #include #include -verbly::filter Generator::MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) +verbly::filter Generator::MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) const { switch (colour) { case kWhite: { @@ -304,7 +304,7 @@ bool Generator::GenerateSinglePanelImpl(std::string name, Height height, Colour if (questions.size() < 1) return false; verbly::form question = questions.front();// questions.at(std::uniform_int_distribution(0, questions.size())(rng_)); - if (IsClueTrivial(height, colour, question, solution)) { + if (IsClueTrivial(height, colour, question, solution, options)) { return false; } if (options.max_len_diff >= 0 && std::abs(static_cast(question.getText().size() - solution.getText().size())) > options.max_len_diff) { @@ -357,7 +357,7 @@ bool Generator::GenerateDoublePanelImpl(std::string name1, std::string name2, He //std::shuffle(questions.begin(), questions.end(), rng_); - if (IsClueTrivial(height, colour, questions[0], solution) || IsClueTrivial(height, colour, questions[1], solution)) { + if (IsClueTrivial(height, colour, questions[0], solution, options) || IsClueTrivial(height, colour, questions[1], solution, options)) { return false; } if (options.max_len_diff >= 0) { @@ -395,7 +395,8 @@ bool Generator::GenerateCohintedPanelsImpl(std::string name1, std::string name2, //std::shuffle(questions.begin(), questions.end(), rng_); - if (IsClueTrivial(height, colour, question, solutions[0]) || IsClueTrivial(height, colour, question, solutions[1])) { + if (IsClueTrivial(height, colour, question, solutions[0], options) + || IsClueTrivial(height, colour, question, solutions[1], options)) { return false; } if (options.max_len_diff >= 0) { @@ -428,7 +429,7 @@ bool Generator::GeneratePairedPanelsImpl(std::string name1, std::string name2, H if (questions.size() < 1) return false; verbly::form question = questions.front();// questions.at(std::uniform_int_distribution(0, questions.size())(rng_)); - if (IsClueTrivial(height, effectiveColour, question, solution)) { + if (IsClueTrivial(height, effectiveColour, question, solution, options)) { return false; } @@ -506,7 +507,7 @@ bool Generator::GeneratePanelStackImpl(std::string top_name, Colour top_colour, if (questions.empty()) return false; top_hint = questions.front().getText(); - if (IsClueTrivial(kTop, top_colour, questions.front(), solution)) { + if (IsClueTrivial(kTop, top_colour, questions.front(), solution, options)) { return false; } } @@ -517,7 +518,7 @@ bool Generator::GeneratePanelStackImpl(std::string top_name, Colour top_colour, if (questions.empty()) return false; middle_hint = questions.front().getText(); - if (IsClueTrivial(kMiddle, middle_colour, questions.front(), solution)) { + if (IsClueTrivial(kMiddle, middle_colour, questions.front(), solution, options)) { return false; } } @@ -528,7 +529,7 @@ bool Generator::GeneratePanelStackImpl(std::string top_name, Colour top_colour, if (questions.empty()) return false; bottom_hint = questions.front().getText(); - if (IsClueTrivial(kBottom, bottom_colour, questions.front(), solution)) { + if (IsClueTrivial(kBottom, bottom_colour, questions.front(), solution, options)) { return false; } } @@ -708,6 +709,7 @@ verbly::filter Generator::GetWordFilter(FilterDirection dir, GenerateOptions opt wordFilter &= (verbly::form::complexity == 2); } else { wordFilter &= (verbly::form::complexity == 1); + wordFilter &= (verbly::form::frequency > 2000000); } } else { wordFilter &= ((verbly::form::complexity > 1) || (verbly::form::frequency > 2000000)); @@ -720,8 +722,15 @@ bool isDigitWrapper(unsigned char ch) { return std::isdigit(ch); } -bool Generator::IsClueTrivial(Height height, Colour colour, const verbly::form& clue, const verbly::form& solution) const +bool Generator::IsClueTrivial(Height height, Colour colour, const verbly::form& clue, const verbly::form& solution, GenerateOptions options) const { + if (!options.allow_top_expansion && height == kTop) { + verbly::filter questionFilter = MakeHintFilter(solution, kMiddle, colour, kTowardQuestion) && clue; + if (!database_->forms(questionFilter).all().empty()) { + return true; + } + } + if (height == kTop && colour == kWhite) { return !database_->forms((verbly::filter)clue && (verbly::word::synonyms %= solution)).all().empty(); -- cgit 1.4.1