From e6b73be0b24acb358b71b0b01c2bd0799cbaca52 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Sun, 11 Aug 2024 14:04:35 -0400 Subject: [PATCH] Program: Allow the user to specify the RNG seed --- README.md | 1 + Rotationator/Program.cs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e1c323a..a337414 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Options: --phaseLength The length of each phase in hours. [default: 4] --scheduleLength How long the schedule should be in days. [default: 30] --overridePhases The override phases file. [] + --randomSeed The seed for the random number generator. [] --version Show version information -?, -h, --help Show help and usage information ``` diff --git a/Rotationator/Program.cs b/Rotationator/Program.cs index 2c96093..8c1e774 100644 --- a/Rotationator/Program.cs +++ b/Rotationator/Program.cs @@ -1,4 +1,4 @@ -using System.CommandLine; +using System.CommandLine; using System.CommandLine.Invocation; using System.Text.Json; using OatmealDome.BinaryData; @@ -71,13 +71,16 @@ Option scheduleLengthOption = new Option("--scheduleLength", () => def Option overridePhasesOption = new Option("--overridePhases", () => null, "The override phases file."); +Option seedOption = new Option("--randomSeed", () => null, "The seed for the random number generator."); + Command command = new RootCommand("Generates a new VSSetting BYAMl file.") { lastByamlArg, outputByamlArg, phaseLengthOption, scheduleLengthOption, - overridePhasesOption + overridePhasesOption, + seedOption }; command.SetHandler(context => Run(context)); @@ -95,8 +98,9 @@ void Run(InvocationContext context) int phaseLength = context.ParseResult.GetValueForOption(phaseLengthOption); int scheduleLength = context.ParseResult.GetValueForOption(scheduleLengthOption); string? overridePhasesPath = context.ParseResult.GetValueForOption(overridePhasesOption); + uint? specifiedSeed = context.ParseResult.GetValueForOption(seedOption); - uint seed = (uint)Environment.TickCount; + uint seed = specifiedSeed ?? (uint)Environment.TickCount; SeadRandom random = new SeadRandom(seed); Console.WriteLine("Random seed: " + seed);