src/Engine/Utilities/ChessFormatter.cs
/// <summary>
/// Converts a chess piece to an approximate numerical value.
/// </summary>
/// <param name="piece">The piece to be converted to a value.</param>
/// <returns>The approximate number of pawns the piece is worth.</returns>
Converts a chess piece to an approximate numerical value.
Converts a chess piece to an approximate numerical value .
public static int GetPieceValue(ChessPieces piece) =>
            piece switch
            {
                ChessPieces.WhiteQueen => 9,
                ChessPieces.BlackQueen => -9,
                ChessPieces.WhiteRook => 5,
                ChessPieces.BlackRook => -5,
                ChessPieces.WhiteBishop => 3,
                ChessPieces.BlackBishop => -3,
                ChessPieces.WhiteKnight => 3,
                ChessPieces.BlackKnight => -3,
                ChessPieces.WhitePawn => 1,
                ChessPieces.BlackPawn => -1,
                _ => 0
            };
public static int GetPieceValue ( ChessPieces piece ) => piece switch { ChessPieces . WhiteQueen => 9 , ChessPieces . BlackQueen => - 9 , ChessPieces . WhiteRook => 5 , ChessPieces . BlackRook => - 5 , ChessPieces . WhiteBishop => 3 , ChessPieces . BlackBishop => - 3 , ChessPieces . WhiteKnight => 3 , ChessPieces . BlackKnight => - 3 , ChessPieces . WhitePawn => 1 , ChessPieces . BlackPawn => - 1 , _ => 0 } ;
Converts a chess piece to an approximate numerical value.
Converts a chess piece to an approximate numerical value .
// TODO : This is fine for purposes of displaying advantage, //        but if this develops into a fuller chess engine, it //        will need a more sophisticated system and kings will need //        a value.
The approximate number of pawns the piece is worth.
The approximate number of pawns the piece is worth .
piece
ChessPieces
The piece to be converted to a value.
The piece to be converted to a value .