/// <summary> /// Returns a pattern with the specified name from the engine's cache. If the pattern doesn't exist, it is loaded from file. /// </summary> /// <param name="name">The name or path of the pattern to retrieve.</param> /// <returns></returns> internal RantPattern GetPattern(string name) { RantPattern pattern; if (_patternCache.TryGetValue(name, out pattern)) { return(pattern); } return(_patternCache[name] = RantPattern.FromFile(name)); }
/// <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, RantPattern.FromFile(path), rng, charLimit).Run()); }
/// <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="seed">The seed to generate output with.</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, long seed, int charLimit = 0) { return(new Interpreter(this, RantPattern.FromFile(path), new RNG(seed), charLimit).Run()); }
/// <summary> /// Loads the file located at the specified path and executes it, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</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, int charLimit = 0) { return(new Interpreter(this, RantPattern.FromFile(path), new RNG(Seeds.NextRaw()), charLimit).Run()); }
/// <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, returning the resulting output. /// </summary> /// <param name="path">The path to the file to execute.</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, int charLimit = 0, double timeout = -1, RantPatternArgs args = null) => RunVM(new Sandbox(this, RantPattern.FromFile(path), new RNG(Seeds.NextRaw()), 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> /// <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> /// 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="seed">The seed to generate output with.</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, long seed, int charLimit = 0, double timeout = -1) { return(RunVM(new VM(this, RantPattern.FromFile(path), new RNG(seed), charLimit), timeout)); }