Search

Monday, August 13, 2012

Day 5: Translating



In the last post, the machine selected a position where the number was 0 (empty spot). I need to translate this to a valid go coordinate. Let's graphic this:


For example in a 6x6 board we had:

01 02 03 04 05 06 07
08 09 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49
50 51 52 53 54 55 56 57

The program just puts a stone on position 25, but a human, for example don't know what is 25. I have to add coordinates.

         A  B   C  D  E  F
   01 02 03 04 05 06 07
1 08 09 10 11 12 13 14
2 15 16 17 18 19 20 21
3 22 23 24 25 26 27 28
4 29 30 31 32 33 34 35
5 36 37 38 39 40 41 42
6 43 44 45 46 47 48 49
  50 51 52 53 54 55 56 57.

Now, we have that 25 is C3, easier to understand right? 

Also GTP (I will start writing about this in the really near future), uses coordinates, so let´s use GTP standard.

What I need now is a translator between array positions and coordinates. I will create a new class with two methods to translate from coordinate to array position and from array position to coordinate.

No comments:

Post a Comment