diff options
| -rw-r--r-- | yandere.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
| diff --git a/yandere.cpp b/yandere.cpp index 635b605..3cb5efa 100644 --- a/yandere.cpp +++ b/yandere.cpp | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | #include <yaml-cpp/yaml.h> | 1 | #include <yaml-cpp/yaml.h> |
| 2 | #include <iostream> | 2 | #include <iostream> |
| 3 | #include <cstdlib> | 3 | #include <random> |
| 4 | #include <ctime> | ||
| 5 | #include <sstream> | 4 | #include <sstream> |
| 6 | #include <fstream> | 5 | #include <fstream> |
| 7 | #include <twitter.h> | 6 | #include <twitter.h> |
| @@ -52,9 +51,6 @@ Container split(std::string input, std::string delimiter) | |||
| 52 | 51 | ||
| 53 | int main(int argc, char** argv) | 52 | int main(int argc, char** argv) |
| 54 | { | 53 | { |
| 55 | srand(time(NULL)); | ||
| 56 | rand(); rand(); rand(); rand(); | ||
| 57 | |||
| 58 | YAML::Node config = YAML::LoadFile("config.yml"); | 54 | YAML::Node config = YAML::LoadFile("config.yml"); |
| 59 | 55 | ||
| 60 | twitter::auth auth; | 56 | twitter::auth auth; |
| @@ -96,7 +92,10 @@ int main(int argc, char** argv) | |||
| 96 | } | 92 | } |
| 97 | } | 93 | } |
| 98 | } | 94 | } |
| 99 | 95 | ||
| 96 | std::random_device random_device; | ||
| 97 | std::mt19937 random_engine{random_device()}; | ||
| 98 | |||
| 100 | for (;;) | 99 | for (;;) |
| 101 | { | 100 | { |
| 102 | std::cout << "Generating tweet" << std::endl; | 101 | std::cout << "Generating tweet" << std::endl; |
| @@ -131,8 +130,10 @@ int main(int argc, char** argv) | |||
| 131 | { | 130 | { |
| 132 | result = "\n"; | 131 | result = "\n"; |
| 133 | } else { | 132 | } else { |
| 134 | auto group = groups[canontkn]; | 133 | auto& group = groups[canontkn]; |
| 135 | result = group[rand() % group.size()]; | 134 | std::uniform_int_distribution<int> dist(0, group.size() - 1); |
| 135 | |||
| 136 | result = group[dist(random_engine)]; | ||
| 136 | } | 137 | } |
| 137 | 138 | ||
| 138 | if (!eqvarname.empty()) | 139 | if (!eqvarname.empty()) |
