[computer-go] Language War!
Chrilly
c.donninger at wavenet.at
Mon Jul 31 00:25:22 PDT 2006
What is the advantage of a BitSet Representation over e.g. an Array of
Bytes?
Board[point]=WHITE_STONE; is faster than something link
WhiteBitSet[point>>5]|=(0x1<<(point&0x1F));
Same of course for the test if a stone is there.
One can calc with Bitsets the liberties by Bit-Shifting but it seems to be
not trivial to calc the number of liberties for each string.
I have used Bitsets for a fast Influence function. But it did not really
work, because this is a measure of the most nearby stone. But one has no
information of the number of influence stones.
In Suzie the Board is a struct { Uint8 Stone, Uint8 LibertyPattern, Uin8
StonePatter[2]}; LibertyPattern and StonePattern contain the info about the
8-adjacent Neigbours.
This is some effort when Setting a stone on the board, because one has also
to change the Patterns of the 8 Neighbour-Squares. But the Info is handy for
a lot of operations.
The really slow part is that I maintain also a list of liberties (and not
just the liberty count) and a list of strings which share at least one
liberty with the string and a list of opponent adjacent strings. This can be
tricky when (several) strings are merged or in the undo-operation split up.
STL:
Normally a special purpose data-representation is faster than a general
purpose one (it one takes advantage of the additional information). I know
only the results of J.Bently in "Programming Pearls, 2nd. edition", where
STL is about 5 times slower than a handcrafted sorting routine.
Chrilly
More information about the computer-go
mailing list