private List <MatrixRow> BuildMatrixRowsForColourPairPaths( ColourPair colourPair, int colourPairIndex, IEnumerable <Path> paths) { return(paths .Select(path => BuildMatrixRowForColourPairPath(colourPair, colourPairIndex, path)) .ToList()); }
public static IEnumerable <Path> InitialPaths(ColourPair colourPair) { yield return(Path.PathWithStartCoordsAndDirection(colourPair.StartCoords, Direction.Up)); yield return(Path.PathWithStartCoordsAndDirection(colourPair.StartCoords, Direction.Down)); yield return(Path.PathWithStartCoordsAndDirection(colourPair.StartCoords, Direction.Left)); yield return(Path.PathWithStartCoordsAndDirection(colourPair.StartCoords, Direction.Right)); }
private Tuple <List <MatrixRow>, List <Path> > FindAllPathsForColourPair( ColourPair colourPair, int colourPairIndex, IEnumerable <Path> activePaths, int maxDirectionChanges) { var pathFinder = new PathFinder(_cancellationToken); var paths = pathFinder.FindAllPaths(_grid, colourPair.EndCoords, activePaths, maxDirectionChanges); var partitionedPaths = paths.ToLookup(p => p.IsActive); var completedPaths = partitionedPaths[true].ToList(); var stalledPaths = partitionedPaths[false].ToList(); var matrixRows = BuildMatrixRowsForColourPairPaths(colourPair, colourPairIndex, completedPaths); return(Tuple.Create(matrixRows, stalledPaths)); }
private MatrixRow BuildMatrixRowForColourPairPath(ColourPair colourPair, int colourPairIndex, Path path) { var dlxRow = new BitArray(_numColumns); dlxRow[colourPairIndex] = true; // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (var coords in path.CoordsList) { var gridLocationIndex = _numColourPairs + (_grid.GridSize * coords.X) + coords.Y; dlxRow[gridLocationIndex] = true; } return(new MatrixRow(colourPair, path, dlxRow)); }
private List <Path> GetStalledPathsForColourPair(ColourPair colourPair) { return(_stalledPaths.Where(path => path.CoordsList.First().Equals(colourPair.StartCoords)).ToList()); }
public MatrixRow(ColourPair colourPair, Path path, BitArray dlxRow) { _colourPair = colourPair; _path = path; _dlxRow = dlxRow; }