about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-09-08 17:43:05 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-09-08 17:43:05 -0400
commitfa26336b8b792a82349e89bcbf7b2c7833f7f420 (patch)
tree252cd69d3b4623e052692f97a2f1e9ac4fada7ee
parent19bca18bff00dd8757a56be955875fc4bc6756df (diff)
downloadyandere-fa26336b8b792a82349e89bcbf7b2c7833f7f420.tar.gz
yandere-fa26336b8b792a82349e89bcbf7b2c7833f7f420.tar.bz2
yandere-fa26336b8b792a82349e89bcbf7b2c7833f7f420.zip
Improved randomization
-rw-r--r--yandere.cpp17
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
53int main(int argc, char** argv) 52int 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())