XOF Format
Open format
XOF, the Xiangqi Open Format
XOF is an open plain-text file format for xiangqi games. One file keeps the moves, variations of any depth, a comment and a timestamp for every move, and any game information you want to add. Anyone may read it, write it and use it, free of charge.
SuperXiangQi supports XOF fully, on desktop and on mobile. It opens, edits and saves XOF games with all their variations and comments. SuperXiangQi Desktop also converts PGN, DhtmlXQ, CCBridge CBF and CBL files to XOF, and imports XOF games into your own game database.
The problem
What is wrong with today’s formats
A game record has two layers: how one move is written, and how a whole game is stored. Both have serious problems today.
Ambiguous moves
Without a front or rear mark, C9+1 cannot tell which of two Cannons on street 9 moved. A reader needs the position and a legal-move generator just to understand the text.
Only three positions
Front, middle and rear handle only three pieces. Up to five Pawns can stand on one street, and the 4th and 5th Pawn have no name.
Same text, different meaning
In the Vietnamese notation of 2004, P2-5 is a sideways move. In the Vietnamese notation of 2021, the same P2-5 is a retreat. You must know which rule book the game was written with.
Different symbols and characters
Two-letter piece symbols such as Tg make moves different lengths. Chinese records mix 一…九 with 1–9 and full-width digits, and Traditional with Simplified characters.
Official books are not consistent
The same book writes two Rooks on one street sometimes as R4-2, sometimes as +R-2, and no rule says what to do when two streets each hold doubled Pawns.
Printing errors cannot be detected
In one rule book we found 13 diagrams with wrong moves. They showed up only when the moves were replayed on a board.
Coordinates are hard to read
Coordinate notations such as ICCS h2e2 are unambiguous, but almost no player records or thinks in them.
Closed binary files
Most xiangqi programs save games in their own binary formats, some encrypted or undocumented. When the program dies, the archive dies with it.
PGN has no variations
Xiangqi PGN files never carry variations, so the analysis, the most valuable part of a commented game, is lost.
PGN move text is not standard
Each writer uses its own piece letters, language and notation, and the file does not say which. You must tell the reader the key by hand.
PGN is hard to parse
Variations, comments, move numbers and annotations share one free-flowing text stream. A correct reader takes far more work than it should.
No place for move timing
Electronic boards and online play record when each move was made, but no format has a place to keep it.
The answer
Why XOF Format
Anyone can read it, anyone can write it, nothing is ambiguous.
| Problem today | What XOF does |
|---|---|
| Closed binary formats | Plain UTF-8 text that opens in any text editor |
| Ambiguous moves | The street number is always written, with a position prefix when pieces share a street |
| Meaning depends on the rule book | One meaning for each sign: + advance, - retreat, = sideways |
| Piece letters differ by language | Each game declares its own Pieces Key: English, Chinese, Vietnamese or any other |
| No variations | Variations of any depth, with any number of alternatives |
| Hard to parse | Very easy to parse, one move per line, in tab-separated columns |
| No move timing, no comments | Every move line has its own timestamp and comment |
One move per line also gives clean git diff output, easy search with standard tools, one text column per game in a database, and printing errors you can fix in a text editor.
Specification
The XOF specification
The specification describes every part of an XOF file: encoding, file structure, headers, the Pieces Key, move text, variations, storing games in a database, and a complete example. It is published on GitHub in three languages, and as a PDF.
Developers
Coding with XOF
Reading and writing XOF is plain text parsing: split the file into games, each game into header and moves, each move line into its columns, and read variations with one small recursive function.
XOFWorker is the open-source C# (.NET) library that SuperXiangQi uses to read and write XOF. It reads large files game by game, writes one game or many, and has the Pieces Key presets for English, Chinese and Vietnamese. Ports to other languages are a short piece of work if you follow the specification.