Beispiel #1
0
        /// <summary>
        /// Takes back (undo) the move. Nothing is done to verify if undoing the move is actually
        /// valid for the board associated to this move.
        /// </summary>
        private void PawnPromotionUnExecute(Board board)
        {
            board.RemoveFromHistory();

            board.PlacePiece(m_to, m_piece);
            board.MovePiece(m_to, m_from);
            board.PlacePiece(m_to, m_capture);

            board.State = m_beforeState;
        }
Beispiel #2
0
        /// <summary>
        /// Takes back (undo) the move. Nothing is done to verify if undoing the move is actually
        /// valid for the board associated to this move.
        /// </summary>
        public virtual void UnExecute()
        {
            m_board.RemoveFromHistory();

            m_board.MovePiece(m_to, m_from);
            m_board.PlacePiece(m_to, m_capture);

            m_board.State = m_beforeState;
        }
Beispiel #3
0
        /// <summary>
        /// Takes back (undo) the En-Passant capture move. Nothing is done to verify if undoing the move is actually
        /// valid for the board associated to this move.
        /// </summary>
        private void EnPassantUnExecute(Board board)
        {
            board.RemoveFromHistory();

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

            board.State = m_beforeState;
        }
Beispiel #4
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);
        }
Beispiel #5
0
        /// <summary>
        /// Takes back (undo) the move. Nothing is done to verify if undoing the move is actually
        /// valid for the board associated to this move.
        /// </summary>
        private void StandardUnExecute(Board board)
        {
            board.RemoveFromHistory();

              board.MovePiece(m_to, m_from);
              board.PlacePiece(m_to, m_capture);

              board.State = m_beforeState;
        }
Beispiel #6
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 PawnPromotionExecute(Board board)
        {
            BoardState afterState = m_beforeState = board.State;

              board.MovePiece(m_from, m_to);
              board.PlacePiece(m_to, m_promoteTo);

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

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

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

              return true;
        }
Beispiel #7
0
        /// <summary>
        /// Takes back (undo) the En-Passant capture move. Nothing is done to verify if undoing the move is actually
        /// valid for the board associated to this move.
        /// </summary>
        private void EnPassantUnExecute(Board board)
        {
            board.RemoveFromHistory();

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

              board.State = m_beforeState;
        }