private ImmutableSigmaMap <MazeCell> InitAboveDiagonal(MapSize size) { // need a local variable here to put it into a closure ImmutableSigmaMap <MazeCell> maze = ArraySigmaMap.From(size, _ => MazeCell.Wall); return(Graph.DepthFirstTraverse(new SigmaIndex(0, 0), s => s.Neighborhood .Clamp(size) .OrderBy(_ => random.Next()), s => s.Neighborhood .Clamp(size) .Where(x => maze[x] == MazeCell.Empty) .Count() > emptyNeighborhood ).Aggregate(maze, (m, r) => maze = m.Insert(r.Node, MazeCell.Empty))); }
public ISigmaMap <MazeCell> Construct(MapSize size) { return(ArraySigmaMap .From(FixConnectivity(SymmetricallyComplete(InitAboveDiagonal(size))))); }