From cd457755cbe2d8d49fb1e3c933c14432ab432a51 Mon Sep 17 00:00:00 2001 From: Al Beano Date: Tue, 19 Jul 2016 14:14:11 +0100 Subject: [PATCH] choice between two RNGs --- MarkovBot.pl | 1 + MarkovBot/MarkovChain.pm | 1 + config.default.yml | 7 +++++++ cpanfile | 3 +++ 4 files changed, 12 insertions(+) diff --git a/MarkovBot.pl b/MarkovBot.pl index 4c55f38..8a67915 100644 --- a/MarkovBot.pl +++ b/MarkovBot.pl @@ -16,6 +16,7 @@ use MarkovBot::Commands; use MarkovBot::MarkovChain; use MarkovBot::Redis; use Encode qw(encode decode); +use if (config("rng") eq "mt"), "Math::Random::MT::Perl" => qw(rand); sub said { my $self = shift; diff --git a/MarkovBot/MarkovChain.pm b/MarkovBot/MarkovChain.pm index 8ea6225..fdf3ddb 100644 --- a/MarkovBot/MarkovChain.pm +++ b/MarkovBot/MarkovChain.pm @@ -12,6 +12,7 @@ use lib $Bin; use MarkovBot::Config; use MarkovBot::Redis; use Encode qw(decode encode); +use if (config("rng") eq "mt"), "Math::Random::MT::Perl" => qw(rand); sub markov( $ ) { # markov - given two starting words, returns a markov chain result diff --git a/config.default.yml b/config.default.yml index 4887c5b..e9dbd6f 100644 --- a/config.default.yml +++ b/config.default.yml @@ -21,3 +21,10 @@ irc_port: 6697 irc_channel: "#baz" irc_nickname: shithead-ng irc_nickname2: shithead + +# +# RNG to use +# This can be "rand" for perl's built in rand() function +# Or "mt" to use the Math::Random::MT::Perl module (recommended) +# +rng: rand diff --git a/cpanfile b/cpanfile index 6fd8e7b..62ed3b5 100644 --- a/cpanfile +++ b/cpanfile @@ -6,3 +6,6 @@ requires "YAML::Tiny" => "0"; requires "POE::Component::SSLify" => "0"; requires "Scalar::Util" => "0"; requires "Encode" => "0"; +requires "if" => "0"; + +recommends "Math::Random::MT::Perl" => "0";