class FEN
package chess.fen
Represents a FEN record object.
Static methods
staticcreateFENFromComponents(fieldPlacement:String, activeColor:String, castlingAvailability:String, enPassant:String, halfmoveClock:Int, fullmoveNumber:Int):FEN
Second constructor to create a FEN object from the six component fields of a FEN record.
If any value is null the result is unspecified.
Parameters:
fieldPlacement | Piece placement (from White's perspective). Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file "a" through file "h". Following the Standard Algebraic Notation (SAN), each piece is identified by a single letter taken from the standard English names (pawn = "P", knight = "N", bishop = "B", rook = "R", queen = "Q" and king = "K"). White pieces are designated using upper-case letters ("PNBRQK") while black pieces use lowercase ("pnbrqk"). Empty squares are noted using digits 1 through 8 (the number of empty squares), and "/" separates ranks. |
---|---|
activeColor | Active color. "w" means White moves next, "b" means Black moves next. |
castlingAvailability | Castling availability. If neither side can castle, this is "-". Otherwise, this has one or more letters: "K" (White can castle kingside), "Q" (White can castle queenside), "k" (Black can castle kingside), and/or "q" (Black can castle queenside). A move that temporarily prevents castling does not negate this notation. |
enPassant | En passant target square in algebraic notation. If there's no en passant target square, this is "-". If a pawn has just made a two-square move, this is the position "behind" the pawn. This is recorded regardless of whether there is a pawn in position to make an en passant capture. |
halfmoveClock | Halfmove clock: The number of halfmoves since the last capture or pawn advance, used for the fifty-move rule. |
fullmoveNumber | Fullmove number: The number of the full move. It starts at 1, and is incremented after Black's move. |
staticdeserialize(filePath:String):FEN
Creates a FEN object from a .fen
file.
Works only for sys targets. Read more about sys targets here https://haxe.org/manual/std-sys.html.
For illegal input files, the result is mostly unspecified.
If the file specified in filePath
does not exist, null
is returned.
If the target language does not support the sys API, null
is returned.
Parameters:
filePath | the file to load, either as relative or absolute path, with file extension. |
---|
Constructor
new(fENString:String)
Constructor. Creates a new FEN object from a FEN string.
If fENString
is invalid the result is unspecified.
Parameters:
fENString | Any valid FEN record. |
---|
Methods
getBoard():String
Returns a string representation of the full board in dextrograd order.
White pieces are depicted as upper case letters, black pieces as lower case letters.
Empty fields are depicted as spaces, not with a number.
Rows are seperated by "\n" (LF).
split(fENString:String):Array<String>
Splits a FEN record string at its specified delimiter " " (whitespace).
Returns an Array<String>
containing the six individual fields of the FEN record.
split(fENString)[0]
contains fieldPlacement
.
split(fENString)[1]
contains activeColor
.
split(fENString)[2]
contains castlingAvailability
.
split(fENString)[3]
contains enPassant
.
split(fENString)[4]
contains halfmoveClock
.
split(fENString)[5]
contains fullmoveNumber
.
For invalid FEN records the result is unspecifed.
Parameters:
fENString | Any valid FEN record. |
---|