Exemplo n.º 1
0
        /// <summary>
        /// Performs the move. I move is only pseudo legal (putting own king in check)
        /// the move isn't executed.
        /// </summary>
        /// <returns>True if move could be carried out, false otherwise.</returns>
        private bool CastlingExecute(Board board)
        {
            BoardState afterState = m_beforeState = board.State;

            //Kings move
            board.MovePiece(m_from, m_to);

            //Rooks move
            board.MovePiece(m_rookFrom, m_rookTo);

            SetCastlingAvailabilety(ref afterState);
            SetEnPassentTarget(ref afterState);
            EndTurn(ref afterState);

            board.State = afterState;
            board.AddToHistory();

            if (board.IsCheck(m_beforeState.ColorToPlay))
            {
                CastlingUnExecute(board);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs the move. I move is only pseudo legal (putting own king in check)
        /// the move isn't executed.
        /// </summary>
        /// <returns>True if move could be carried out, false otherwise.</returns>
        public virtual bool Execute()
        {
            BoardState afterState = m_beforeState = m_board.State;

            m_board.MovePiece(m_from, m_to);

            SetCastlingAvailabilety(ref afterState);
            SetEnPassentTarget(ref afterState);
            EndTurn(ref afterState);

            m_board.State = afterState;
            m_board.AddToHistory();

            if (m_board.IsCheck(m_beforeState.ColorToPlay))
            {
                UnExecute();
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs the move. I move is only pseudo legal (putting own king in check)
        /// the move isn't executed.
        /// </summary>
        /// <returns>True if move could be carried out, false otherwise.</returns>
        private bool EnPassantExecute(Board board)
        {
            BoardState afterState = m_beforeState = board.State;

            board.PlacePiece(m_beforeState.EnPassantTarget, Piece.None);
            board.MovePiece(m_from, m_to);

            SetCastlingAvailabilety(ref afterState);
            SetEnPassentTarget(ref afterState);
            EndTurn(ref afterState);

            board.State = afterState;
            board.AddToHistory();

            if (board.IsCheck(m_beforeState.ColorToPlay))
            {
                EnPassantUnExecute(board);
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Performs the move. If move is only pseudo legal (putting own king in check)
        /// the move isn't executed.
        /// </summary>
        /// <returns>True if move could be carried out, false otherwise.</returns>
        private bool StandardExecute(Board board)
        {
            BoardState afterState = m_beforeState = board.State;

              board.MovePiece(m_from, m_to);

              SetCastlingAvailabilety(ref afterState);
              SetEnPassentTarget(ref afterState);
              EndTurn(ref afterState);

              board.State = afterState;
              board.AddToHistory();

              if (board.IsCheck(m_beforeState.ColorToPlay))
              {
            StandardUnExecute(board);
            return false;
              }

              return true;
        }