Exemple #1
0
        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)));
        }
Exemple #2
0
 public ISigmaMap <MazeCell> Construct(MapSize size)
 {
     return(ArraySigmaMap
            .From(FixConnectivity(SymmetricallyComplete(InitAboveDiagonal(size)))));
 }