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 +++++++++++++++++--------- generator.h | 5 +++-- main.cpp | 62 ++++++++++++++++++++++++++++++----------------------------- 3 files changed, 53 insertions(+), 41 deletions(-) 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(); diff --git a/generator.h b/generator.h index 1c7934e..7803004 100644 --- a/generator.h +++ b/generator.h @@ -56,6 +56,7 @@ struct GenerateOptions { std::string copy_hidden; // supported by single mid white bool force_two_words = false; bool must_be_broad = false; // the solution must also be gettable by bottom white/red/blue. supported by single and double + bool allow_top_expansion = false; // this disables the triviality check that top puzzles can't also apply to middle }; class Wanderlust { @@ -197,7 +198,7 @@ public: private: - verbly::filter MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction); + verbly::filter MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) const; bool GenerateSinglePanelImpl(std::string name, Height height, Colour colour, GenerateOptions options); @@ -215,7 +216,7 @@ private: verbly::filter GetWordFilter(FilterDirection direction, GenerateOptions options) const; - bool IsClueTrivial(Height height, Colour colour, const verbly::form& clue, const verbly::form& solution) const; + bool IsClueTrivial(Height height, Colour colour, const verbly::form& clue, const verbly::form& solution, GenerateOptions options = {}) const; unsigned int seed_; std::mt19937 rng_; diff --git a/main.cpp b/main.cpp index 3b6e8e1..3d53cb0 100644 --- a/main.cpp +++ b/main.cpp @@ -174,6 +174,8 @@ public: // The Observant // Knight/Night + // there are some .allow_top_expansion = true panels that don't do anything yet + // and some paired top/middle stacks that aren't implemented bc honestly who caressss gen_.GenerateSinglePanel("Panel_rat_tar", kMiddle, kBlack, {.palindrome = kRejectPalindrome}); gen_.GenerateSinglePanel("Panel_discover_recover", kMiddle, kPurple, {.max_len_diff = 1}); gen_.GenerateSinglePanel("Panel_deadend_deadened", kTop, kWhite, {.multiword = true}); @@ -181,9 +183,9 @@ public: gen_.GenerateSinglePanel("Panel_warner_corner", kTop, kPurple); gen_.GenerateSinglePanel("Panel_lies_lies", kMiddle, kWhite, {.obscure_hint = true, .max_answer_len = 20}); gen_.GeneratePairedPanels("Panel_night_knight", "Panel_knight_night", kMiddle, kBlue); - gen_.GenerateSinglePanel("Panel_bee_be", kMiddle, kRed); - gen_.GenerateSinglePanel("Panel_new_knew", kMiddle, kBlue, {.max_answer_len = 4}); - gen_.GenerateSinglePanel("Panel_fore_for", kMiddle, kRed); + gen_.GenerateSinglePanel("Panel_bee_be", kMiddle, kRed, {.allow_top_expansion = true}); + gen_.GenerateSinglePanel("Panel_new_knew", kMiddle, kBlue, {.max_answer_len = 4, .allow_top_expansion = true}); + gen_.GenerateSinglePanel("Panel_fore_for", kMiddle, kRed, {.allow_top_expansion = true}); gen_.GenerateCohintedPanels("Panel_trusted_trust", "Panel_trusted_rusted", kMiddle, kRed, {.save_for_later = true}); gen_.GenerateCohintedPanels("Panel_rust_trust", "Panel_rust_crust", kMiddle, kBlue, {.max_answer_len = 5, .save_for_later = true}); gen_.GenerateSinglePanel("Panel_encrusted_rust", kMiddle, kRed, {.save_for_later = true}); @@ -213,11 +215,11 @@ public: gen_.GenerateSinglePanel("Panel_locked_knocked", kMiddle, kPurple, {.max_answer_len = 5, .reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); gen_.GenerateSinglePanel("Panel_daughter_laughter", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); gen_.GenerateDoublePanel("Panel_move_love", "Panel_stove_love", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); - gen_.GenerateSinglePanel("Panel_scope_type", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); + gen_.GenerateSinglePanel("Panel_scope_type", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1, .allow_top_expansion = true}); gen_.GenerateSinglePanel("Panel_abyss_this", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); gen_.GenerateDoublePanel("Panel_sweat_great", "Panel_beat_great", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); - gen_.GenerateSinglePanel("Panel_alumni_hi", kTop, kPurple, {.reuse_solution = true, .unique_pool = "initiated"}); - gen_.GenerateSinglePanel("Panel_wrath_path", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1}); + gen_.GenerateSinglePanel("Panel_alumni_hi", kTop, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .allow_top_expansion = true}); + gen_.GenerateSinglePanel("Panel_wrath_path", kMiddle, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 1, .allow_top_expansion = true}); gen_.GenerateDoublePanel("Panel_knight_write", "Panel_byte_write", kTop, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 2}); gen_.GenerateSinglePanel("Panel_maim_same", kTop, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 0}); gen_.GenerateSinglePanel("Panel_bare_bear", kTop, kPurple, {.reuse_solution = true, .unique_pool = "initiated", .max_len_diff = 0}); @@ -304,24 +306,24 @@ public: gen_.GenerateOneRoadManyTurns("Panel_order_onepathmanyturns", "Panel_eon_one", "Panel_path_road", "Panel_any_many", "Panel_send_use_turns"); // Rhyme Rooms - gen_.GeneratePanelStack("Panel_ascend_rhyme", kPurple, "", {}, "Panel_ascend_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_double_rhyme", kPurple, "", {}, "Panel_double_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_blocked_rhyme", kPurple, "", {}, "Panel_blocked_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_rise_rhyme", kPurple, "", {}, "Panel_rise_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_crystal_rhyme", kPurple, "", {}, "Panel_crystal_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_creative_rhyme", kPurple, "", {}, "Panel_creative_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_child_rhyme", kPurple, "", {}, "Panel_child_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_hidden_rhyme", kPurple, "", {}, "Panel_hidden_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_word_rhyme", kPurple, "", {}, "Panel_word_whole", kBlue, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_silent_rhyme", kPurple, "", {}, "Panel_silent_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_bones_rhyme", kPurple, "", {}, "Panel_bones_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_sentence_rhyme", kPurple, "", {}, "Panel_sentence_whole", kBlue, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_dream_rhyme", kPurple, "", {}, "Panel_dream_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_mystery_rhyme", kPurple, "", {}, "Panel_mystery_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_jump_rhyme", kPurple, "", {}, "Panel_jump_syn", kWhite, {.unique_pool = "rhyme"}); - gen_.GeneratePanelStack("Panel_fall_rhyme", kPurple, "", {}, "Panel_fall_syn", kWhite, {.unique_pool = "rhyme"}); - //gen_.GeneratePanelStack("Panel_return_rhyme", kPurple, "", {}, "Panel_return_ant", kBlack, {.unique_pool = "rhyme"}); - //gen_.GeneratePanelStack("Panel_descend_rhyme", kPurple, "", {}, "Panel_descend_ant", kBlack, {.unique_pool = "rhyme"}); + gen_.GeneratePanelStack("Panel_ascend_rhyme", kPurple, "", {}, "Panel_ascend_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_double_rhyme", kPurple, "", {}, "Panel_double_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_blocked_rhyme", kPurple, "", {}, "Panel_blocked_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_rise_rhyme", kPurple, "", {}, "Panel_rise_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_crystal_rhyme", kPurple, "", {}, "Panel_crystal_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_creative_rhyme", kPurple, "", {}, "Panel_creative_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_child_rhyme", kPurple, "", {}, "Panel_child_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_hidden_rhyme", kPurple, "", {}, "Panel_hidden_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_word_rhyme", kPurple, "", {}, "Panel_word_whole", kBlue, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_silent_rhyme", kPurple, "", {}, "Panel_silent_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_bones_rhyme", kPurple, "", {}, "Panel_bones_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_sentence_rhyme", kPurple, "", {}, "Panel_sentence_whole", kBlue, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_dream_rhyme", kPurple, "", {}, "Panel_dream_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_mystery_rhyme", kPurple, "", {}, "Panel_mystery_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_jump_rhyme", kPurple, "", {}, "Panel_jump_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + gen_.GeneratePanelStack("Panel_fall_rhyme", kPurple, "", {}, "Panel_fall_syn", kWhite, {.unique_pool = "rhyme", .allow_top_expansion = true}); + //gen_.GeneratePanelStack("Panel_return_rhyme", kPurple, "", {}, "Panel_return_ant", kBlack, {.unique_pool = "rhyme", .allow_top_expansion = true}); + //gen_.GeneratePanelStack("Panel_descend_rhyme", kPurple, "", {}, "Panel_descend_ant", kBlack, {.unique_pool = "rhyme", .allow_top_expansion = true}); // ^ commenting those out for now because they take disproportionately long to generate currently gen_.GenerateSinglePanel("Panel_leap_leap", kMiddle, kWhite, {.obscure_hint = true}); @@ -405,11 +407,11 @@ public: // The Colorful - gen_.GenerateSinglePanel("Panel_begin_start", kBottom, kWhite, {.reuse_solution = true}); - gen_.GenerateSinglePanel("Panel_found_lost", kBottom, kBlack, {.reuse_solution = true}); - gen_.GenerateSinglePanel("Panel_loaf_crust", kBottom, kRed, {.reuse_solution = true}); + gen_.GenerateSinglePanel("Panel_begin_start", kBottom, kWhite, {.reuse_solution = true, .unique_pool = "traveled"}); + gen_.GenerateSinglePanel("Panel_found_lost", kBottom, kBlack, {.reuse_solution = true, .unique_pool = "agreeable"}); + gen_.GenerateSinglePanel("Panel_loaf_crust", kBottom, kRed, {.reuse_solution = true, .unique_pool = "bold"}); //Panel_eggs_breakfast: cream? butter! - gen_.GenerateSinglePanel("Panel_sun_sky", kBottom, kBlue, {.reuse_solution = true}); + gen_.GenerateSinglePanel("Panel_sun_sky", kBottom, kBlue, {.reuse_solution = true, .unique_pool = "undeterred"}); //Panel_teacher_substitute: spoon? fork! //Panel_walnuts_orange: letters? numbers! //Panel_path_i: walls? green! @@ -506,7 +508,7 @@ public: gen_.GenerateSinglePanel("Panel_red_top_2", kTop, kRed); gen_.GenerateSinglePanel("Panel_red_top_3", kTop, kRed); gen_.GenerateSinglePanel("Panel_red_top_4", kTop, kRed); - //gen_.GeneratePanelStack("Panel_red_top_5", kRed, "Panel_red_mid_2", kRed, "", {}); // slow + //gen_.GeneratePanelStack("Panel_red_top_5", kRed, "Panel_red_mid_2", kRed, "", {}, .allow_top_expansion = true); // slow gen_.GenerateSinglePanel("Panel_red_mid_1", kMiddle, kRed); gen_.GenerateSinglePanel("Panel_red_mid_3", kMiddle, kRed); gen_.GeneratePanelStack("", {}, "Panel_red_mid_4", kRed, "Panel_red_bot_4", kRed); @@ -518,7 +520,7 @@ public: // The Artistic gen_.GeneratePanelStack("Panel_blue_top_1", kBlue, "", {}, "Panel_red_bot_1", kRed); - gen_.GeneratePanelStack("", {}, "Panel_red_mid_2", kRed, "Panel_blue_bot_2", kBlue); + gen_.GeneratePanelStack("", {}, "Panel_red_mid_22", kRed, "Panel_blue_bot_2", kBlue); gen_.GeneratePanelStack("", {}, "Panel_blue_mid_3", kBlue, "Panel_red_bot_3", kRed); gen_.GeneratePanelStack("Panel_red_top_4", kRed, "Panel_blue_mid_4", kBlue, "", {}); gen_.GeneratePanelStack("Panel_yellow_top_5", kYellow, "", {}, "Panel_blue_bot_5", kBlue); -- cgit 1.4.1