How To Read The FEN Text?
The key to door to communicate with computersBr1rQ1Rb/rBPnNpbR/1PB2bp1/Pn1BbKNp/pNkbB1nP/1pb2BP1/RbpNnPBr/bR1qR1rB w - - 0 1
Yep, that's gibberish, and you will probably walk away thinking that this is a another one of those spam blogs that was written by a 8 year old, and report them for making an empty blog.
Well, no! infact, this is the complete opposite of gibberish, This is:
Forsyth–Edwards Notation
What Is The FEN (Forsyth–Edwards Notation) Text?
Oooooh, Looks like a very complicated device that is part of an engine that sends people to mars.
Fine I'll stop :D
Forsyth–Edwards Notation (FEN) is a standard notation for describing a particular board position of a chess game. The purpose of FEN is to provide all the necessary information to restart a game from a particular position.
Let's say you wanna send a very complicated puzzle to your best friend, There are exactly 2 ways to do that, you either:
1. Send them a screen shot of the puzzle
2. Send them a link to the lichess board editor
Now #1 takes a lot of time, you have to upload an imgur post, copy the link and go back to lichess again and you have to make sure that the upload is completed otherwise the .jpg file will show as undefined...
But #2 is easy, you go to the editor, set up the position, and grab the URL the share it with your friend.
Did you notice that the link to that exact position (starting position as example) somewhat weird?
https://lichess.org/analysis/rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR_w_KQkq_-_0_1?color=white
You see? the rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR_w_KQkq_-_0_1 part?
That, my friend, is the FEN text.
It's how computers recognize positions, the computer knows where every piece are and everything you would know just based by the strange text.
There are more than a billion trillion positions, but for every position there is one corresponding FEN text.
It's like giving the computer eyes to see the position via a code.
FEN is based on a system developed by Scottish newspaper journalist David Forsyth, His system became popular in the 19th century, then Steven J. Edwards extended it to support its use by computers. (So it's called the Forsyth–Edwards Notation, Duh!) ''FEN'' is defined in the "Portable Game Notation Specification and Implementation Guide" In the for chess games, FEN is used to define initial positions other than the standard one.
BUT FEN does not provide sufficient information to decide whether a draw by threefold repetition may be legally claimed or a draw offer may be accepted; for that, a different format such as Extended Position Description is needed, that's a whole new chapter and we are getting really deep.
Let's start with an empty board...
Still here? good! because this is the good stuff.
First, if you look closely at the FEN; rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1, you will see there are two parts:
The main board: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
And the extra info: w KQkq - 0 1
And these are the pieces! you will understand later!
| Piece name | FEN transfer |
|---|---|
| White King | K |
| White Queen | Q |
| White Rook | R |
| White Bishop | B |
| White Knight | N |
| White Pawn | P |
| Black King | k |
| Black Queen | q |
| Black Rook | r |
| Black Bishop | b |
| Black Knight | n |
| Black Pawn | p |
Let's first see the main body, with an empty board!
8/8/8/8/8/8/8/8
As you can see, the ''8'' means that there's nothing on the 8th rank, nothing on the 7th rank... all the way to the 1st rank.
The ''8'' here specifies there is 8 blank spaces counting from left to right.
Now let's put a king on the board.
2K5/8/8/8/8/8/8/8
You see how the fen changes? it notices that counting left to right, there are two blank spaces, and then a white king, and then five blank spaces.
And ofcouse there is still nothing on the 1-7th ranks.
2K3n1/8/8/8/8/8/8/8
Now there's a black knight on the board!
Counting left to right again, there are two blank spaces, a white king, 3 blank spaces, a black knight, a blank space!
Whoa! things are geting complicated, but let figure this out a rank by a time.
First, starting with the 8th rank, it's the same king & knight position we saw before, so it's still 2K3n1
Then the 7th rank, we have 3 blank spaces, a white rook, then 4 blank spaces. so it's 3R4
6th rank we have 1 blank space, a black king, a black knight, and 5 blank spaces so it's 1kn5
Do it again for every rank, and you will get...
2K3n1/3R4/1kn5/6p1/8/5q2/2Q5/1B2b3
And that is the board!
The Extra Info
Remember i said there was another half of the FEN?
Well that part is easy compared to the main part: w KQkq - 0 1
The ''w'' means it's white to move, ''b'' for black
KQkq means white has rights the castle kingside and queen side (KQ) and so does black (kq)
If, let's say white can only castle queenside, and black can only castle kingside it becomes: Qk
If both sides can't castle than the KQkq will be replaced by a ''-''
The other ''-'' just exits, not really doing anything...
The ''0'' means it's been 0 moves since the last pawn move, it's a value for the 50-move rule. if it's ''50'' then it's a draw to the 50-move.
The ''1'' means it's the first move in the game, if it's 7 it means the game has been played 7 turns.
Mixing It Together!
If we mix the main board with the extra info we get a complete FEN text!
For example, this is the starting position: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
And the FEN is ready to be used!
Oh i forgot to mention, when entering the FEN in a lichess analysis board, make sure the Extra Info bit; w KQkq - 0 1 gets turned into _ w_KQkq_-_0_1
Every space get's morphed into a underdash!
Thanks For Reading!
Thank you for the time it took for you to read this study! I hope you learned something new! (That's the whole point lol)
It's been a while since i posted a blog, and i look further to post more!
Please like the blog if you enjoyed it!
