From e24eb1a308928152ad35e3efa8f4dc7640e8652e Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 9 Dec 2022 15:03:53 -0500 Subject: Reduced possible hint combinations fixes #5 refs #7 --- lingo.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/lingo.cpp b/lingo.cpp index c6f9427..30b46ab 100644 --- a/lingo.cpp +++ b/lingo.cpp @@ -272,6 +272,19 @@ private: {kBottom, kBlue}, }; + std::set> expensive_hints = { + {kTop, kPurple}, + {kMiddle, kPurple}, + }; + + std::set> moderate_hints = { + {kTop, kRed}, + {kTop, kBlue}, + {kMiddle, kRed}, + {kMiddle, kBlue}, + {kBottom, kBlack}, + }; + verbly::filter wordFilter = (verbly::form::proper == false); verbly::filter cleanFilter = @@ -285,13 +298,31 @@ private: try { int hints = 0; + int non_purple_uses = 0; + int expensive_uses = 0; + int moderate_uses = 0; std::array, kHeightCount> parts; for (int height = 0; height < static_cast(kHeightCount); height++) { if (std::bernoulli_distribution(0.5)(rng_)) { int colour = std::uniform_int_distribution(0, static_cast(kColourCount)-1)(rng_); - if (filters.count({static_cast(height), static_cast(colour)})) { + auto combo = std::make_tuple(static_cast(height), static_cast(colour)); + if (filters.count(combo)) { parts[static_cast(height)] = static_cast(colour); + hints++; + if (colour != kPurple) + { + non_purple_uses++; + } + if (expensive_hints.count(combo)) + { + expensive_uses++; + } + if (moderate_hints.count(combo)) + { + moderate_uses++; + } + std::cout << COLOUR_EMOJIS[colour]; } else { std::cout << "▪️"; @@ -302,7 +333,18 @@ private: } std::cout << std::endl; - if (hints < 1) { + if (non_purple_uses < 1) + { + std::cout << "No hints (or only purple hints)." << std::endl; + continue; + } + if (expensive_uses > 1) + { + std::cout << "Too many expensive hints." << std::endl; + continue; + } + if (expensive_uses == 1 && moderate_uses > 0) { + std::cout << "Moderate hints can't be combined with an expensive hint." << std::endl; continue; } -- cgit 1.4.1