public Dictionary <int, PatternNeighbours> FindNeighbours(PatternDataResults patternFinderResult)
        {
            Dictionary <int, PatternNeighbours> result = new Dictionary <int, PatternNeighbours>();

            FindNeighboursForEachPattern(patternFinderResult, result);
            return(result);
        }
 private void FindNeighboursForEachPattern(PatternDataResults patternFinderResult, Dictionary <int, PatternNeighbours> result)
 {
     for (int row = 0; row < patternFinderResult.GetGridLengthY(); row++)
     {
         for (int col = 0; col < patternFinderResult.GetGridLengthX(); col++)
         {
             PatternNeighbours neighbours = PatternFinder.CheckNeighboursInEachDirection(col, row, patternFinderResult);
             PatternFinder.AddNeighboursToDictionary(result, patternFinderResult.GetIndexAt(col, row), neighbours);
         }
     }
 }
        public Dictionary <int, PatternNeighbours> FindNeighbours(PatternDataResults patternFinderResult)
        {
            Dictionary <int, PatternNeighbours> result = new Dictionary <int, PatternNeighbours>();

            foreach (var patternDataToCheck in patternFinderResult.PatternIndexDictionary)
            {
                foreach (var possibleNeighbourForPattern in patternFinderResult.PatternIndexDictionary)
                {
                    FindNeighboursInAllDirections(result, patternDataToCheck, possibleNeighbourForPattern);
                }
            }
            return(result);
        }
Example #4
0
        public static PatternNeighbours CheckNeighboursInEachDirection(int x, int y,
                                                                       PatternDataResults patternDataResults)
        {
            PatternNeighbours patternNeighbours = new PatternNeighbours();

            foreach (Direction dir in Enum.GetValues(typeof(Direction)))
            {
                int PossiblePatternIndex = patternDataResults.GetNeighbourInDirection(x, y, dir);
                if (PossiblePatternIndex >= 0)
                {
                    patternNeighbours.AddPatternToDictionary(dir, PossiblePatternIndex);
                }
            }

            return(patternNeighbours);
        }
Example #5
0
 private void GetPatternNeighbours(PatternDataResults patternFinderResult, IFindNeighbourStrategy strategy)
 {
     patternPossibleNeighboursDictionary = PatternFinder.FindPossibleNeighboursForAllPatterns(strategy, patternFinderResult);
 }
Example #6
0
 public static Dictionary <int, PatternNeighbours> FindPossibleNeighboursForAllPatterns(
     IFindNeighbourStrategy strategy, PatternDataResults patternFinderResult)
 {
     return(strategy.FindNeighbours(patternFinderResult));
 }