Programming Puzzles, Chess Positions and Huffman Coding
cforcoding.com
cforcoding.com
http://en.wikipedia.org/wiki/Arithmetic_encoding
Arithmetic compression differs from Huffman encoding because it encodes the entire dataset as a whole, rather than symbol-by-symbol. At worst, it will provide the same encoding that Huffman does, and it has far better performance on degenerate cases (such as 1 symbol having 75% chance). I think the commonly cited statistic is about 5% better on average, for some definition of 'average.'
For the curious: Arithmetic encoding works by taking all possible sequences, and taking the closed interval from 0 to 1 and chopping it into pieces, where the size of each piece is the probability of the corresponding sequence. Then the encoding of a sequence is the decimal (well, binary) expansion of any number that falls within the corresponding interval.
The starting board position in FEN would look something like this: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
I'll stress that the idea of this post isn't to implement a Chess engine but merely to examine an admittedly artificial problem (much like Code Golf results in code you usually wouldn't actually use for anything real because it's typically unreadable even if clever).
Various hashing techniques could speed up comparisons of positions but they don't allow you to store positions.
3 bits always suffice to indicate either (a) a pawn en prise (as it were) or (b) no en passant possible because there's no enemy pawn on the proper square for that file. (You can't have pawns on all 8 files and at the same time have one eligible for en passant capture, since you've got to have an opponent's pawn on an adjacent file. So in the usual case of no en passant you just pick a file not occupied by a pawn of the right color, alternatively one of the right color not adjacent to a pawn of the color to move. This is always possible).