示例#1
0
        public override MovementPattern MovePattern(Point position)
        {
            int oldX = position.X;
            int oldY = position.Y;
            int newX, newY;

            MovementPattern pattern = new MovementPattern();
            List <Point>    offsets = new List <Point>
            {
                new Point(-1, -1),
                new Point(-1, 0),
                new Point(-1, 1),
                new Point(0, -1),
                new Point(0, 1),
                new Point(1, -1),
                new Point(1, 0),
                new Point(1, 1)
            };

            foreach (Point offset in offsets)
            {
                newX = oldX + offset.X;
                newY = oldY + offset.Y;

                if (newX >= 0 && newX < 10 && newY >= 0 && newY < 10)
                {
                    pattern.kingPattern.Add(new Point(newX, newY));
                }
            }

            return(pattern);
        }
示例#2
0
        public override MovementPattern MovePattern(Point position)
        {
            MovementPattern pattern = new MovementPattern();
            int             oldX = position.X;
            int             oldY = position.Y;
            int             newX, newY;

            List <Point> jumps   = new List <Point>();
            List <Point> offsets = new List <Point>
            {
                new Point(-1, -2),
                new Point(-2, -1),
                new Point(1, -2),
                new Point(-2, 1),
                new Point(1, 2),
                new Point(2, 1),
                new Point(-1, 2),
                new Point(2, -1)
            };

            foreach (Point offset in offsets)
            {
                newX = oldX + offset.X;
                newY = oldY + offset.Y;

                if (newX >= 0 && newX < 10 && newY >= 0 && newY < 10)
                {
                    jumps.Add(new Point(newX, newY));
                }
            }
            pattern.jumpPattern = jumps;

            return(pattern);
        }
示例#3
0
        public override MovementPattern MovePattern(Point position)
        {
            MovementPattern pattern = new MovementPattern();
            int             oldY    = position.Y;
            int             newY;

            if (pieceColor == PieceColor.White)
            {
                newY = oldY - 1;
                if (newY >= 0)
                {
                    pattern.pawnMovePattern.Add(new Point(position.X, newY));
                    if (position.X - 1 >= 0)
                    {
                        pattern.pawnAttackPattern.Add(new Point(position.X - 1, newY));
                    }

                    if (position.X + 1 < 10)
                    {
                        pattern.pawnAttackPattern.Add(new Point(position.X + 1, newY));
                    }
                }

                if (oldY == 7)
                {
                    newY = oldY - 2;
                    pattern.pawnMovePattern.Add(new Point(position.X, newY));
                }
            }

            if (pieceColor == PieceColor.Black)
            {
                newY = oldY + 1;
                if (newY < 10)
                {
                    pattern.pawnMovePattern.Add(new Point(position.X, newY));
                    if (position.X - 1 >= 0)
                    {
                        pattern.pawnAttackPattern.Add(new Point(position.X - 1, newY));
                    }

                    if (position.X + 1 < 10)
                    {
                        pattern.pawnAttackPattern.Add(new Point(position.X + 1, newY));
                    }
                }

                if (oldY == 2)
                {
                    newY = oldY + 2;
                    pattern.pawnMovePattern.Add(new Point(position.X, newY));
                }
            }

            return(pattern);
        }
示例#4
0
        public override MovementPattern MovePattern(Point position)
        {
            MovementPattern pattern = new MovementPattern();
            List <Point>    line    = new List <Point>();

            //dreapta
            for (int i = 1; i < 10; i++)
            {
                int newX = position.X + i;

                if (newX < 10)
                {
                    line.Add(new Point(newX, position.Y));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            line = new List <Point>();

            //stanga
            for (int i = 1; i < 10; i++)
            {
                int newX = position.X - i;

                if (newX >= 0)
                {
                    line.Add(new Point(newX, position.Y));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            line = new List <Point>();

            //sus
            for (int i = 1; i < 10; i++)
            {
                int newY = position.Y - i;

                if (newY >= 0)
                {
                    line.Add(new Point(position.X, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            line = new List <Point>();

            //jos
            for (int i = 1; i < 10; i++)
            {
                int newY = position.Y + i;

                if (newY < 10)
                {
                    line.Add(new Point(position.X, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);

            List <Point> diagonal = new List <Point>();

            //-45 grade
            for (int i = 1; i < 10; i++)
            {
                int newX = position.X + i;
                int newY = position.Y + i;

                if (newX < 10 && newY < 10)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);
            diagonal = new List <Point>();

            //135 grade
            for (int i = 1; i < 10; i++)
            {
                int newX = position.X - i;
                int newY = position.Y - i;

                if (newX >= 0 && newY >= 0)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);
            diagonal = new List <Point>();

            //-135 grade
            for (int i = 1; i < 10; i++)
            {
                int newX = position.X - i;
                int newY = position.Y + i;

                if (newX >= 0 && newY < 10)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);
            diagonal = new List <Point>();

            //45 grade
            for (int i = 1; i < 10; i++)
            {
                int newX = position.X + i;
                int newY = position.Y - i;

                if (newX < 10 && newY >= 0)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);

            return(pattern);
        }
示例#5
0
        public override MovementPattern MovePattern(Point position)
        {
            MovementPattern pattern = new MovementPattern();
            List <Point>    jumps   = new List <Point>();
            List <Point>    offsets = new List <Point>
            {
                new Point(-1, -2),
                new Point(-2, -1),
                new Point(1, -2),
                new Point(-2, 1),
                new Point(1, 2),
                new Point(2, 1),
                new Point(-1, 2),
                new Point(2, -1)
            };

            int oldX = position.X;
            int oldY = position.Y;
            int newX, newY;

            foreach (Point offset in offsets)
            {
                newX = oldX + offset.X;
                newY = oldY + offset.Y;

                if (newX >= 0 && newX < 10 && newY >= 0 && newY < 10)
                {
                    jumps.Add(new Point(newX, newY));
                }
            }
            pattern.jumpPattern = jumps;

            List <Point> line = new List <Point>();

            //dreapta
            for (int i = 1; i < 10; i++)
            {
                newX = position.X + i;

                if (newX < 10)
                {
                    line.Add(new Point(newX, position.Y));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            line = new List <Point>();

            //stanga
            for (int i = 1; i < 10; i++)
            {
                newX = position.X - i;

                if (newX >= 0)
                {
                    line.Add(new Point(newX, position.Y));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            line = new List <Point>();

            //sus
            for (int i = 1; i < 10; i++)
            {
                newY = position.Y - i;

                if (newY >= 0)
                {
                    line.Add(new Point(position.X, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            line = new List <Point>();

            //jos
            for (int i = 1; i < 10; i++)
            {
                newY = position.Y + i;

                if (newY < 10)
                {
                    line.Add(new Point(position.X, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(line);
            return(pattern);
        }
示例#6
0
        public override MovementPattern MovePattern(Point position)
        {
            MovementPattern pattern = new MovementPattern();
            int             oldX = position.X;
            int             oldY = position.Y;
            int             newX, newY;

            List <Point> jumps   = new List <Point>();
            List <Point> offsets = new List <Point>
            {
                new Point(-1, -2),
                new Point(-2, -1),
                new Point(1, -2),
                new Point(-2, 1),
                new Point(1, 2),
                new Point(2, 1),
                new Point(-1, 2),
                new Point(2, -1)
            };

            foreach (Point offset in offsets)
            {
                newX = oldX + offset.X;
                newY = oldY + offset.Y;

                if (newX >= 0 && newX < 10 && newY >= 0 && newY < 10)
                {
                    jumps.Add(new Point(newX, newY));
                }
            }
            pattern.jumpPattern = jumps;

            List <Point> diagonal = new List <Point>();

            //-45 grade
            for (int i = 1; i < 10; i++)
            {
                newX = position.X + i;
                newY = position.Y + i;

                if (newX < 10 && newY < 10)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);
            diagonal = new List <Point>();

            //135 grade
            for (int i = 1; i < 10; i++)
            {
                newX = position.X - i;
                newY = position.Y - i;

                if (newX >= 0 && newY >= 0)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);
            diagonal = new List <Point>();

            //-135 grade
            for (int i = 1; i < 10; i++)
            {
                newX = position.X - i;
                newY = position.Y + i;

                if (newX >= 0 && newY < 10)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);
            diagonal = new List <Point>();

            //45 grade
            for (int i = 1; i < 10; i++)
            {
                newX = position.X + i;
                newY = position.Y - i;

                if (newX < 10 && newY >= 0)
                {
                    diagonal.Add(new Point(newX, newY));
                }

                else
                {
                    break;
                }
            }
            pattern.slidingPatterns.Add(diagonal);

            return(pattern);
        }