PageRenderTime 26ms CodeModel.GetById 23ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/wiki/Encoding.wiki

http://indi-go.googlecode.com/
Unknown | 26 lines | 16 code | 10 blank | 0 comment | 0 complexity | 0e0c2021d376bca1444713001043a358 MD5 | raw file
 1#summary A simple and memory efficient way of storing board states
 2
 3= Introduction =
 4
 5I propose storing the board state as a base64 string. Each 5 intersections can be stored in a character.
 6
 7
 8= Details =
 9
10There 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.
11
12If 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:
13
14{{{
15E - Empty - 0
16W - White - 1
17B - Black - 2
18
19Colour: E    W   E  E  B
20Trits:  0    1   0  0  2 = 2*1 + 1*27 = 29
21Mult:  81   27   9  3  1
22}}}
23
24We can then encode each octet as a Base64 character, so the above would be encoded as a lower case 'd'.
25
26A 361 intersection board encoded in this way should come out as 73 characters.