public MaterialPicker(NollaPrng prng, uint worldSeed) { PRNG = prng; PickMaterials(LIQUIDS, 3); PickMaterials(ALCHEMY, 1); ShuffleList(worldSeed); PRNG.Next(); PRNG.Next(); }
void ShuffleList(uint worldSeed) { var prng = new NollaPrng((worldSeed >> 1) + 12534); // Toxic sludge, blood, and soil for first for (int i = Materials.Count - 1; i >= 0; i--) { int rand = (int)(prng.Next() * (i + 1)); var tmp = Materials[i]; Materials[i] = Materials[rand]; Materials[rand] = tmp; } }
public static void PickForSeed(uint worldSeed) { var prng = new NollaPrng(worldSeed * 0.17127000 + 1323.59030000); // Preheat random! for (int i = 0; i < 5; i++) { prng.Next(); } Console.WriteLine($"Seed: {worldSeed}"); Console.WriteLine($"Lively Concotion: {new MaterialPicker(prng, worldSeed).ToString()}"); Console.WriteLine($"Alchemical Precursor: {new MaterialPicker(prng, worldSeed).ToString()}"); Console.WriteLine(""); }
void PickMaterials(List <string> source, int count) { int counter = 0; int failed = 0; while (counter < count && failed < 99999) { var picked = source[(int)(PRNG.Next() * source.Count)]; if (!Materials.Any(v => v == picked)) { Materials = Materials.Append(picked).ToList(); counter++; } else { failed++; } } return; }