diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /DSACore/Auxiliary/RandomMisc.cs | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'DSACore/Auxiliary/RandomMisc.cs')
-rw-r--r-- | DSACore/Auxiliary/RandomMisc.cs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/DSACore/Auxiliary/RandomMisc.cs b/DSACore/Auxiliary/RandomMisc.cs index 1295f02..72c2234 100644 --- a/DSACore/Auxiliary/RandomMisc.cs +++ b/DSACore/Auxiliary/RandomMisc.cs @@ -13,40 +13,40 @@ namespace DSACore.Auxiliary { var output = new StringBuilder(); var strings = input.Split('w', 'd').ToList(); - int count = Convert.ToInt32(strings[0]); + var count = Convert.ToInt32(strings[0]); strings = strings[1].Split(' ').ToList(); - int d = Convert.ToInt32(strings[0]); + var d = Convert.ToInt32(strings[0]); if (strings.Count > 0) { } - int sum = 0; - for (int i = 0; i < count; i++) + var sum = 0; + for (var i = 0; i < count; i++) { var roll = Dice.Roll(d); sum += roll; output.Append("[" + roll + "] "); } - - if (strings.Count > 1) - { - sum += Convert.ToInt32(strings[1]); - output.Append("sum: " + sum); - } + + if (strings.Count > 1) + { + sum += Convert.ToInt32(strings[1]); + output.Append("sum: " + sum); + } return output.ToString(); } public static double Random(double stdDev = 1, double mean = 0) { - double u1 = Rand.NextDouble(); // uniform(0,1) random doubles - double u2 = Rand.NextDouble(); - double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * - Math.Sin(2.0 * Math.PI * u2); // random normal(0,1) - double randNormal = + var u1 = Rand.NextDouble(); // uniform(0,1) random doubles + var u2 = Rand.NextDouble(); + var randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * + Math.Sin(2.0 * Math.PI * u2); // random normal(0,1) + var randNormal = mean + stdDev * randStdNormal; // random normal(mean,stdDev^2) return randNormal; } } -} +}
\ No newline at end of file |