Exemple #1
0
 public static void Find(GridVisitorArgs args, Cell startCell)
 {
     args.Visited.TryGetValue(startCell.PositionInGrid, out bool status);
     if (!status)
     {
         Visit(args, startCell);
     }
 }
Exemple #2
0
        public static IEnumerable <List <Cell> > FindCombinations(Grid grid, IEnumerable <Neighbours> checkingNeighbours)
        {
            var visited = new Dictionary <Point, bool>(grid.Width * grid.Height);
            var args    = new GridVisitorArgs(grid, visited, checkingNeighbours);

            for (int i = 0; i < grid.Width; ++i)
            {
                for (int j = 0; j < grid.Height; ++j)
                {
                    args.Solution = new List <Cell>();
                    Find(args, grid.Cells[i, j]);
                    if (args.Solution.Count >= 3)
                    {
                        yield return(args.Solution);
                    }
                }
            }
        }