public async Task MemberRandom(Context ctx) { ctx.CheckSystem(); var randGen = new global::System.Random(); //Maybe move this somewhere else in the file structure since it doesn't need to get created at every command // TODO: don't buffer these, find something else to do ig var members = await _db.Execute(c => { if (ctx.MatchFlag("all", "a")) { return(_repo.GetSystemMembers(c, ctx.System.Id)); } return(_repo.GetSystemMembers(c, ctx.System.Id) .Where(m => m.MemberVisibility == PrivacyLevel.Public)); }).ToListAsync(); if (members == null || !members.Any()) { throw Errors.NoMembersError; } var randInt = randGen.Next(members.Count); await ctx.Reply(embed : await _embeds.CreateMemberEmbed(ctx.System, members[randInt], ctx.Guild, ctx.LookupContextFor(ctx.System))); }
internal static void TestCorrectness() { global::System.Random rand = new global::System.Random(); int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Select rs = new Select(); int select = a[0]; for (int i = 1; i < a.Length; ++i) { if (rs.isSelected(rand.Next())) { select = a[i]; } } Console.WriteLine(select); rs.reset(0); select = -1; for (int i = 0; i < a.Length; ++i) { if (rs.isSelected(rand.Next())) { select = a[i]; } } Console.WriteLine(select); }
/// <summary>Returns a random Vector3</summary> /// <param name="random">System.Random instance</param> /// <returns>The random Vector3</returns> public static Vector3D NextVector3(this global::System.Random random) { return(new Vector3D( (random.Next() - random.Next()) * (float)random.NextDouble(), (random.Next() - random.Next()) * (float)random.NextDouble(), (random.Next() - random.Next()) * (float)random.NextDouble())); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "random") { if (TemplateNode.HasChildNodes) { // only grab <li> nodes List <XmlNode> listNodes = new List <XmlNode>(); foreach (XmlNode childNode in TemplateNode.ChildNodes) { if (childNode.Name == "li") { listNodes.Add(childNode); } } if (listNodes.Count > 0) { global::System.Random r = new global::System.Random(); XmlNode chosenNode = listNodes[r.Next(listNodes.Count)]; return(chosenNode.InnerXml); } } } return(string.Empty); }
/// <summary> /// リストの要素をランダムに並び替える /// </summary> public static void Shuffle <T>(this Original.IList <T> list, Random random = null) { for (int indexA = 0; indexA < list.Count; ++indexA) { int indexB = list.RandomIndex(random); list.Swap(indexA, indexB); } }
public void OneOf() { var @this = new global::System.Random(); var value1 = @this.OneOf(1, 2, 3, 4); var value2 = @this.OneOf("a", "b", "c", "d"); var value3 = @this.OneOf(1, "a", global::System.DateTime.Now, new object()); }
internal global::SWA.Ariadne.Gui.Mazes.ContourImage LoadImage(string imagePath, global::System.Random r) { object[] args = new object[] { imagePath, r}; global::SWA.Ariadne.Gui.Mazes.ContourImage ret = ((global::SWA.Ariadne.Gui.Mazes.ContourImage)(m_privateObject.Invoke("LoadImage", new System.Type[] { typeof(string), typeof(global::System.Random)}, args))); return ret; }
internal System.Collections.Generic.List<string> FindImages(string folderPath, int count, bool quickSearch, global::System.Random r) { object[] args = new object[] { folderPath, count, quickSearch, r}; System.Collections.Generic.List<string> ret = ((System.Collections.Generic.List<string>)(m_privateObject.Invoke("FindImages", new System.Type[] { typeof(string), typeof(int), typeof(bool), typeof(global::System.Random)}, args))); return ret; }
public void @this(int n1){ //XMLVM_BEGIN_WRAPPER[Compatlib.System.Random: void <init>(int)] random = new global::System.Random(n1); //XMLVM_END_WRAPPER[Compatlib.System.Random: void <init>(int)] }
public void Reset(int seed) { random = new System.Random(seed); }
public void @this(int n1) { //XMLVM_BEGIN_WRAPPER[Compatlib.System.Random: void <init>(int)] random = new global::System.Random(n1); //XMLVM_END_WRAPPER[Compatlib.System.Random: void <init>(int)] }
/// <summary> /// Creates a generator with initial seed. /// </summary> /// <param name="seed"></param> public NativeGenerator(int seed) { random = new System.Random(seed); }
/// <summary> /// Creates a generator with automatic (time based) seed. /// </summary> public NativeGenerator() { random = new System.Random(); }
/// <summary> /// ランダムなindexを返します。 /// </summary> public static int RandomIndex <T>(this Original.IList <T> list, Random random) { return(random.Next(list.Count)); }
/// <summary> /// ランダムな位置の項目を削除し、削除された項目を返します。 /// </summary> public static T PopRandom <T>(this Original.IList <T> list, Random random = null) { var index = list.RandomIndex(random); return(list.Pop(index)); }
public void Reset() { random = new System.Random(); }
public void CoinToss() { var @this = new global::System.Random(); var value = @this.CoinToss(); }