public static bool IsCoordsInMatrixRange(int[,] matrix, ICoords coords) { var isRowInRange = 0 <= coords.Row && coords.Row < matrix.GetLength(0); var isColInRange = 0 <= coords.Col && coords.Col < matrix.GetLength(1); return(isRowInRange && isColInRange); }
public static ICoords GetNextCoords(ICoords coords, Direction direction) { var newRow = coords.Row + RowChange[(int)direction]; var newCol = coords.Col + ColChange[(int)direction]; return(new Coords(newRow, newCol)); }
public bool Equals(ICoords other) { if (ReferenceEquals(null, other)) { return(false); } return(_Long == other.Long && _Lat == other.Lat && _South == other.South && _East == other.East); }
public static IEnumerable <ICoords> HortogonalCoord(ICoords target) { yield return(new Coords((byte)(target.X + 1), target.Y)); yield return(new Coords((byte)(target.X - 1), target.Y)); yield return(new Coords(target.X, (byte)(target.Y + 1))); yield return(new Coords(target.X, (byte)(target.Y - 1))); }
/// <summary> /// Add List's Style /// from False to True /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Add(ICoords item) { if (InOfRange(item)) { this[item] = true; return(true); } else { return(false); } }
/// <summary> /// Remove List's Style /// from True to False /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Remove(ICoords item) { if (InOfRange(item) && this[item]) { this[item] = false; return(true); } else { return(false); } }
private static ICoords GetNextCellCoords(this int[,] matrix, ICoords coords, Direction direction) { if (!Utils.IsCoordsInMatrixRange(matrix, coords)) { throw new ArgumentOutOfRangeException("Coords"); } var newCoords = Utils.GetNextCoords(coords, direction); var isNewCoordsBetter = Utils.IsCoordsInMatrixRange(matrix, newCoords); return(isNewCoordsBetter ? newCoords : coords); }
private IEnumerable <ICoords> GroupWalker(BitPlane scope, ICoords fuse) { var todo = new List <ICoords>(); todo.Add(fuse); while (todo.Any()) { var target = todo.First(); yield return(target); scope.Remove(target); todo.Remove(target); todo.AddRange(_walk(scope, target)); } }
public bool Remove(ICoords stone) { return(Remove(stone.X, stone.Y)); }
/// <summary> /// Is coords on the board /// </summary> public bool StoneInBounds(ICoords stone) { return(StoneInBounds(stone.X, stone.Y)); }
static void PrintCoords(ICoords coords) { Console.WriteLine($"{coords.x} - {coords.y}"); }
public bool InOfRange(ICoords coords) { return(coords.X < Width && coords.Y < Height); }
public bool this[ICoords coords] { get { return(this[coords.X, coords.Y]); } set { this[coords.X, coords.Y] = value; } }
public static IEnumerable <ICoords> NobiWalk(BitPlane scope, ICoords target) { return(HortogonalCoord(target).Where(x => scope.InOfRange(x) && scope[x])); }