Exemple #1
0
        public bool moveCreatesCheck(Square origin, Square dest)
        {
            // Creates a copy of the board and simulates a move
            Board copy = new Board();

            for (int i = 0; i < Constant.SIZE; i++)
            {
                for (int j = 0; j < Constant.SIZE; j++)
                {
                    copy.getSquare(i, j).piece = this._squares[i][j].piece;
                }
            }

            copy.getSquare(origin.x, origin.y).piece = null;
            copy.getSquare(dest.x, dest.y).piece     = origin.piece;

            // returns true if the move made by [x] makes [x] be in check
            return(copy.isChecked(copy.getKing(origin.piece.isWhite), copy.getKingSquare(origin.piece.isWhite)));
        }