2 ms·
In the game of connect-4, one doesn't need base 3 to make compact encodings. Gravity forces all non-empty squares in a column to be consecutive so a column of h
by tromp 3y ago
In the game of connect-4, one doesn't need base 3 to make compact encodings.
Gravity forces all non-empty squares in a column to be consecutive so a column of height n can be encoded in n+1 bits. For a column with h stones in it, set bit h to 1, all higher bits to 0, and then bits 0..h-1 can encode the h stones...
This allows a 7x6 connect-4 board to be encoded in 7x7=49 bits.
An 8x7 board still neatly fits into 64 bits. This is used in the Fhourstones connect-4 solver [1].
[1] https://tromp.github.io/c4/c4.html https://tromp.github.io/c4/c4.html