diff options
Diffstat (limited to 'dialogue.cpp')
-rw-r--r-- | dialogue.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
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**) | |||
81 | 81 | ||
82 | for (;;) | 82 | for (;;) |
83 | { | 83 | { |
84 | std::set<speaker_id> pastSpeakers; | ||
85 | |||
86 | |||
84 | speaker_id curSpeaker = allSpeakers.next(); | 87 | speaker_id curSpeaker = allSpeakers.next(); |
85 | 88 | ||
86 | std::ostringstream theEnd; | 89 | std::ostringstream theEnd; |
90 | int maxLines = rand() % 4 + 3; | ||
87 | 91 | ||
88 | for (int i = 0; i < 5; i++) | 92 | for (int i = 0; i < maxLines; i++) |
89 | { | 93 | { |
90 | speaker_data& curSd = speakerData.at(curSpeaker); | 94 | pastSpeakers.insert(curSpeaker); |
91 | 95 | ||
92 | //std::ostringstream thisLine; | 96 | speaker_data& curSd = speakerData.at(curSpeaker); |
93 | 97 | ||
94 | if (curSd.name != "") | 98 | if (curSd.name != "") |
95 | { | 99 | { |
96 | theEnd << curSd.name << ": "; | 100 | theEnd << curSd.name << ": "; |
97 | } | 101 | } |
98 | 102 | ||
99 | theEnd << curSd.chain.randomSentence(1); | 103 | std::string curLine = curSd.chain.randomSentence(rand() % 30 + 1); |
100 | 104 | ||
101 | /*if (i > 0 && theEnd.str().length() + thisLine.str().length() > 280) | 105 | if (curSd.name == "" && |
106 | curLine[0] != '[' && | ||
107 | curLine[0] != '(' && | ||
108 | curLine[0] != '*') | ||
102 | { | 109 | { |
103 | break; | 110 | theEnd << "[" << curLine << "]"; |
104 | }*/ | 111 | } else { |
112 | theEnd << curLine; | ||
113 | } | ||
105 | 114 | ||
106 | theEnd << std::endl; | 115 | theEnd << std::endl; |
107 | //theEnd << thisLine.str(); | ||
108 | 116 | ||
109 | curSpeaker = curSd.nextSpeaker.next(); | 117 | speaker_id repeatSpeaker = *std::next(std::begin(pastSpeakers), rand() % pastSpeakers.size()); |
118 | if (repeatSpeaker != curSpeaker && | ||
119 | rand() % 3 == 0) | ||
120 | { | ||
121 | curSpeaker = repeatSpeaker; | ||
122 | } else { | ||
123 | curSpeaker = curSd.nextSpeaker.next(); | ||
124 | } | ||
110 | } | 125 | } |
111 | 126 | ||
112 | std::string output = theEnd.str(); | 127 | std::string output = theEnd.str(); |