summary refs log tree commit diff stats
path: root/lingo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lingo.cpp')
-rw-r--r--lingo.cpp46
1 files 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:
272 {kBottom, kBlue}, 272 {kBottom, kBlue},
273 }; 273 };
274 274
275 std::set<std::tuple<Height, Colour>> expensive_hints = {
276 {kTop, kPurple},
277 {kMiddle, kPurple},
278 };
279
280 std::set<std::tuple<Height, Colour>> moderate_hints = {
281 {kTop, kRed},
282 {kTop, kBlue},
283 {kMiddle, kRed},
284 {kMiddle, kBlue},
285 {kBottom, kBlack},
286 };
287
275 verbly::filter wordFilter = (verbly::form::proper == false); 288 verbly::filter wordFilter = (verbly::form::proper == false);
276 289
277 verbly::filter cleanFilter = 290 verbly::filter cleanFilter =
@@ -285,13 +298,31 @@ private:
285 try 298 try
286 { 299 {
287 int hints = 0; 300 int hints = 0;
301 int non_purple_uses = 0;
302 int expensive_uses = 0;
303 int moderate_uses = 0;
288 std::array<std::optional<Colour>, kHeightCount> parts; 304 std::array<std::optional<Colour>, kHeightCount> parts;
289 for (int height = 0; height < static_cast<int>(kHeightCount); height++) { 305 for (int height = 0; height < static_cast<int>(kHeightCount); height++) {
290 if (std::bernoulli_distribution(0.5)(rng_)) { 306 if (std::bernoulli_distribution(0.5)(rng_)) {
291 int colour = std::uniform_int_distribution<int>(0, static_cast<int>(kColourCount)-1)(rng_); 307 int colour = std::uniform_int_distribution<int>(0, static_cast<int>(kColourCount)-1)(rng_);
292 if (filters.count({static_cast<Height>(height), static_cast<Colour>(colour)})) { 308 auto combo = std::make_tuple<Height, Colour>(static_cast<Height>(height), static_cast<Colour>(colour));
309 if (filters.count(combo)) {
293 parts[static_cast<Height>(height)] = static_cast<Colour>(colour); 310 parts[static_cast<Height>(height)] = static_cast<Colour>(colour);
311
294 hints++; 312 hints++;
313 if (colour != kPurple)
314 {
315 non_purple_uses++;
316 }
317 if (expensive_hints.count(combo))
318 {
319 expensive_uses++;
320 }
321 if (moderate_hints.count(combo))
322 {
323 moderate_uses++;
324 }
325
295 std::cout << COLOUR_EMOJIS[colour]; 326 std::cout << COLOUR_EMOJIS[colour];
296 } else { 327 } else {
297 std::cout << "▪️"; 328 std::cout << "▪️";
@@ -302,7 +333,18 @@ private:
302 } 333 }
303 std::cout << std::endl; 334 std::cout << std::endl;
304 335
305 if (hints < 1) { 336 if (non_purple_uses < 1)
337 {
338 std::cout << "No hints (or only purple hints)." << std::endl;
339 continue;
340 }
341 if (expensive_uses > 1)
342 {
343 std::cout << "Too many expensive hints." << std::endl;
344 continue;
345 }
346 if (expensive_uses == 1 && moderate_uses > 0) {
347 std::cout << "Moderate hints can't be combined with an expensive hint." << std::endl;
306 continue; 348 continue;
307 } 349 }
308 350