Compact Game Notation Specification

Compact Game Notation (followingly, "CGN") is made to fit chess games in as few bytes as possible at the cost of humans not being able to read or write it which makes it perfect for digital game archives. Furthermore, converting between CGN, Portable Game Notation (PGN) and other notations and is an easy task for computers.

CGN uses big-endian which means that the most significant bit comes first. All strings are encoded and decoded using UTF-8.

As there are multiple CGN versions, I've decided I put their specifications in this single, sharable HTML file for maximum simplicity. If you want to implement all versions or only the latest version is up to you.

Tags

The names and meanings of tags are inherited from PGN and as in PGN, the moves of the game come after the tags.

The first byte of a tag defines its meaning:

and the bytes after will be its value, terminated by a null-byte.

Moves

The first bit of a move determines if this is a control move (1) or a played move (0).

If a played move is given, there are 15 more bits to it (totaling 2 bytes):

However, if a control move was given, this is not an actual move but rather an indicator with a total length of 1 byte. The remaining 7 bits declare its meaning:

What's new in Version 2

Tags

The names and meanings of tags are inherited from PGN but there are a couple of exceptions:

Moves

The first bit of a move determines if this is a control move (1) or a played move (0).

If a played move was given, there are 15 more bits to it (totaling 2 bytes):

However, if a control move was given, this is not an actual move but rather an indicator with a total length of 1 byte. The remaining 7 bits will declare its meaning:


Copyright (c) 2018, Tim "timmyRS" Speckhals