/wiki/Encoding.wiki
http://indi-go.googlecode.com/ · Unknown · 26 lines · 16 code · 10 blank · 0 comment · 0 complexity · 0e0c2021d376bca1444713001043a358 MD5 · raw file
- #summary A simple and memory efficient way of storing board states
- = Introduction =
- I propose storing the board state as a base64 string. Each 5 intersections can be stored in a character.
- = Details =
- There are 19*19 = 361 intersections on a full sized go board. Each intersection can have three states: empty, white or black. This gives 3^361^ = 1.74*10^172^ = 2^562^ possible board states.
- If we're not concerned too much about storage efficiency then we can convert each 5 intersections to an 8 bit number by treating them as base 3:
- {{{
- E - Empty - 0
- W - White - 1
- B - Black - 2
- Colour: E W E E B
- Trits: 0 1 0 0 2 = 2*1 + 1*27 = 29
- Mult: 81 27 9 3 1
- }}}
- We can then encode each octet as a Base64 character, so the above would be encoded as a lower case 'd'.
- A 361 intersection board encoded in this way should come out as 73 characters.