/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. = Introduction =
  3. I propose storing the board state as a base64 string. Each 5 intersections can be stored in a character.
  4. = Details =
  5. 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.
  6. 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:
  7. {{{
  8. E - Empty - 0
  9. W - White - 1
  10. B - Black - 2
  11. Colour: E W E E B
  12. Trits: 0 1 0 0 2 = 2*1 + 1*27 = 29
  13. Mult: 81 27 9 3 1
  14. }}}
  15. We can then encode each octet as a Base64 character, so the above would be encoded as a lower case 'd'.
  16. A 361 intersection board encoded in this way should come out as 73 characters.