What is FEN?
FEN (Forsyth-Edwards Notation) is a method of recording a Xiangqi position, inherited from chess.
A single string is enough to represent a position, which is very convenient, and engines also receive positions through FEN.
A FEN contains at least the position and the side to move.
Basic FEN recording rules
- Start recording from Black's back rank and go down to Red's back rank; within each rank, record from left to right (from Red's point of view).
- Each letter stands for a type of piece: k King/General, a Advisor, b Elephant, c Cannon, n Horse, r Chariot, p Pawn. Uppercase letters are Red pieces and lowercase letters are Black pieces.
- For empty squares, record the number of consecutive empty squares (some notations also record each empty square separately as 1).
- After finishing a rank, end it with / and then start the next rank. Do not write / after the last rank (Red's back rank).
- After all ranks are recorded, write a space, then w or b (w means Red moves first, b means Black moves first). Some notations also use r for Red to move.
Example

The FEN of this diagram is:
3k1a3/4a4/5n3/9/9/9/9/9/9/4KR3 wFEN viewer
Look at the diagram. Start from Black's back rank and go from left to right. The first, second and third squares are empty, and since there are 3 consecutive empty squares, we first write a 3. Then comes the Black General, written k, followed by one empty square and a Black Advisor, written 1a. Then again 3 consecutive empty squares, written 3. That finishes Black's back rank, and we write a /. This is where the first segment 3k1a3/ comes from. Then we record Black's second rank, and so on until Red's back rank is finished. Note that Red pieces are written in uppercase. Finally, a space and w, where w means it is Red's turn to move in this diagram.
Other FEN fields
A full FEN may look like this:
3k1a3/4a4/5n3/9/9/9/9/9/9/4KR3 w - - 0 1The extra - - 0 1 follows. The "- -" has no meaning: FEN was ported from chess, so the chess castling and en passant symbols were kept.
As for the 0 1, the former means the number of moves since the last capture is 0, and the latter means the current move number is 1. The number of moves since the last capture is the 60-move rule information; for example, under the 60-move rule, when this number reaches 120 (half-moves), the game is drawn.
If a FEN has only the basic position and side to move, the engine and GUI will assume - - 0 1 or - - 0 0 by default.
movelist
A FEN only represents a single position, while FEN plus a movelist can express the move history.
For example:
5a3/3ka4/5n3/9/9/9/9/9/9/4K1R2 w moves g0f0 d8d9The position reached by this movelist is the position in the "Example" section.
This FEN plus movelist means: starting from the position "5a3/3ka4/5n3/9/9/9/9/9/9/4K1R2 w", the moves g0f0 and d8d9 were played.
A movelist is simply a record of coordinate-to-coordinate moves. From Red's point of view, all files from left to right are labeled a to i, and all ranks from bottom to top (Red's back rank to Black's back rank) are labeled 0 to 9, so each of the 90 points has a coordinate. g0f0 means the piece at g0 moved to f0.
