Added randomization

This commit is contained in:
Trianta 2023-12-08 18:19:14 -06:00
parent d3f007b7f6
commit 485f1b2164
3 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,23 @@
#include "generator.hpp" #include "generator.hpp"
#include <cstdlib>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <random>
std::default_random_engine generator;
void InitializeGenerator(void)
{
generator.seed(std::random_device{}());
}
// Returns a newly generated number
int GenerateRandomNumber(int generationLimit)
{
int generatedNumber;
std::uniform_int_distribution<> distribution(0, generationLimit - 1);
generatedNumber = distribution(snakeplusplus::generator);
return generatedNumber;
}
void Trie::insert(const std::deque<char>& currentKGram) { void Trie::insert(const std::deque<char>& currentKGram) {
@ -84,7 +101,8 @@ void Generator::ReadFile(void) {
void Generator::GenerateOutput(void) { void Generator::GenerateOutput(void) {
} }
char GenerateCharacter(void) { char Generator::GenerateCharacter(void) {
double roll = ((double) GenerateRandomNumber(RAND_MAX)) / ((double) RAND_MAX);
return 'z'; return 'z';
} }

View File

@ -5,7 +5,8 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
void PrintUsage(void); void InitializeGenerator(void);
int GenerateRandomNumber(int generationLimit);
struct ArgumentList { struct ArgumentList {
std::string filename = ""; std::string filename = "";
@ -48,4 +49,6 @@ private:
Trie trie; Trie trie;
}; };
void PrintUsage(void);
#endif // !GENERATOR_HPP #endif // !GENERATOR_HPP

View File

@ -7,6 +7,7 @@ int main(int argc, char* argv[]) {
} }
Generator markovChain; Generator markovChain;
markovChain.SetArguments(argc, argv); markovChain.SetArguments(argc, argv);
InitializeGenerator();
markovChain.ReadFile(); markovChain.ReadFile();
markovChain.GenerateOutput(); markovChain.GenerateOutput();
return 0; return 0;