protected Procedural(City city, long seed) { if (city == null) throw new ArgumentNullException(nameof(city)); Seed = seed; City = city; rng = new RNG(BaseSeed, seed); GenerateStatic(); GenerateDynamic(); }
public Citizen(City city, long seed) { if (city == null) throw new ArgumentNullException(nameof(city)); _city = city; _seed = seed; _rng = new RNG(RNG.GetRaw(CITIZEN_RNG_BASE_GEN, seed)); var sdata = city.Rant.DoPackaged("sz/citizen", _seed); FirstName = String.Intern(sdata["firstname"]); MiddleName = String.Intern(sdata["middlename"]); MiddleInitial = MiddleName.FirstOrDefault(Char.IsLetter); LastName = String.Intern(sdata["lastname"]); Enum.TryParse(sdata["sex"], true, out _sex); // Tilt the distribution towards younger people var age = _rng.Next(18, _rng.Next(30, _rng.Next(30, 100))); var birthMonth = _rng.Next(12) + 1; var birthDay = _rng.Next(DateTime.DaysInMonth(city.StartingTime.Year - age, birthMonth)) + 1; BirthDate = new DateTime(city.StartingTime.Year - age, birthMonth, birthDay, 0, 0, 0); }
/// <summary> /// Executes the specified pattern and returns a series of outputs. /// </summary> /// <param name="input">The pattero to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <returns></returns> public IEnumerable<RantOutput> DoSerial(RantPattern input, RNG rng, int charLimit = 0, double timeout = -1) => new Sandbox(this, input, rng, charLimit).RunSerial(timeout);
/// <summary> /// Loads the file located at the specified path and executes it using a custom seed, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <returns></returns> public Output DoFile(string path, RNG rng, int charLimit = 0) { return(new Interpreter(this, Source.FromFile(path), rng, charLimit).Run()); }
/// <summary> /// Executes the specified pattern using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit"> /// The maximum number of characters that can be printed. An exception will be thrown if the limit /// is exceeded. Set to zero or below for unlimited characters. /// </param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public RantOutput Do(RantProgram input, RNG rng, int charLimit = 0, double timeout = -1, RantProgramArgs args = null) => RunVM(new Sandbox(this, input, rng, charLimit, GetPreservedCarrierState(), args), timeout);
/// <summary> /// Executes the specified pattern and returns a series of outputs. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public IEnumerable<RantOutput> DoSerial(string input, RNG rng, int charLimit = 0, double timeout = -1, RantPatternArgs args = null) => new Sandbox(this, RantPattern.FromString(input), rng, charLimit, args).RunSerial(timeout);
/// <summary> /// Loads the file located at the specified path and executes it using a custom seed, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public RantOutput DoFile(string path, RNG rng, int charLimit = 0, double timeout = -1, RantPatternArgs args = null) => RunVM(new Sandbox(this, RantPattern.FromFile(path), rng, charLimit, args), timeout);
/// <summary> /// Loads the file located at the specified path and executes it using a custom seed, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <returns></returns> public RantOutput DoFile(string path, RNG rng, int charLimit = 0) { return(new VM(this, RantPattern.FromFile(path), rng, charLimit).Run()); }
/// <summary> /// Executes the specified pattern using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public RantOutput Do(RantPattern input, RNG rng, int charLimit = 0, double timeout = -1, RantPatternArgs args = null) => RunVM(new Sandbox(this, input, rng, charLimit, args), timeout);
/// <summary> /// Executes the specified pattern using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <returns></returns> public RantOutput Do(RantPattern input, RNG rng, int charLimit = 0, double timeout = -1) { return(RunVM(new VM(this, input, rng, charLimit), timeout)); }
/// <summary> /// Loads the file located at the specified path and executes it using a custom seed, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <returns></returns> public RantOutput DoFile(string path, RNG rng, int charLimit = 0, double timeout = -1) { return(RunVM(new VM(this, RantPattern.FromFile(path), rng, charLimit), timeout)); }
/// <summary> /// Compiles the specified string into a pattern, executes it using a custom RNG, and returns the resulting output. /// </summary> /// <param name="input">The input string to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <returns></returns> public RantOutput Do(string input, RNG rng, int charLimit = 0, double timeout = -1) { return(RunVM(new VM(this, RantPattern.FromString(input), rng, charLimit), timeout)); }
/// <summary> /// Executes the specified source using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The source to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <returns></returns> public Output Do(Source input, RNG rng, int charLimit = 0) { return(new Interpreter(this, input, rng, charLimit).Run()); }
/// <summary> /// Executes the specified pattern and returns a series of outputs. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public IEnumerable <RantOutput> DoSerial(string input, RNG rng, int charLimit = 0, double timeout = -1, RantPatternArgs args = null) => new Sandbox(this, RantPattern.FromString(input), rng, charLimit, args).RunSerial(timeout);
/// <summary> /// Compiles the specified string into a pattern, executes it using a custom RNG, and returns the resulting output. /// </summary> /// <param name="input">The input string to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <returns></returns> public RantOutput Do(string input, RNG rng, int charLimit = 0) { return(new VM(this, RantPattern.FromString(input), rng, charLimit).Run()); }
public static char SelectFromRanges(string rangeString, RNG rng) { if (String.IsNullOrEmpty(rangeString)) { return('?'); } var list = new List <Tuple <char, char, int> >(); // <min, max, weight> var chars = rangeString.GetEnumerator(); char a, b; bool stall = false; while (stall || chars.MoveNext()) { stall = false; if (Char.IsWhiteSpace(chars.Current)) { continue; } if (!Char.IsLetterOrDigit(a = chars.Current)) { return('?'); } if (!chars.MoveNext()) { list.Add(Tuple.Create(a, a, 1)); break; } if (chars.Current == '-') { if (!chars.MoveNext()) { return('?'); } if (!Char.IsLetterOrDigit(b = chars.Current)) { return('?'); } if (Char.IsLetter(a) != Char.IsLetter(b) || Char.IsUpper(a) != Char.IsUpper(b)) { return('?'); } list.Add(Tuple.Create(a <b?a : b, a> b ? a : b, Math.Abs(b - a) + 1)); continue; } list.Add(Tuple.Create(a, a, 1)); stall = true; } if (!list.Any()) { return('?'); } int wSelect = rng.Next(0, list.Sum(r => r.Item3)) + 1; var ranges = list.GetEnumerator(); while (ranges.MoveNext()) { if (wSelect > ranges.Current.Item3) { wSelect -= ranges.Current.Item3; } else { break; } } return(Convert.ToChar(rng.Next(ranges.Current.Item1, ranges.Current.Item2 + 1))); }
/// <summary> /// Executes the specified pattern using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <returns></returns> public RantOutput Do(RantPattern input, RNG rng, int charLimit = 0) { return(new VM(this, input, rng, charLimit).Run()); }
public VehicleCompany(City city, long seed) : base(city, seed, CompanySpecialization.Vehicles) { var rng = new RNG(RNG.GetRaw(Bases.Company, seed)); int numVehicleModels = rng.Next(city.Config.NumCarCompaniesMin, city.Config.NumCarCompaniesMax + 1); }
static void StartIrrgen() { var rand = new Random(0); Thread.Sleep(400); C.WriteLine("#YIRRGEN Simulation Constant Calculator v1.4.53.3967495a"); C.WriteLine("Copyright (c) 1993 Eugene Glass, Jason Fisch"); C.WriteLine(); Thread.Sleep(600); Loading("INIT: #Y[libhypermathlib2000 v5.7.8453]", 24, 30, true); Loading("INIT: #Y[lib-libsagan84 v1.4.9b]", 24, 30, true); Loading("INIT: #Y[libcalculalgebra v6.7.69]", 24, 30, true); Loading("INIT: #Y[libfuccboiGDX (Professional Edition)]", 24, 30, true); Loading("INIT: #Y[libMEGAphp-vm v8.6.0]", 24, 30, true); Loading("INIT: #Y[lib-interdimensional-grasse v1.2.1]", 24, 30, true); Loading("INIT: #Y[libfischingrod v0.2.0]", 24, 30, true); Loading("INIT: #Y[librant4unix v3.0.0]", 24, 30, true); Loading("INIT: #Y[libMirrorScript v5.6.Eyes-Real?]", 24, 30, true); Loading("INIT: #Y[libtimespacepapaya v3.0.2]", 24, 30, true); C.WriteLine("\n#GSubmodules initialized!\n"); C.WriteLine("#YAllocating output buffers 0-255"); Count(0, 255); C.WriteLine("\nPartitioning math cache\n"); Thread.Sleep(500); for (int i = 0; i < 8; i++) { C.WriteLine(new string('=', 48)); C.WriteLine($"#MPARTITION CREATED @ 0x{rand.Next():X8} ({rand.Next(500, 1001)}K)"); C.WriteLine(new string('=', 48)); C.WriteLine(); Thread.Sleep(200); } C.WriteLine("#GAll systems ready."); C.WriteLine("#YProceed? (Y/n)"); Console.ReadLine(); Console.CursorVisible = false; Thread.Sleep(350); C.Write("#RLET'S DO THIS SHIT"); for (int i = 0; i < 35; i++) { C.Write("#R>"); Thread.Sleep(20); } C.WriteLine(); Console.Clear(); for (int i = 0; i < 4; i++) { Console.WriteLine("........................\n"); Thread.Sleep(300); } C.Write("#YCALCULATION START "); Spinner(); C.WriteLine('\n'); int delayBase = 1; float delayOffset = 1000f; C.Write("5."); var colors = new[] { 'W', 'R', 'G', 'B', 'Y', 'C', 'M' }; var bcolors = new[] { ConsoleColor.DarkBlue, ConsoleColor.DarkCyan, ConsoleColor.DarkGreen, ConsoleColor.DarkRed, ConsoleColor.DarkYellow, ConsoleColor.DarkBlue, ConsoleColor.DarkMagenta, ConsoleColor.DarkGray, ConsoleColor.Black }; var rant = new RantEngine(); rant.LoadPackage("Rantionary"); rant.Dictionary.IncludeHiddenClass("nsfw"); var rngRant = new RNG(0); var pattern = RantPattern.FromString(@" [rs:[n:1;8];{\s|:|--|\(|\);|\;|*|@|?!|...|_|::|\#|$|%|^|&\~|\u2591|\u2592|\u2593|\}|\{|\""|'|,|/|\\|\`|\|*|+|\< |\> |__|++|--|\<\< |\>\> |!!}] [before:[case:{upper|lower|none|word}]] {{<adj>\s|}<noun>|<place>|<verb.nom>|<name>|<adv>|<state>|<element>|<unit>|<country>|the|entity| pointer|object|int|void|reference|bool|boolean|byte|char|protected|private|public|internal|static| unsigned|operator|delete|const|float|double|dword|return|namespace|nullptr|class|template|exec|auto| \#include \<[`[^\w\d]`i:{<noun>|<verb.nom>};_].h\>| \#define __[case:upper]<noun>[case:none] [rs:[n:1;4];\s]{<noun>|<adj>|and|or|the|<verb>} [n:1;1k]|\#{W|R|G|Y|C|M|B}|[r:[n:1;16]]{\w}|0x\8,X|{<noun>|<verb>}\(\)|[numfmt:verbal-en;[n:1;1M]]}" ); int l = 13000; int corruptPoint = 7500; int unstablePoint = 6000; for (int i = 0; i < l; i++) { if (i < corruptPoint) { for (int j = 0; j < i / 100 + 1; j++) { if (i > unstablePoint && rand.Next(0, (corruptPoint - i) / 10 + 2) == 0) { C.Write(' '); } else { C.Write(rand.Next(0, 10)); } } } else if (i == corruptPoint) { SpinnerActive = false; for (int k = 0; k < 75; k++) { C.WriteLine($"#R==== FATAL ERROR ==== @ 0x{rngRant.NextRaw():X16}, 0x{rngRant.NextRaw():X16}"); Thread.Sleep(5); } } else { switch (rand.Next(0, 2)) { case 0: C.Write($"#{colors[rand.Next(colors.Length)]}{rand.Next(0, 10)}", false); break; case 1: if (i > 9000) { Console.BackgroundColor = bcolors[rand.Next(bcolors.Length)]; } C.Write(rant.Do(pattern, rngRant), false); break; } switch (rand.Next(700)) { case 0: Thread.Sleep(125); break; case 1: case 2: case 3: case 4: case 5: Console.MoveBufferArea(0, 0, 6, 8, rand.Next(Console.BufferWidth - 6), Console.CursorTop - 8, '\u2592', ConsoleColor.Black, ConsoleColor.Black); break; } } Thread.Sleep(delayBase + (int)delayOffset); delayOffset *= 0.845f; } Console.BackgroundColor = ConsoleColor.Green; Console.Clear(); for (int i = 0; i < Console.BufferWidth; i++) { if (i % 3 == 2) continue; Console.MoveBufferArea(Console.WindowHeight, 0, 1, Console.WindowHeight, i, 0, '\u2592', ConsoleColor.Blue, ConsoleColor.Magenta); for(int j = 0; j < 4; j++) Console.MoveBufferArea(0, 0, 1, 1, rand.Next(Console.WindowWidth), rand.Next(Console.WindowHeight), '\u2591', ConsoleColor.Yellow, ConsoleColor.Black); } }
/// <summary> /// Executes a pattern that has been loaded from a package using a custom random number generator and returns the resulting output. /// </summary> /// <param name="patternName">The name of the pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public RantOutput DoPackaged(string patternName, RNG rng, int charLimit = 0, double timeout = -1, RantPatternArgs args = null) { if (!PatternExists(patternName)) throw new ArgumentException("Pattern doesn't exist."); return RunVM(new Sandbox(this, _patternCache[patternName], rng, charLimit, args), timeout); }
/// <summary> /// Compiles the specified string into a pattern, executes it using a custom RNG, and returns the resulting output. /// </summary> /// <param name="input">The input string to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <returns></returns> public RantOutput Do(string input, RNG rng, int charLimit = 0, double timeout = -1) => RunVM(new Sandbox(this, RantPattern.FromString(input), rng, charLimit), timeout);
/// <summary> /// Loads the file located at the specified path and executes it using a custom seed, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit"> /// The maximum number of characters that can be printed. An exception will be thrown if the limit /// is exceeded. Set to zero or below for unlimited characters. /// </param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <param name="args">The arguments to pass to the pattern.</param> /// <returns></returns> public RantOutput DoFile(string path, RNG rng, int charLimit = 0, double timeout = -1, RantProgramArgs args = null) => RunVM(new Sandbox(this, RantProgram.CompileFile(path), rng, charLimit, GetPreservedCarrierState(), args), timeout);
/// <summary> /// Executes the specified pattern using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The pattern to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param> /// <returns></returns> public RantOutput Do(RantPattern input, RNG rng, int charLimit = 0, double timeout = -1) => RunVM(new Sandbox(this, input, rng, charLimit), timeout);
public IEnumerable <RantOutput> DoSerial(string input, RNG rng, int charLimit = 0, double timeout = -1, RantProgramArgs args = null) => new Sandbox(this, RantProgram.CompileString(input), rng, charLimit, GetPreservedCarrierState(), args).RunSerial(timeout);
/// <summary> /// Executes the specified string using a custom random number generator and returns the resulting output. /// </summary> /// <param name="input">The input string to execute.</param> /// <param name="rng">The random number generator to use when generating output.</param> /// <param name="charLimit">The maximum number of characters that can be printed. An exception will be thrown if the limit is exceeded. Set to zero or below for unlimited characters.</param> /// <returns></returns> public Output Do(string input, RNG rng, int charLimit = 0) { return(new Interpreter(this, Source.FromString(input), rng, charLimit).Run()); }