예제 #1
0
        public override List <Point> NearestCells()
        {
            int[] dx = { 1, 1, 1, 0, 0, -1, -1, -1 };
            int[] dy = { 1, 0, -1, 1, -1, 1, 0, -1 };

            var cells = new List <Point>();

            for (int i = 0; i < dx.Length; ++i)
            {
                if (ChessBoard.CoordsCorrect(X + dx[i], Y + dy[i]))
                {
                    cells.Add(new Point(X + dx[i], Y + dy[i]));
                }
            }

            return(cells);
        }
예제 #2
0
        public override bool CorrectToMoveTo(int x, int y)
        {
            if (!ChessBoard.CoordsCorrect(x, y))
            {
                return(false);
            }

            if (x != X && y != Y)
            {
                return(false);
            }

            if (x == X && y == Y)
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public override bool CorrectToMoveTo(int x, int y)
        {
            if (!ChessBoard.CoordsCorrect(x, y))
            {
                return(false);
            }

            int diffX = Math.Abs(x - X), diffY = Math.Abs(y - Y);

            if (diffX > 2 ||
                diffY > 2 ||
                diffX == 0 ||
                diffY == 0 ||
                diffX == diffY)
            {
                return(false);
            }

            return(true);
        }
예제 #4
0
        public override List <List <Point> > GetPaths()
        {
            var       paths = new List <List <Point> >();
            const int max   = ChessBoard.FieldSize - 1;

            if (X != 0)
            {
                paths.Add(GetPathTo(0, Y));
            }
            if (X != max)
            {
                paths.Add(GetPathTo(max, Y));
            }
            if (Y != 0)
            {
                paths.Add(GetPathTo(X, 0));
            }
            if (Y != max)
            {
                paths.Add(GetPathTo(X, max));
            }

            if (X != 0 && Y != 0)
            {
                paths.Add(ChessBoard.CoordsCorrect(0, Y - X) ? GetPathTo(0, Y - X) : GetPathTo(X - Y, 0));
            }
            if (X != 0 && Y != max)
            {
                paths.Add(ChessBoard.CoordsCorrect(X - max + Y, max) ? GetPathTo(X - max + Y, max) : GetPathTo(0, Y + X));
            }
            if (X != max && Y != 0)
            {
                paths.Add(ChessBoard.CoordsCorrect(max, Y - max + X) ? GetPathTo(max, Y - max + X) : GetPathTo(X + Y, 0));
            }
            if (X != max && Y != max)
            {
                paths.Add(ChessBoard.CoordsCorrect(max, Y + max - X) ? GetPathTo(max, Y + max - X) : GetPathTo(X + max - Y, max));
            }

            return(paths);
        }
예제 #5
0
        public override bool CorrectToMoveTo(int x, int y)
        {
            if (!ChessBoard.CoordsCorrect(x, y))
            {
                return(false);
            }

            if (x == X && y == Y)
            {
                return(false);
            }

            int diffX = Math.Abs(x - X), diffY = Math.Abs(y - Y);

            if (diffX != diffY && (diffX > 0 && diffY > 0))
            {
                return(false);
            }

            return(true);
        }