using System.Collections.Generic; namespace Hallucinate.GameSetup.Maze.Extensions { /// /// Provides utility extension methods for maze generation algorithms. /// public static class Extensions { private static System.Random _rng = new System.Random(); /// /// Shuffles the elements of an using the Fisher-Yates algorithm. /// This is used to randomize directions for maze generation. /// /// The type of elements in the list. /// The list to shuffle. public static void Shuffle(this IList list) { int n = list.Count; while (n > 1) { n--; int k = _rng.Next(n + 1); T value = list[k]; list[k] = list[n]; list[n] = value; } } } }