From 3fbe970f83eabcc7dd223231068a6e25ded2f654 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 27 Feb 2019 22:55:10 -0500 Subject: Some enhancements Variable lines and characters per line. Action lines are surrounded in brackets if they are not already delimited. Sometimes a prior speaker will be reused instead of using the distribution. --- dialogue.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'dialogue.cpp') diff --git a/dialogue.cpp b/dialogue.cpp index dd34ee5..0e0c7bc 100644 --- a/dialogue.cpp +++ b/dialogue.cpp @@ -81,32 +81,47 @@ int main(int, char**) for (;;) { + std::set pastSpeakers; + + speaker_id curSpeaker = allSpeakers.next(); std::ostringstream theEnd; + int maxLines = rand() % 4 + 3; - for (int i = 0; i < 5; i++) + for (int i = 0; i < maxLines; i++) { - speaker_data& curSd = speakerData.at(curSpeaker); + pastSpeakers.insert(curSpeaker); - //std::ostringstream thisLine; + speaker_data& curSd = speakerData.at(curSpeaker); if (curSd.name != "") { theEnd << curSd.name << ": "; } - theEnd << curSd.chain.randomSentence(1); + std::string curLine = curSd.chain.randomSentence(rand() % 30 + 1); - /*if (i > 0 && theEnd.str().length() + thisLine.str().length() > 280) + if (curSd.name == "" && + curLine[0] != '[' && + curLine[0] != '(' && + curLine[0] != '*') { - break; - }*/ + theEnd << "[" << curLine << "]"; + } else { + theEnd << curLine; + } theEnd << std::endl; - //theEnd << thisLine.str(); - curSpeaker = curSd.nextSpeaker.next(); + speaker_id repeatSpeaker = *std::next(std::begin(pastSpeakers), rand() % pastSpeakers.size()); + if (repeatSpeaker != curSpeaker && + rand() % 3 == 0) + { + curSpeaker = repeatSpeaker; + } else { + curSpeaker = curSd.nextSpeaker.next(); + } } std::string output = theEnd.str(); -- cgit 1.4.1