summary refs log tree commit diff stats
path: root/dialogue.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2019-02-27 22:55:10 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2019-02-27 22:55:10 -0500
commit3fbe970f83eabcc7dd223231068a6e25ded2f654 (patch)
tree1c6a3f00072d617737ce00afc7e2f123199ce1f9 /dialogue.cpp
parent2b152d09881559a0330b3ff923e03e715777c6c3 (diff)
downloadaspartame-3fbe970f83eabcc7dd223231068a6e25ded2f654.tar.gz
aspartame-3fbe970f83eabcc7dd223231068a6e25ded2f654.tar.bz2
aspartame-3fbe970f83eabcc7dd223231068a6e25ded2f654.zip
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.
Diffstat (limited to 'dialogue.cpp')
-rw-r--r--dialogue.cpp33
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();