Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public bool Equals(ICoords other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            return(_Long == other.Long && _Lat == other.Lat && _South == other.South && _East == other.East);
        }
Ejemplo n.º 4
0
        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)));
        }
Ejemplo n.º 5
0
 /// <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);
     }
 }
Ejemplo n.º 6
0
 /// <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);
     }
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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));
            }
        }
Ejemplo n.º 9
0
 public bool Remove(ICoords stone)
 {
     return(Remove(stone.X, stone.Y));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Is coords on the board
 /// </summary>
 public bool StoneInBounds(ICoords stone)
 {
     return(StoneInBounds(stone.X, stone.Y));
 }
Ejemplo n.º 11
0
 static void PrintCoords(ICoords coords)
 {
     Console.WriteLine($"{coords.x} - {coords.y}");
 }
Ejemplo n.º 12
0
 public bool InOfRange(ICoords coords)
 {
     return(coords.X < Width && coords.Y < Height);
 }
Ejemplo n.º 13
0
        public bool this[ICoords coords]
        {
            get { return(this[coords.X, coords.Y]); }

            set { this[coords.X, coords.Y] = value; }
        }
Ejemplo n.º 14
0
 public static IEnumerable <ICoords> NobiWalk(BitPlane scope, ICoords target)
 {
     return(HortogonalCoord(target).Where(x => scope.InOfRange(x) && scope[x]));
 }