Example #1
0
        private void FloodFill(Point start)
        {
            var toProc = new Stack <Point>();

            toProc.Push(start);

            while (toProc.Count > 0)
            {
                var p = toProc.Pop();

                var cardinals = CardinalDirections.GetCardinalPointsAround(p).Select(c => c.Item1);
                foreach (var point in cardinals)
                {
                    if (Maze[point.Y, point.X] != 0)
                    {
                        //< If un-explored, fill it in
                        if (Explored[point.Y, point.X] == false)
                        {
                            //< Set the flood value to 1 more than the the previous point
                            FloodLevels[point.Y, point.X] = FloodLevels[p.Y, p.X] + 1;
                            //< Add this point to be filled
                            toProc.Push(point);
                        }
                    }
                }

                //< Set the current point as seen
                Explored[p.Y, p.X] = true;
            }
        }
Example #2
0
        private List <Tuple <Point, long> > GetPointsToCheck(Point p)
        {
            //< Get all the cardinal positions around this point
            var cardinals = CardinalDirections.GetCardinalPointsAround(p);

            //< Return those that ain't been explored
            return(cardinals.Where(c => IsUnexplored(c.Item1)).ToList());
        }