Esempio n. 1
0
 public override bool IsAvailable(ChessSquare[,] board, int row, int column, int index)
 {
     bool canMove = true;
     if (board[row, column].Piece.Color == Color)
     {
         canMove = false;
     }
     else if (board[row, column].Piece.Color != ChessColor.NONE)
     {
         if (collision[index] >= 1)
         {
             canMove = false;
         }
         collision[index]++;
     }
     else
     {
         for (int x = 0; x < 8; ++x)
         {
             if(collision[x] > 0)
             {
                 canMove = false;
                 break;
             }
         }
     }
     if (this.canMove[index])
     {
         this.canMove[index] = canMove;
     }
     return canMove;
 }
Esempio n. 2
0
 public bool IsEmpty(ChessSquare[,] board, int row, int column, int index)
 {
     bool canMove = true;
     if (board[row, column].Piece.Color != ChessColor.NONE)
     {
         canMove = false;
     }
     if (this.canMove[index] == true)
     {
         this.canMove[index] = canMove;
     }
     return canMove;
 }
Esempio n. 3
0
 public override bool CheckMovement(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     bool isValid = false;
     List<int[]> available = RestrictMovement(board, startX, startY);
     for (int x = 0; x < available.Count; ++x)
     {
         if (available[x][0] == endX && available[x][1] == endY)
         {
             isValid = true;
         }
     }
     return isValid;
 }
Esempio n. 4
0
 public override bool IsAvailable(ChessSquare[,] board, int row, int column, int index)
 {
     bool canMove = true;
     if (board[row, column].Piece.Color == Color && board[row, column].Piece.Color != ChessColor.NONE)
     {
         canMove = false;
     }
     if (this.canMove[index] == true)
     {
         this.canMove[index] = canMove;
     }
     return canMove;
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a board of empty board squares.
 /// </summary>
 public void CreateSquares()
 {
     //Board
     Squares = new ChessSquare[8, 8];
     ChessColor color = ChessColor.LIGHT;
     //Empty squares
     for (int x = 0; x < 8; ++x)
     {
         for (int y = 0; y < 8; y++)
         {
             Squares[x, y] = new ChessSquare(x, y, color);
             //Spaces
             if (Squares[x, y].Piece == null)
             {
                 Squares[x, y].Piece = new Space();
             }
             color = ChangeColor(color);
         }
         color = ChangeColor(color);
     }
 }
Esempio n. 6
0
 public bool CastleingRightPosition(ChessSquare[,] board, int x)
 {
     bool inPosition = false;
     int position = 0;
     if (board[x, 4].Piece.GetType() == typeof(King))
     {
         if (((King)board[x, 4].Piece).moveAmount == 0)
         {
             position++;
         }
     }
     if (board[x, 7].Piece.GetType() == typeof(Rook))
     {
         if (((Rook)board[x, 7].Piece).moveAmount == 0)
         {
             position++;
         }
     }
     if (position == 2)
     {
         inPosition = true;
     }
     return inPosition;
 }
Esempio n. 7
0
 public override List<int[]> Search(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     bool isMoveSet = false;
     List<int[]> available = new List<int[]>();
         if (startX + 1 < 8)//down
         {
             available.Add(new int[] { startX + 1, startY });
             if (startX + 1 == endX && startY == endY)
             {
                 isMoveSet = true;
             }
         }
     ResetSearch(available, isMoveSet);
     if (isMoveSet == false)
     {
             if (startX + 1 < 8 && startY - 1 >= 0)//down Left
             {
                 available.Add(new int[] { startX + 1, startY - 1 });
                 if (startX + 1 == endX && startY - 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startX + 1 < 8 && startY - 1 >= 0)//down Left
             {
                 available.Add(new int[] { startX + 1, startY - 1 });
                 if (startX + 1 == endX && startY - 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startX + 1 < 8 && startY + 1 < 8)//down right
             {
                 available.Add(new int[] { startX + 1, startY + 1 });
                 if (startX + 1 == endX && startY + 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startY + 1 < 8)//right
             {
                 available.Add(new int[] { startX, startY + 1 });
                 if (startX == endX && startY + 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startX - 1 >= 0)//up
             {
                 available.Add(new int[] { startX - 1, startY });
                 if (startX - 1 == endX && startY == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startX - 1 >= 0 && startY - 1 >= 0)//up left
             {
                 available.Add(new int[] { startX - 1, startY - 1 });
                 if (startX - 1 == endX && startY - 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startX - 1 >= 0 && startY + 1 < 8)//up right
             {
                 available.Add(new int[] { startX - 1, startY + 1 });
                 if (startX - 1 == endX && startY + 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
             if (startY - 1 >= 0)//left
             {
                 available.Add(new int[] { startX, startY - 1 });
                 if (startX == endX && startY - 1 == endY)
                 {
                     isMoveSet = true;
                 }
             }
         ResetSearch(available, isMoveSet);
     }
     return available;
 }
Esempio n. 8
0
 public bool IsPossibleToCastle(ChessSquare[,] board, int x, bool isLeft)
 {
     bool isPossible = false;
     bool leftCastle = false;
     bool rightCastle = false;
     int caslteLeft = 0;
     int caslteRight = 0;
     for (int y = 0; y < 4; ++y)
     {
         if(4 - y >= 0)
         {
             if (board[x, 4 - y].Piece.Color == ChessColor.NONE)
             {
                 caslteLeft++;
             }
         }
         if (4 + y < 8)
         {
             if (y != 3)
             {
                 if (board[x, 4 + y].Piece.Color == ChessColor.NONE)
                 {
                     caslteRight++;
                 }
             }
         }
     }
     if(isLeft == true)
     {
         if (caslteLeft == 3)
         {
             leftCastle = CastleingLeftPosition(board, x);
             if (leftCastle == true)
             {
                 isPossible = true;
             }
         }
     }
     else
     {
         if (caslteRight == 2)
         {
             rightCastle = CastleingRightPosition(board, x);
             if (rightCastle == true)
             {
                 isPossible = true;
             }
         }
     }
     return isPossible;
 }
Esempio n. 9
0
 public override List<int[]> RestrictMovement(ChessSquare[,] board, int startX, int startY)
 {
     ResetMovement();
     List<int[]> available = new List<int[]>();
     bool isAvailable = false;
     bool isCastleing = false;
     bool isLeft = false;
     if (startX + 1 < 8)//down 1
     {
         isAvailable = IsAvailable(board, startX + 1, startY, 0);
         if (isAvailable == true)
         {
             if(canMove[0] == true)
             {
                 available.Add(new int[] { startX + 1, startY });
             }
         }
     }
     if (startX + 1 < 8 && startY - 1 >= 0)//down Left 1
     {
         isAvailable = IsAvailable(board, startX + 1, startY - 1, 1);
         if (isAvailable == true)
         {
             if (canMove[1] == true)
             {
                 available.Add(new int[] { startX + 1, startY - 1 });
             }
         }
     }
     if (startX + 1 < 8 && startY + 1 < 8)//down right 1
     {
         isAvailable = IsAvailable(board, startX + 1, startY + 1, 2);
         if (isAvailable == true)
         {
             if (canMove[2] == true)
             {
                 available.Add(new int[] { startX + 1, startY + 1 });
             }
         }
     }
     if (startY + 1 < 8)//right 1
     {
         isAvailable = IsAvailable(board, startX, startY + 1, 3);
         if (isAvailable == true)
         {
             if (canMove[3] == true)
             {
                 available.Add(new int[] { startX, startY + 1 });
             }
         }
         isCastleing = IsPossibleToCastle(board, startX, isLeft);
         if (isCastleing == true)
         {
             available.Add(new int[] { startX, startY + 2 });
         }
     }
     if (startX - 1 >= 0)//up 1
     {
         isAvailable = IsAvailable(board, startX - 1, startY, 4);
         if (isAvailable == true)
         {
             if (canMove[4] == true)
             {
                 available.Add(new int[] { startX - 1, startY });
             }
         }
     }
     if (startX - 1  >= 0 && startY - 1 >= 0)//up left 1
     {
         isAvailable = IsAvailable(board, startX - 1, startY - 1, 5);
         if (isAvailable == true)
         {
             if (canMove[5] == true)
             {
                 available.Add(new int[] { startX - 1, startY - 1 });
             }
         }
     }
     if (startX - 1 >= 0 && startY + 1 < 8)//up right 1
     {
         isAvailable = IsAvailable(board, startX - 1, startY + 1, 6);
         if (isAvailable == true)
         {
             if (canMove[6] == true)
             {
                 available.Add(new int[] { startX - 1, startY + 1 });
             }
         }
     }
     if (startY - 1 >= 0)//left 1
     {
         isAvailable = IsAvailable(board, startX, startY - 1, 7);
         if (isAvailable == true)
         {
             if (canMove[7] == true)
             {
                 available.Add(new int[] { startX, startY - 1 });
             }
         }
         isLeft = true;
         isCastleing = IsPossibleToCastle(board, startX, isLeft);
         if (isCastleing == true)
         {
             available.Add(new int[] { startX, startY - 2 });
         }
     }
     return available;
 }
Esempio n. 10
0
 public override List<int[]> RestrictMovement(ChessSquare[,] board, int startX, int startY)
 {
     return new List<int[]>();
 }
Esempio n. 11
0
        private bool CheckEnPassant(ChessSquare[,] board, int row, int column, int index)
        {
            bool canMove = false;

            if (board[row, column].Piece is Pawn)
            {
                if (board[row, column].Piece.Color != Color && board[row, column].Piece.Color != ChessColor.NONE)
                {
                    if (((Pawn)board[row, column].Piece)._moveAmount == 1)
                    {
                        if (((Pawn)board[row, column].Piece)._moves == 2)
                        {
                            if (((Pawn)board[row, column].Piece).chance == true)
                            {
                                canMove = true;
                            }
                        }
                    }
                }
            }
            if (this.canMove[index] == false)
            {
                this.canMove[index] = canMove;
            }
            return canMove;
        }
Esempio n. 12
0
 /// <summary>
 /// Checks if movement does not go off the board.
 /// </summary>
 /// <param name="start">A int array containing the starting postion for the piece.</param>
 /// <returns>Returns a list of valid movements for the piece.</returns>
 public abstract List<int[]> RestrictMovement(ChessSquare[,] board, int startX, int startY);
Esempio n. 13
0
 /// <summary>
 /// Checks if the desired location is an empty square and a piece of a different color.
 /// </summary>
 /// <param name="board">A 2-Dimesional array of ints representing the board.</param>
 /// <param name="end">A int array containg the end position for the piece.</param>
 /// <returns>
 /// True: If the desired square is empty or has an enemy piece.
 /// False: If the desired square already contains a friendly piece.
 /// </returns>
 public abstract bool CheckMovement(ChessSquare[,] board, int startX, int startY, int endX, int endY);
Esempio n. 14
0
 /// <summary>
 /// Removes the pawn that got 
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="board"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public void EnPassant(UniformGrid grid, ChessSquare[,] board, int x, int y)
 {
     if ((int)board[x, y].Piece.Color != Turn)
     {
         if (((Pawn)board[x, y].Piece)._moveAmount == 1)
         {
             board[x, y].Piece = new Space();
             ((Square)grid.Children[(x * 8) + y]).Panel.Children.Clear();
             ((Square)grid.Children[(x * 8) + y]).Pic = null;
         }
     }
 }
Esempio n. 15
0
 public override bool CheckMovement(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     ResetMovement();
     bool isValid = false;
     List<int[]> available = RestrictMovement(board, startX, startY);
     for (int x = 0; x < available.Count; ++x)
     {
         if (available[x][0] == endX && available[x][1] == endY)
         {
             isValid = true;
             _moveAmount++;
             _moves = startX - endX;
             if (Color == ChessColor.DARK)
             {
                 _moves = endX - startX;
             }
             if (_moves == 2)
             {
                 chance = true;
             }
         }
     }
     return isValid;
 }
Esempio n. 16
0
 /// <summary>
 /// Checks if the current piece is a pawn.
 /// Checks if the sides of the piece is not the end of the board.
 /// Checks the color of the selected piece.
 /// Checks if the sides of the selected piece is a pawn.
 /// </summary>
 /// <param name="board"></param>
 /// <param name="x1">The selected piece's x coordinate</param>
 /// <param name="y1">The selected piece's y coordinate</param>
 public void CheckEnPassant(ChessSquare[,] board, int x1, int y1)
 {
     if (board[x1, y1].Piece.GetType() == typeof(Pawn))
     {
         if ((x1 + 1) < 8)
         {
             if (board[x1, y1].Piece.Color == ChessColor.LIGHT)
             {
                 if (board[x1 + 1, y1].Piece.GetType() == typeof(Pawn))
                 {
                     EnPassant(g, Board.Squares, x1 + 1, y1);
                 }
             }
         }
         if ((x1 - 1) >= 0)
         {
             if (board[x1, y1].Piece.Color == ChessColor.DARK)
             {
                 if (board[x1 - 1, y1].Piece.GetType() == typeof(Pawn))
                 {
                     EnPassant(g, Board.Squares, x1 - 1, y1);
                 }
             }
         }
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Moves a piece from a starting location to a desired location.
 /// </summary>
 /// <param name="board">A 2-Dimesional array of ints representing the board.</param>
 /// <param name="start">A int array containing the starting postion for the piece.</param>
 /// <param name="end">A int array containg the end position for the piece.</param>
 public abstract void MovePiece(ChessSquare[,] board, int startX, int startY, int endX, int endY);
Esempio n. 18
0
 /// <summary>
 /// Checks if a movement option for a piece is empty or has an enemy piece.
 /// If it has a ally piece, then it can not move pass the piece unless it is
 /// a knight.
 /// </summary>
 /// <param name="board">A 2-Dimesional array of ints representing the board.</param>
 /// <param name="row">A int representing a row from the board.</param>
 /// <param name="column">A int representing a column number fromthe board.</param>
 /// <param name="index">A int representing a index number for the bool array.</param>
 /// <returns></returns>
 public abstract bool IsAvailable(ChessSquare[,] board, int row, int column, int index);
Esempio n. 19
0
 public override List<int[]> Test(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     bool isMoveSet = false;
     List<int[]> available = new List<int[]>();
     for (int x = 1; x < 8; ++x)
     {
         if (startX + x < 8)//down
         {
             available.Add(new int[] { startX + x, startY });
             if (startX + x == endX && startY == endY)
             {
                 isMoveSet = true;
                 break;
             }
         }
     }
     Test2(available, isMoveSet);
     if(isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startX + x < 8 && startY - x >= 0)//down Left
             {
                 available.Add(new int[] { startX + x, startY - x });
                 if (startX + x == endX && startY - x == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startX + x < 8 && startY + x < 8)//down right
             {
                 available.Add(new int[] { startX + x, startY + x });
                 if (startX + x == endX && startY + x == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startY + x < 8)//right
             {
                 available.Add(new int[] { startX, startY + x });
                 if (startX == endX && startY + x == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startX - x >= 0)//up
             {
                 available.Add(new int[] { startX - x, startY });
                 if (startX - x == endX && startY == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startX - x >= 0 && startY - x >= 0)//up left
             {
                 available.Add(new int[] { startX - x, startY - x });
                 if (startX - x == endX && startY - x == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startX - x >= 0 && startY + x < 8)//up right
             {
                 available.Add(new int[] { startX - x, startY + x });
                 if (startX - x == endX && startY + x == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         for (int x = 1; x < 8; ++x)
         {
             if (startY - x >= 0)//left
             {
                 available.Add(new int[] { startX, startY - x });
                 if (startX == endX && startY - x == endY)
                 {
                     isMoveSet = true;
                     break;
                 }
             }
         }
         Test2(available, isMoveSet);
     }
     return available;
 }
Esempio n. 20
0
 public override bool IsAvailable(ChessSquare[,] board, int row, int column, int index)
 {
     return false;
 }
Esempio n. 21
0
 public override List<int[]> RestrictMovement(ChessSquare[,] board, int startX, int startY)
 {
     ResetMovement();
     List<int[]> available = new List<int[]>();
     bool isAvailable = false;
     for (int x = 1; x < 8; ++x)
     {
         if (startX + x < 8)//down
         {
             isAvailable = IsAvailable(board, startX + x, startY, 0);
             if (isAvailable == true)
             {
                 if (canMove[0] == true)
                 {
                     available.Add(new int[] { startX + x, startY });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startX + x < 8 && startY - x >= 0)//down Left
         {
             isAvailable = IsAvailable(board, startX + x, startY - x, 1);
             if (isAvailable == true)
             {
                 if (canMove[1] == true)
                 {
                     available.Add(new int[] { startX + x, startY - x });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startX + x < 8 && startY + x < 8)//down right
         {
             isAvailable = IsAvailable(board, startX + x, startY + x, 2);
             if (isAvailable == true)
             {
                 if (canMove[2] == true)
                 {
                     available.Add(new int[] { startX + x, startY + x });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startY + x < 8)//right
         {
             isAvailable = IsAvailable(board, startX, startY + x, 3);
             if (isAvailable == true)
             {
                 if (canMove[3] == true)
                 {
                     available.Add(new int[] { startX, startY + x });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startX - x >= 0)//up
         {
             isAvailable = IsAvailable(board, startX - x, startY, 4);
             if (isAvailable == true)
             {
                 if (canMove[4] == true)
                 {
                     available.Add(new int[] { startX - x, startY });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startX - x >= 0 && startY - x >= 0)//up left
         {
             isAvailable = IsAvailable(board, startX - x, startY - x, 5);
             if (isAvailable == true)
             {
                 if (canMove[5] == true)
                 {
                     available.Add(new int[] { startX - x, startY - x });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startX - x >= 0 && startY + x < 8)//up right
         {
             isAvailable = IsAvailable(board, startX - x, startY + x, 6);
             if (isAvailable == true)
             {
                 if (canMove[6] == true)
                 {
                     available.Add(new int[] { startX - x, startY + x });
                 }
             }
         }
     }
     collision = new int[8];
     for (int x = 1; x < 8; ++x)
     {
         if (startY - x >= 0)//left
         {
             isAvailable = IsAvailable(board, startX, startY - x, 7);
             if (isAvailable == true)
             {
                 if (canMove[7] == true)
                 {
                     available.Add(new int[] { startX, startY - x });
                 }
             }
         }
     }
     return available;
 }
Esempio n. 22
0
 public abstract List<int[]> Test(ChessSquare[,] board, int startX, int startY, int endX, int endY);
Esempio n. 23
0
 public override void MovePiece(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     board[endX, endY].Piece = board[startX, startY].Piece;
     board[startX, startY].Piece = new Space();
 }
Esempio n. 24
0
 public override List<int[]> RestrictMovement(ChessSquare[,] board, int startX, int startY)
 {
     List<int[]> available = new List<int[]>();
     bool isAvailable = false;
     if (Color == ChessColor.DARK)
     {
         if (startX + 1 < 8)//down 1
         {
             isAvailable = IsEmpty(board, startX + 1, startY, 0);
             if (isAvailable == true)
             {
                 if (canMove[0] == true)
                 {
                     available.Add(new int[] { startX + 1, startY });
                 }
             }
         }
         if (_moves == 0)//down 2
         {
             isAvailable = IsEmpty(board, startX + 2, startY, 6);
             if (isAvailable == true)
             {
                 if (canMove[0] == true)
                 {
                     available.Add(new int[] { startX + 2, startY });
                 }
             }
         }
         if (startX + 1 < 8 && startY - 1 >= 0)//down Left 1
         {
             if (board[startX + 1, startY - 1].Piece.Color != Color && board[startX + 1, startY - 1].Piece.Color != ChessColor.NONE)
             {
                 isAvailable = IsAvailable(board, startX + 1, startY - 1, 1);
                 if (isAvailable == true)
                 {
                     if (canMove[1] == true)
                     {
                         available.Add(new int[] { startX + 1, startY - 1 });
                     }
                 }
             }
         }
         if (startX + 1 < 8 && startY + 1 < 8)//down right 1
         {
             if (board[startX + 1, startY + 1].Piece.Color != Color && board[startX + 1, startY + 1].Piece.Color != ChessColor.NONE)
             {
                 isAvailable = IsAvailable(board, startX + 1, startY + 1, 2);
                 if (isAvailable == true)
                 {
                     if (canMove[2] == true)
                     {
                         available.Add(new int[] { startX + 1, startY + 1 });
                     }
                 }
             }
         }
     }
     else
     {
         if (startX - 1 >= 0)//up 1
         {
             isAvailable = IsEmpty(board, startX - 1, startY, 3);
             if (isAvailable == true)
             {
                 if (canMove[3] == true)
                 {
                     available.Add(new int[] { startX - 1, startY });
                 }
             }
         }
         if (_moves == 0)//up 2
         {
             isAvailable = IsEmpty(board, startX - 2, startY, 7);
             if (isAvailable == true)
             {
                 if (canMove[3] == true)
                 {
                     available.Add(new int[] { startX - 2, startY });
                 }
             }
         }
         if (startX - 1 >= 0 && startY - 1 >= 0)//up left 1
         {
             if (board[startX - 1, startY - 1].Piece.Color != Color && board[startX - 1, startY - 1].Piece.Color != ChessColor.NONE)
             {
                 isAvailable = IsAvailable(board, startX - 1, startY - 1, 4);
                 if (isAvailable == true)
                 {
                     if (canMove[4] == true)
                     {
                         available.Add(new int[] { startX - 1, startY - 1 });
                     }
                 }
             }
         }
         if (startX - 1 >= 0 && startY + 1 < 8)//up right 1
         {
             if (board[startX - 1, startY + 1].Piece.Color != Color && board[startX - 1, startY + 1].Piece.Color != ChessColor.NONE)
             {
                 isAvailable = IsAvailable(board, startX - 1, startY + 1, 5);
                 if (isAvailable == true)
                 {
                     if (canMove[5] == true)
                     {
                         available.Add(new int[] { startX - 1, startY + 1 });
                     }
                 }
             }
         }
     }
     return available;
 }
Esempio n. 25
0
 public override bool CheckMovement(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     return false;
 }
Esempio n. 26
0
 public override List<int[]> Test(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     bool isMoveSet = false;
     List<int[]> available = new List<int[]>();
         if (startX - 2 >= 0 && startY - 1 >= 0)//up 2 left 1
         {
             available.Add(new int[] { startX - 2, startY - 1 });
             if (startX - 2 == endX && startY - 1 == endY)
             {
                 isMoveSet = true;
             }
         }
     Test2(available, isMoveSet);
     if (isMoveSet == false)
     {
         if (startX - 2 >= 0 && startY + 1 < 8)//up 2 right 1
         {
             available.Add(new int[] { startX - 2, startY + 1 });
             if (startX - 2 == endX && startY + 1 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         if (startX - 1 >= 0 && startY - 2 >= 0)//up 1 left 2
         {
             available.Add(new int[] { startX - 1, startY - 2 });
             if (startX - 1 == endX && startY - 2 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         if (startX - 1 >= 0 && startY + 2 < 8)//up 1 right 2
         {
             available.Add(new int[] { startX - 1, startY + 2 });
             if (startX - 1 == endX && startY + 2 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         if (startX + 2 < 8 && startY - 1 >= 0)//down 2 left 1
         {
             available.Add(new int[] { startX + 2, startY - 1 });
             if (startX + 2 == endX && startY - 1 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         if (startX + 2 < 8 && startY + 1 < 8)//down 2 right 1
         {
             available.Add(new int[] { startX + 2, startY + 1 });
             if (startX + 2 == endX && startY + 1 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         if (startX + 1 < 8 && startY - 2 >= 0)//down 1 left 2
         {
             available.Add(new int[] { startX + 1, startY - 2 });
             if (startX + 1 == endX && startY - 2 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     if (isMoveSet == false)
     {
         if (startX + 1 < 8 && startY + 2 < 8)//down 1 right 2
         {
             available.Add(new int[] { startX + 1, startY + 2 });
             if (startX + 1 == endX && startY + 2 == endY)
             {
                 isMoveSet = true;
             }
         }
         Test2(available, isMoveSet);
     }
     return available;
 }
Esempio n. 27
0
 public override void MovePiece(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
 }
Esempio n. 28
0
 public override List<int[]> RestrictMovement(ChessSquare[,] board, int startX, int startY)
 {
     ResetMovement();
     List<int[]> available = new List<int[]>();
     bool isAvailable = false;
     if (startX - 2 >= 0 && startY - 1 >= 0)//up 2 left 1
     {
         isAvailable = IsAvailable(board, startX - 2, startY - 1, 0);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX - 2, startY - 1 });
         }
     }
     if (startX - 2 >= 0 && startY + 1 < 8)//up 2 right 1
     {
         isAvailable = IsAvailable(board, startX - 2, startY + 1, 1);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX - 2, startY + 1 });
         }
     }
     if (startX - 1 >= 0 && startY - 2 >= 0)//up 1 left 2
         {
             isAvailable = IsAvailable(board, startX - 1, startY - 2, 2);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX - 1, startY - 2 });
         }
     }
     if (startX - 1 >= 0 && startY + 2 < 8)//up 1 right 2
     {
         isAvailable = IsAvailable(board, startX - 1, startY + 2, 3);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX - 1, startY + 2 });
         }
     }
     if (startX + 2 < 8 && startY - 1 >= 0 )//down 2 Left 1
     {
         isAvailable = IsAvailable(board, startX + 2, startY - 1, 4);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX + 2, startY - 1 });
         }
     }
     if (startX + 2 < 8 && startY + 1 < 8)//down 2 right 1
     {
         isAvailable = IsAvailable(board, startX + 2, startY + 1, 5);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX + 2, startY + 1 });
         }
     }
     if (startX + 1 < 8 && startY - 2 >= 0)//down 1 Left 2
     {
         isAvailable = IsAvailable(board, startX + 1, startY - 2, 6);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX + 1, startY - 2 });
         }
     }
     if (startX + 1 < 8 && startY + 2 < 8)//down 1 right 2
     {
         isAvailable = IsAvailable(board, startX + 1, startY + 2, 7);
         if (isAvailable == true)
         {
             available.Add(new int[] { startX + 1, startY + 2 });
         }
     }
     return available;
 }
Esempio n. 29
0
 public override List<int[]> Search(ChessSquare[,] board, int startX, int startY, int endX, int endY)
 {
     return new List<int[]>();
 }
Esempio n. 30
0
 public List<int[]> Attacks(ChessSquare[,] board, int startX, int startY)
 {
     ResetMovement();
     List<int[]> available = new List<int[]>();
     bool isAvailable = false;
     if (Color == ChessColor.DARK)
     {
         if (startX + 1 < 8 && startY - 1 >= 0)//down Left 1
         {
             if (board[startX + 1, startY - 1].Piece.Color != Color)
             {
                 isAvailable = IsAvailable(board, startX + 1, startY - 1, 1);
                 if (isAvailable == true)
                 {
                     if (canMove[1] == true)
                     {
                         available.Add(new int[] { startX + 1, startY - 1 });
                     }
                 }
             }
         }
         if (startX + 1 < 8 && startY + 1 < 8)//down right 1
         {
             if (board[startX + 1, startY + 1].Piece.Color != Color)
             {
                 isAvailable = IsAvailable(board, startX + 1, startY + 1, 2);
                 if (isAvailable == true)
                 {
                     if (canMove[2] == true)
                     {
                         available.Add(new int[] { startX + 1, startY + 1 });
                     }
                 }
             }
         }
     }
     else
     {
         if (startX - 1 >= 0 && startY - 1 >= 0)//up left 1
         {
             if (board[startX - 1, startY - 1].Piece.Color != Color)
             {
                 isAvailable = IsAvailable(board, startX - 1, startY - 1, 4);
                 if (isAvailable == true)
                 {
                     if (canMove[4] == true)
                     {
                         available.Add(new int[] { startX - 1, startY - 1 });
                     }
                 }
             }
         }
         if (startX - 1 >= 0 && startY + 1 < 8)//up right 1
         {
             if (board[startX - 1, startY + 1].Piece.Color != Color)
             {
                 isAvailable = IsAvailable(board, startX - 1, startY + 1, 5);
                 if (isAvailable == true)
                 {
                     if (canMove[5] == true)
                     {
                         available.Add(new int[] { startX - 1, startY + 1 });
                     }
                 }
             }
         }
     }
     return available;
 }