From 1e34d9d675a50f1ccc1a43d3c2fed94ba3e5351b Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 12 Dec 2023 14:48:42 -0500 Subject: Removed some trivial puzzles --- generator/CMakeLists.txt | 2 +- generator/generator.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/generator/CMakeLists.txt b/generator/CMakeLists.txt index 3b66720..fb5dc3c 100644 --- a/generator/CMakeLists.txt +++ b/generator/CMakeLists.txt @@ -3,7 +3,7 @@ project (generator) add_subdirectory(vendor/fmt) -include_directories(../vendor/hkutil vendor/fmt/include) +include_directories(vendor/hkutil vendor/fmt/include) add_executable(generator generator.cpp main.cpp) set_property(TARGET generator PROPERTY CXX_STANDARD 17) diff --git a/generator/generator.cpp b/generator/generator.cpp index 49018c8..0639492 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -374,6 +374,10 @@ void generator::run() { for (size_t f_id2 : all_forms) { if (f_id1 != f_id2) { Form& form = forms_.at(f_id1); + Form& form2 = forms_.at(f_id2); + if (form.anagram_set_id == form2.anagram_set_id) { + continue; + } form.puzzles[kYellowTop].insert(f_id2); } } @@ -427,6 +431,9 @@ void generator::run() { for (size_t f_id1 : pronunciation.form_ids) { for (size_t f_id2 : all_forms) { Form& form = forms_.at(f_id1); + if (form.reverse_form_id == f_id2) { + continue; + } form.puzzles[kBlackTop].insert(f_id2); } } @@ -573,6 +580,12 @@ void generator::run() { for (size_t mero_form_id : merophone.form_ids) { Form& mero_form = forms_.at(mero_form_id); + if (holo_form.text.find(mero_form.text) != + std::string::npos) { + // We don't want top puzzles that are also middle puzzles. + continue; + } + bool word_overlap = false; for (size_t holo_word_id : holo_form.word_ids) { for (size_t mero_word_id : mero_form.word_ids) { -- cgit 1.4.1 From c7e2188850370689a2467d6241097250d325bd0f Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 12 Dec 2023 18:26:27 -0500 Subject: Generate wanderlust and paintings --- generator/generator.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++++- generator/generator.h | 3 ++ 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/generator/generator.cpp b/generator/generator.cpp index 0639492..cd13051 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -857,6 +857,25 @@ void generator::run() { } } + // Orange addition + std::vector orange_addition; + { + hatkirby::progress ppgs("Generating orange addition puzzles...", + wanderlust_.size()); + + for (const auto& [cipher, form_id] : wanderlust_) { + for (const auto& [cipher2, form_id2] : wanderlust_) { + if (cipher2 >= cipher) { + break; + } + if (wanderlust_.count(cipher - cipher2)) { + orange_addition.push_back(fmt::format( + "[{},{},{}]", form_id2, wanderlust_[cipher - cipher2], form_id)); + } + } + } + } + // Count up all of the generated puzzles. int total_puzzles = 0; int reusable_words = 0; @@ -916,6 +935,27 @@ void generator::run() { std::ofstream output_file(outputPath_); output_file << "extends Node\n\nvar forms = [" << hatkirby::implode(form_entry, ",") << "]" << std::endl; + + std::vector painting_entries; + { + std::list paintings(readFile(datadirPath_ / "paintings.txt")); + for (const std::string& line : paintings) { + auto parts = hatkirby::split>(line, ","); + painting_entries.push_back( + fmt::format("[\"{}\",\"{}\"]", parts[0], parts[1])); + } + } + output_file << "var paintings = [" << hatkirby::implode(painting_entries, ",") + << "]" << std::endl; + + std::vector cipher_lines; + for (const auto& [cipher, form_id] : wanderlust_) { + cipher_lines.push_back(std::to_string(form_id)); + } + output_file << "var wanderlust = [" << hatkirby::implode(cipher_lines, ",") + << "]" << std::endl; + output_file << "var addition = [" << hatkirby::implode(orange_addition, ",") + << "]" << std::endl; } size_t generator::LookupOrCreatePronunciation(const std::string& phonemes) { @@ -996,7 +1036,59 @@ size_t generator::LookupOrCreateForm(const std::string& word) { } else { size_t form_id = forms_.size(); form_by_text_[word] = form_id; - forms_.push_back({.id = form_id, .text = word}); + std::optional ciphered; + if (std::all_of(word.begin(), word.end(), [](char ch) { + return ch == 'w' || ch == 'a' || ch == 'n' || ch == 'd' || + ch == 'e' || ch == 'r' || ch == 'l' || ch == 'u' || + ch == 's' || ch == 't'; + })) { + ciphered = 0; + std::string to_cipher = word; + while (!to_cipher.empty()) { + *ciphered *= 10; + switch (to_cipher.back()) { + case 'w': { + *ciphered += 1; + break; + } + case 'a': { + *ciphered += 2; + break; + } + case 'n': { + *ciphered += 3; + break; + } + case 'd': { + *ciphered += 4; + break; + } + case 'e': { + *ciphered += 5; + break; + } + case 'r': { + *ciphered += 6; + break; + } + case 'l': { + *ciphered += 7; + break; + } + case 'u': { + *ciphered += 8; + break; + } + case 's': { + *ciphered += 9; + break; + } + } + to_cipher.pop_back(); + } + wanderlust_[*ciphered] = form_id; + } + forms_.push_back({.id = form_id, .text = word, .ciphered = ciphered}); std::string sortedText = word; std::sort(sortedText.begin(), sortedText.end()); diff --git a/generator/generator.h b/generator/generator.h index f89bab9..ea30bd9 100644 --- a/generator/generator.h +++ b/generator/generator.h @@ -92,6 +92,7 @@ class generator { std::vector pronunciation_ids; std::optional anagram_set_id; std::optional reverse_form_id; + std::optional ciphered; std::unordered_map> puzzles; }; @@ -124,6 +125,8 @@ class generator { std::vector> synsets_; std::unordered_map synset_by_wnid_; + + std::map wanderlust_; }; #endif /* end of include guard: GENERATOR_H_D5C6A724 */ \ No newline at end of file -- cgit 1.4.1