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.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/lingo.cpp b/lingo.cpp index a963ca8..137d6e7 100644 --- a/lingo.cpp +++ b/lingo.cpp
@@ -89,6 +89,9 @@ verbly::filter makeHintFilter(verbly::filter subfilter, Height height, Colour co
89 verbly::filter::comparison::field_does_not_equal, 89 verbly::filter::comparison::field_does_not_equal,
90 verbly::form::id))))); 90 verbly::form::id)))));
91 } 91 }
92 case kMiddle: {
93 return subfilter;
94 }
92 default: break; // Not supported yet. 95 default: break; // Not supported yet.
93 } 96 }
94 break; 97 break;
@@ -525,6 +528,8 @@ private:
525 {kMiddle, kPurple}, 528 {kMiddle, kPurple},
526 {kMiddle, kGreen}, 529 {kMiddle, kGreen},
527 {kMiddle, kOrange}, 530 {kMiddle, kOrange},
531 {kMiddle, kWhite},
532 {kMiddle, kBlack},
528 {kBottom, kWhite}, 533 {kBottom, kWhite},
529 {kBottom, kBlack}, 534 {kBottom, kBlack},
530 {kBottom, kRed}, 535 {kBottom, kRed},
@@ -692,7 +697,25 @@ private:
692 } else { 697 } else {
693 verbly::filter questionFilter = makeHintFilter(solution, height, *colour, kTowardQuestion); 698 verbly::filter questionFilter = makeHintFilter(solution, height, *colour, kTowardQuestion);
694 verbly::form questionPart = database_->forms(questionFilter && cleanFilter && wordFilter).first(); 699 verbly::form questionPart = database_->forms(questionFilter && cleanFilter && wordFilter).first();
695 chosenHints[i] = questionPart.getText(); 700
701 if (height == kMiddle && (*colour == kWhite || *colour == kBlack)) {
702 std::string question = questionPart.getText();
703 int ceiling = (hints == 1) ? question.size()/3 : question.size()*2/3;
704 int numToObscure = (ceiling > 0) ? std::uniform_int_distribution<int>(1, ceiling)(rng_) : 1;
705 std::vector<int> indicies(question.size());
706 std::iota(indicies.begin(), indicies.end(), 0);
707 std::shuffle(indicies.begin(), indicies.end(), rng_);
708
709 for (int i=0; i<numToObscure; i++) {
710 if (question[indicies[i]] != ' ' && question[indicies[i]] != '-') {
711 question[indicies[i]] = '?';
712 }
713 }
714
715 chosenHints[i] = question;
716 } else {
717 chosenHints[i] = questionPart.getText();
718 }
696 719
697 if (isClueTrivial(height, *colour, questionPart, solution)) 720 if (isClueTrivial(height, *colour, questionPart, solution))
698 { 721 {