Show / Hide Table of Contents

Class Fen

This class provides constants and static functions to manage FEN strings (see https://chessprogramming.wikispaces.com/Forsyth-Edwards+Notation)

Inheritance
System.Object
Fen
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: PonzianiComponents.Chesslib
Assembly: PonzianiComponents.dll
Syntax
public class Fen

Fields

| Improve this Doc View Source

INITIAL_POSITION

FEN Representation of the starting position in standard chess

Declaration
public const string INITIAL_POSITION = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
Field Value
Type Description
System.String
| Improve this Doc View Source

PIECE_CHAR_BBISHOP

Character representing the black bishop in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_BBISHOP = 'b'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_BKING

Character representing the white king in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_BKING = 'k'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_BKNIGHT

Character representing the black knight in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_BKNIGHT = 'n'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_BPAWN

Character representing the black pawn in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_BPAWN = 'p'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_BQUEEN

Character representing the black king in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_BQUEEN = 'q'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_BROOK

Character representing the black queen in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_BROOK = 'r'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_NONE

Character representing no piece (empty square)

Declaration
public const char PIECE_CHAR_NONE = ' '
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_WBISHOP

Character representing the white bishop in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_WBISHOP = 'B'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_WKING

Character representing the white king in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_WKING = 'K'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_WKNIGHT

Character representing the white knight in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_WKNIGHT = 'N'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_WPAWN

Character representing the white pawn in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_WPAWN = 'P'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_WQUEEN

Character representing the white king in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_WQUEEN = 'Q'
Field Value
Type Description
System.Char
| Improve this Doc View Source

PIECE_CHAR_WROOK

Character representing the white queen in Forsyth-Edwards-Notation (FEN)

Declaration
public const char PIECE_CHAR_WROOK = 'R'
Field Value
Type Description
System.Char

Methods

| Improve this Doc View Source

CheckValid(String)

Checks if a given string is a valid Fen string. This means that the fen can be parsed and a position can be determined, but not that the position is legal. Fens without 50 move counter and movenumber (as used in EPD) are accepted

Declaration
public static bool CheckValid(string fen)
Parameters
Type Name Description
System.String fen

Fen to be checked

Returns
Type Description
System.Boolean

treu, if valid

| Improve this Doc View Source

FenPartFromBoard(Char[])

Creates the first part of a FEN string from a board array

Declaration
public static string FenPartFromBoard(char[] board)
Parameters
Type Name Description
System.Char[] board
Returns
Type Description
System.String
| Improve this Doc View Source

GetPieceArray(String)

Calulates an Array of Piece Characters represented by the provided string in FEN Notation. The array representation used is A1 = 0, H1 = 7, H8 = 63

Declaration
public static char[] GetPieceArray(string fen)
Parameters
Type Name Description
System.String fen

The position in FEN representation

Returns
Type Description
System.Char[]
| Improve this Doc View Source

ParsePieceChar(Char)

Get's the piece for a piece characteristic (Example Black Queen for 'q' and White Pawn for 'p'

Declaration
public static Piece ParsePieceChar(char c)
Parameters
Type Name Description
System.Char c
Returns
Type Description
Piece
| Improve this Doc View Source

ParseSquare(String)

Parses a square provided by it's field name (such as 'a1', 'e5' or 'h8')

Declaration
public static Square ParseSquare(string squareString)
Parameters
Type Name Description
System.String squareString

The square as string

Returns
Type Description
Square

The square defined by squareString

Remarks

This method doesn't make any error checking. If invalid input is provided this might result in a crash

| Improve this Doc View Source

PieceChar(Piece)

Get's the char used for the piece (Example 'q' for black queen or 'P' for White pawn)

Declaration
public static char PieceChar(Piece piece)
Parameters
Type Name Description
Piece piece
Returns
Type Description
System.Char
| Improve this Doc View Source

Swap(String)

Creates a fen string representing an equivalent position with colors reversed

Declaration
public static string Swap(string fen)
Parameters
Type Name Description
System.String fen

the positions which shall be swapped

Returns
Type Description
System.String

fen string of the swapped position

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX