How to store a chess position in 26 bytes using bit-level magic (2022)

In this post, the author explores the efficient storage of chess game data using encoding techniques. They begin by examining the straightforward method of representing chess positions, which requires 100 bits or approximately 12 bytes. However, they then propose two observations that allow for more compact encoding. First, they suggest using the opposing king’s position to represent captured pieces, essentially storing this information for free. Second, they discuss a unique ordering system for representing promoted pawns, reducing the required bits for promotions. By implementing these strategies, the author concludes that chess game data can be stored in approximately 26 bytes. The post also mentions the use of Huffman coding for compression and invites readers to explore further.

https://www.ezzeriesa.com/index/Writing%20efa7772a3ae64a8193c7ef981ac619fc/Compressing%20chess%20positions%20for%20fun%20and%20profit%20df1fdb5364eb42fdac11eb23b25e9605.html

To top