This is the most popular method: it's used by practically all the modern chess databases like Chessbase and Chess Assistant.dracflamloc wrote:You theoretically could actually encode every single possible move into 8 bits. I'm pretty sure anyway. Though you may have a hard time if you encode moves that a pawn can make if it gets turned into a queen. You'd probably run over 0-255 limit in that case.
Example:
Pawn 1: Move 1 forward, Move 1 up-left, Move 1 up-right
3 moves. Each pawn would have 3 moves so thats a total of 24 moves. 0-23 would be for pawn moves.
Just analyze every move a piece can make. You'll probably be right on the border of the 8-byte limit.
They use a byte to store the index of the move in an array of the possible moves in the position.
In the past NICbase used bits, and not bytes: very efficient but more complicated.
The problem of > 255 moves is simply solved: it's a very rare condition, and when happens you can consume a second byte.
The overhead is not so big, and a little footprint of the moves becomes important when you store millions of games in a database.