In order to keep working sets small, I prefer to not save extra information about chains. Instead:
Definition: Let c be the color of a stone. (That is white or black). A field f is not c-isolated if there is a sequence (f.0=f, ..., f.k-1) such that
- f.i and f.i+1 are neighbours
- f.j is not occupied by a stone of color c (could be very well occupied by a stone of a color that is not c)
- f.k-1 is either a border or a corner field.
(Lemma: Border and corner fields are not c-isolated for arbitrary c.)
Lemma: Using a depth first search, we can check in space less than 6*diam(board) and in time less than 6*fieldcount(board) whether or not a field is c-isolated.
Claim: It will be faster to actually perform the dfs within the cache instead of saving, maintaining and accessing extra information about chains in memory.
Lemma: Putting a stone of color c to field f closes a ring if
- there is a neighbour of f that is occupied by a stone of color c and has six neighbours that are also occupied by a stone of color c (the ring with 7 stones and diameter 1), or
- there is a neighbour of f that is c-isolated.
The good news is, that the question whether or not a put closes a fork or bridge can be answered also by a very similar dfs. So after all, the decision if a put finished a game can be drawn with one dfs (for fork/bridge) and at most 6 more dfs for ring detection.
Using this approach, a program can tabularize size 3 (with 19 cells) in 44 seconds on one 2.66 GHz core of my laptop. This includes the evaluation of 90814537 normal forms of which 16578814 are unique, the calculation of the normal form after each put and the maintenance of the game cache.
Significant improvement in speed is still possible: Please note, that for a fixed board size, the dfs can be "unrolled" to a piece of code
- that accumulates the border/edge connectivity,
- that has no branches and therefore will be executed very effectively also on machines with instruction pipelines and
- that uses bit operations only and therefore is well suited to use SIMD extensions.
Moreover, the 6 ring dfs could be collapsed to a single one which works bottom up.
FatPhil is right, this is an exercise in programming, not in understanding Havannah. But good engineering may help to advance there.