예제 #1
0
 internal Piece(ChessPieceType chessPiece, ChessPieceColor chessPieceColor)
 {
     this.PieceType          = chessPiece;
     this.PieceColor         = chessPieceColor;
     this.LastValidMoveCount = this.PieceType == ChessPieceType.Pawn || this.PieceType == ChessPieceType.Knight ? 2 : 0;
     this.ValidMoves         = new Stack <byte>(this.LastValidMoveCount);
     this.PieceValue         = Piece.CalculatePieceValue(this.PieceType);
     this.PieceActionValue   = Piece.CalculatePieceActionValue(this.PieceType);
 }
예제 #2
0
파일: Board.cs 프로젝트: jskubick/ChessCore
        private static bool PromotePawns(Board board, Piece piece, byte dstPosition, ChessPieceType promoteToPiece)
        {
            if (piece.PieceType == ChessPieceType.Pawn)
            {
                if (dstPosition < 8)
                {
                    board.Squares[dstPosition].Piece.PieceType        = promoteToPiece;
                    board.Squares[dstPosition].Piece.PieceValue       = Piece.CalculatePieceValue(promoteToPiece);
                    board.Squares[dstPosition].Piece.PieceActionValue = Piece.CalculatePieceActionValue(promoteToPiece);
                    return(true);
                }
                if (dstPosition > 55)
                {
                    board.Squares[dstPosition].Piece.PieceType        = promoteToPiece;
                    board.Squares[dstPosition].Piece.PieceValue       = Piece.CalculatePieceValue(promoteToPiece);
                    board.Squares[dstPosition].Piece.PieceActionValue = Piece.CalculatePieceActionValue(promoteToPiece);
                    return(true);
                }
            }

            return(false);
        }