Skip to content

alexqfredrickson/FenParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FenParser

FenParser is a C# class library for .NET 8.0 that parses Forsyth-Edwards notated records.

Basic usage

First, construct a FenParser object and feed it a FEN string.

FenParser parser = new FenParser("5k2/ppp5/4P3/3R3p/6P1/1K2Nr2/PP3P2/8 b - - 1 32");

Now FenParser's BoardStateData field exposes all of the necessary metadata used to describe the game's state, including:

  • The active player color
  • The en-passant square (if eligible)
  • Piece placement and ranks
  • Each player's kingside/queenside castling availability
  • The game's halfmove counter
  • The game's turn number
bool castlingAvailability = parser.BoardStateData.WhiteCanQueensideCastle; // false

Additionally, the BoardStateData.ToConsole() method returns a command-line visualization of the board state.

-----------------
| | | | | |k| | |
-----------------
|p|p|p| | | | | |
-----------------
| | | | |P| | | |
-----------------
| | | |R| | | |p|
-----------------
| | | | | | |P| |
-----------------
| |K| | |N|r| | |
-----------------
|P|P| | | |P| | |
-----------------
| | | | | | | | |
-----------------

The active player is Black.
White cannot castle, and Black cannot castle.
There are no squares eligible for en-passant capture.
There has been 1 halfmove since the last pawn advance or capture.
This is move number 32.

About

A C# 8.0 FEN string parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages