[computer-go] Go datastructures
Darren Cook
darren at dcook.org
Fri Jul 20 17:17:20 PDT 2007
> I always used a 1-dimensional 25x25 = 625 integer array with 0 for
> black 1 for white 2 for empty and 3 for border (everything else).
>
> This way I can have a 21x21 board with 2 rows of border cells
> surrounding it.
David Fotland, on the other hand, seems to use a 19x19 grid, and detect
off-board separately. (?)
This is the way I've also always done it. I get round the speed issues
of off-board detection because I have a global singleton called APD
(Adjacent Point Data). Its constructor caches lots of results. E.g. it
has functions to turn a 0..N coord into x and y coords, functions to
rotate points, functions to return the coord a certain distance away
(e.g. ikken to the North, keima to the South-East). That latter function
returns a special value when off-board.
APD also has functions for looping (e.g. through all the adjacents, or
all the diagonals, or even all the ogeima; automatically skipping over
off-board), for measuring distance to nearest edge or nearest corner,
and for point "type" (corner, edge, centre).
But, still, I wonder if the N+1 x N+1 design is quicker.
Darren
More information about the computer-go
mailing list