I am trying to make a card game, and I made my own shuffle function in rTools, but every time I update the console (e.g. using a console.readline statement) it re-randomizes the list. For example, in a list<string> of 1,2,3,4,5 and I use rTools.shuffle on it, the first three would be something like 3, 5, and 2. But after I refresh it without restarting the code, it would be a completely different series. I'm using an online editor, dotnetfiddle.net, if that changes anything. I have tried multiple different approaches- here is my code:
using System;
using System.Collections.Generic;
namespace elementCard
{
public class rTools {
public rTools() {
dddd = DateTime.Now;
llll = dddd.Ticks;
ssss = llll.ToString().Substring(llll.ToString().Length - 8, 8);//This is because the original long was not accepted by System.Random(int)
_seed = Int32.Parse(ssss);
}
private DateTime dddd
{ get; set; }
private long llll
{ get; set; }
private string ssss
{ get; set; }
private int _seed
{ get; set; }
public List<string> shuffle(List<string> l)
{
int count = l.Count-1;
List<string> ret = new List<string>();
int ind = 0;
Random rng = new Random(_seed);
string card = null;
while (count > -1)
{
ind = rng.Next(0, count);
card = l[ind];
l.RemoveAt(ind);
ret.Add(card);
card = null;
count--;
}
return ret;
}
}
public class Program
{
public static void Main()
{
rTools rtools = new rTools();
Console.WriteLine("Hello World");
List<List<string>> playerHands = new List<List<string>>();
//