Changeset 180

Show
Ignore:
Timestamp:
09/15/06 22:49:02 (2 years ago)
Author:
ug
Message:

Several bug fixes. Implemented use of format string, sort criteria.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/libkombilo

    • Property svn:ignore set to
      *.pyc
      *.so
      .*.swp
      *.db
      cpptest

  • 06/libkombilo/cpptest.cc

    r177 r180  
    22 
    33int main() { 
    4         GameList gl("t1.db", "id", "", ALGO_FINALPOS | ALGO_MOVELIST, 19); 
    5         gl.printNum(); 
     4        GameList gl("t1.db", "id", "pw,pb,dt%%1 - %2, %3", ALGO_FINALPOS | ALGO_MOVELIST, 19); 
    65        gl.gisearch("pw = 'Hane Naoki'"); 
    7         gl.printNum(); 
    8         Pattern p(1, 13, 1, 14, 5, 4, "..XOO...XX.......X..", "", 0, 'X') ; 
     6        Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO") ; 
    97  PatternList pl(p, 0, 0, 19); 
    108        SearchOptions so; 
    119        gl.search(pl, so); 
    12         gl.printAll(); 
     10        printf("num games: %d\n", gl.size()); 
    1311} 
  • 06/libkombilo/process.py

    r177 r180  
    1919 
    2020    starttime = time.time() 
    21     algos = ALGO_FINALPOS | ALGO_MOVELIST 
     21    algos = ALGO_FINALPOS | ALGO_MOVELIST # | ALGO_HASH_FULL 
    2222    try: 
    23         gl = GameList('t1.db', 'id', '', algos, 19) 
     23        gl = GameList('t1.db', 'id', 'pw,pb,re,dt%%1 - %2 (%3), %4', algos, 19) 
    2424    except DBError: 
    2525        print 'Database error' 
  • 06/libkombilo/search.cc

    r177 r180  
    2626#include "search.h" 
    2727#include <stdio.h> 
     28#include <string> 
    2829#include <cstring> 
    29 #include <iostream> 
    30  
    3130 
    3231PatternError::PatternError() {} 
     
    4443 
    4544Symmetries::Symmetries(char sX, char sY) { 
    46   // cout << "Enter method Symmetries::Symmetries" << endl;  
    4745  sizeX = sX; 
    4846  sizeY = sY; 
     
    163161 
    164162Pattern::Pattern() { 
    165   // cout << "Enter method Pattern::Pattern()" << endl;  
    166163  initialPos = 0; 
    167164  finalPos = 0; 
    168165  contList = 0; 
    169   bits = 0; 
    170   bitlengths = 0; // FIXME?! 
    171166        flip = 0; 
    172167        colorSwitch = 0; 
     
    176171 
    177172 
     173Pattern::Pattern(int type, int boardsize, int sX, int sY, 
     174                 char* iPos, char* cList, int lenCList, char mOne) { 
     175  flip = 0; 
     176  colorSwitch = 0; 
     177  if (mOne=='B' || mOne=='X') moveOne = 'X'; 
     178  else moveOne = 'O'; 
     179  if (moveOne == 'X') moveTwo = 'O'; 
     180  else moveTwo = 'X'; 
     181  sizeX = sX; 
     182  sizeY = sY; 
     183 
     184        if (type == CORNER_NW_PATTERN || type == FULLBOARD_PATTERN) { 
     185    left = right = top = bottom = 0; 
     186        } else if (type == CORNER_NE_PATTERN) { 
     187                top = bottom = 0; 
     188    left = right = boardsize -1 - sizeX; 
     189        } else if (type == CORNER_SE_PATTERN) { 
     190                top = bottom = boardsize -1 - sizeY; 
     191    left = right = boardsize -1 - sizeX; 
     192        } else if (type == CORNER_SW_PATTERN) { 
     193                top = bottom = boardsize -1 - sizeY; 
     194                left = right = 0; 
     195        } else if (type == SIDE_N_PATTERN) { 
     196                top = bottom = 0; 
     197                left = 1; 
     198                right = boardsize -1 - sizeX; 
     199        } else if (type == SIDE_E_PATTERN) { 
     200    left = right = boardsize -1 - sizeX; 
     201                top = 1; 
     202                bottom = boardsize -1 - sizeY; 
     203        } else if (type == SIDE_W_PATTERN) { 
     204                left = right = 0; 
     205                top = 1; 
     206                bottom = boardsize -1 - sizeY; 
     207        } else if (type == SIDE_S_PATTERN) { 
     208                top = bottom = boardsize -1 - sizeY; 
     209                left = 1; 
     210                right = boardsize -1 - sizeX; 
     211        } else if (type == CENTER_PATTERN) { 
     212                left = top = 1; 
     213                right = boardsize -1 - sizeX; 
     214                bottom = boardsize -1 - sizeY; 
     215        } 
     216 
     217  initialPos = new char[sizeX * sizeY]; 
     218  finalPos = new char[sizeX*sizeY]; 
     219  for(int i=0; i<sizeX*sizeY; i++) { 
     220    initialPos[i] = iPos[i]; 
     221    finalPos[i] = iPos[i]; 
     222  } 
     223 
     224  lenContList = lenCList; 
     225  contList = new char[lenCList*4+1]; 
     226  for(int i=0; i<4*lenCList; i++) contList[i] = cList[i]; 
     227  for(int i=0; i<lenContList; i++) { 
     228    finalPos[contList[4*i] + sizeX * contList[4*i+1]] = BW2XO(contList[4*i+2]); 
     229  } 
     230  contList[lenCList*4] = 0; 
     231} 
     232 
    178233Pattern::Pattern(int le, int ri, int to, int bo, int sX, int sY, 
    179234                 char* iPos, char* cList, int lenCList, char mOne) { 
    180   // cout << "Enter method Pattern::Pattern" << endl;  
    181235  flip = 0; 
    182236  colorSwitch = 0; 
     
    191245  bottom = bo; 
    192246 
    193   // anchors.sort(); 
    194          
    195247  sizeX = sX; 
    196248  sizeY = sY; 
     
    210262  } 
    211263  contList[lenCList*4] = 0; 
    212  
    213   bits = new char_p[4]; 
    214   bitlengths = new int[4]; 
    215  
    216   for(int i=0; i<2; i++) { 
    217     for(int j=0; j<2; j++) { 
    218       int xBlocks = (sizeY+i+1)/2; 
    219       int yBlocks = (sizeX+j+1)/2; 
    220       char* nextBlock = new char[400]; 
    221       int nextBlockIndex = 0; 
    222       nextBlock[nextBlockIndex++] = yBlocks; 
    223  
    224       for(int k1=0; k1 < yBlocks; k1++) { 
    225         char nlist[400]; 
    226         int nlistIndex = 0; 
    227  
    228         for(int k2=0; k2 < xBlocks; k2++) { 
    229           int n = 0; 
    230           for(int x=0; x<2; x++) { 
    231             for(int y=0; y<2; y++) { 
    232               int indexX = k1 * 2 + y - j; 
    233               int indexY = k2 * 2 + x - i; 
    234               if (0 <= indexX && indexX < sizeX && 0 <= indexY && indexY < sizeY) { 
    235                 if (getFinal(indexX,indexY)=='X') 
    236                   n |= 1 << (2*(2*x+y)); 
    237                 else if (getFinal(indexX,indexY)=='O') 
    238                   n |= 1 << (2*(2*x+y)+1); 
    239               } 
    240             } 
    241           } 
    242           nlist[nlistIndex++] = n; 
    243         }               
    244  
    245         int start = 0; 
    246         int end = nlistIndex; 
    247  
    248         while (start < end && !nlist[start]) start++; 
    249         while (end > start && !nlist[end-1]) end--; 
    250  
    251         nextBlock[nextBlockIndex++] = start; 
    252         nextBlock[nextBlockIndex++] = end-start; 
    253         for(int current=start; current < end; current++)  
    254           nextBlock[nextBlockIndex++] = nlist[current]; 
    255       } 
    256       char* nB = new char[nextBlockIndex]; 
    257       for(int ii=0; ii<nextBlockIndex; ii++) nB[ii] = nextBlock[ii]; 
    258       bitlengths[2*i + j] = nextBlockIndex; 
    259       bits[2*i + j] = nB; 
    260       delete [] nextBlock; 
    261     } 
    262   } 
    263   // cout << "Leave method Pattern::Pattern(...)" << endl;  
    264264} 
    265265 
    266266Pattern::~Pattern() { 
    267   // cout << "Enter method Pattern::~Pattern" << endl;  
    268267  if (initialPos) delete [] initialPos; 
    269268  if (finalPos) delete [] finalPos; 
    270269  if (contList) delete [] contList; 
    271   if (bitlengths) { 
    272     delete [] bitlengths; 
    273     for(int i=0; i<4; i++) 
    274       if (bits[i]) delete [] bits[i]; 
    275     delete [] bits; 
    276   } 
    277   // cout << "Leave method Pattern::~Pattern" << endl;  
    278270} 
    279271 
    280272Pattern::Pattern(const Pattern& p) { 
    281   // cout << "Enter method Pattern::Pattern(const Pattern&)" << endl;  
    282273  left = p.left; 
    283274  right = p.right; 
     
    303294  } 
    304295  else contList = 0; 
    305   if (p.bitlengths) { 
    306     bits = new char_p[4]; 
    307     bitlengths = new int[4]; 
    308  
    309     for(int i=0; i<4; i++) { 
    310       bitlengths[i] = p.bitlengths[i]; 
    311       if (bitlengths[i]>0) bits[i] = new char[bitlengths[i]]; 
    312       else { 
    313         bits[i] = 0; 
    314         continue; 
    315       } 
    316       for(int j=0; j<bitlengths[i]; j++) 
    317         bits[i][j] = p.bits[i][j]; 
    318     } 
    319   } 
    320   else { 
    321     bits = 0; 
    322     bitlengths = 0; 
    323   } 
    324296} 
    325297 
    326298Pattern& Pattern::operator=(const Pattern& p) { 
    327   // cout << "Enter method Pattern::operator=" << endl;  
    328299  if (&p != this) { 
    329300    left = p.left; 
     
    341312    if (finalPos) delete [] finalPos; 
    342313    if (contList) delete [] contList; 
    343     if (bits) delete [] bits; 
    344     if (bitlengths) delete [] bitlengths; 
    345314     
    346315    initialPos = new char[sizeX*sizeY]; 
     
    355324    contList[lenContList*4] = 0; 
    356325 
    357     if (p.bitlengths) { 
    358       bits = new char_p[4]; 
    359       bitlengths = new int[4]; 
    360  
    361       for(int i=0; i<4; i++) { 
    362         bitlengths[i] = p.bitlengths[i]; 
    363         if (bitlengths[i]>0) bits[i] = new char[bitlengths[i]]; 
    364         else { 
    365           bits[i] = 0; 
    366           continue; 
    367         } 
    368         for(int j=0; j<bitlengths[i]; j++) 
    369           bits[i][j] = p.bits[i][j]; 
    370       } 
    371     } 
    372     else { 
    373       bits = 0; 
    374       bitlengths = 0; 
    375     } 
    376326  } 
    377327  return *this; 
    378   // cout << "Leave method Pattern::op= " << endl;  
    379328} 
    380329 
    381330 
    382331Pattern& Pattern::copy(const Pattern& p) { 
    383   // cout << "Enter method Pattern::copy" << endl;  
    384332  if (&p != this) { 
    385333    left = p.left; 
     
    397345    if (finalPos) delete [] finalPos; 
    398346    if (contList) delete [] contList; 
    399     if (bits) delete [] bits; 
    400     if (bitlengths) delete [] bitlengths; 
    401347     
    402348    initialPos = new char[sizeX*sizeY]; 
     
    410356    for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 
    411357    contList[lenContList*4] = 0; 
    412  
    413     if (p.bitlengths) { 
    414       bits = new char_p[4]; 
    415       bitlengths = new int[4]; 
    416  
    417       for(int i=0; i<4; i++) { 
    418         bitlengths[i] = p.bitlengths[i]; 
    419         if (bitlengths[i]>0) bits[i] = new char[bitlengths[i]]; 
    420         else { 
    421           bits[i] = 0; 
    422           continue; 
    423         } 
    424         for(int j=0; j<bitlengths[i]; j++) 
    425           bits[i][j] = p.bits[i][j]; 
    426       } 
    427     } 
    428     else { 
    429       bits = 0; 
    430       bitlengths = 0; 
    431     } 
    432358  } 
    433359  return *this; 
    434   // cout << "Leave method Pattern::copy " << endl;  
    435360} 
    436361 
     
    482407 
    483408PatternList::PatternList(Pattern& p, int fColor, int nMove, int bsize) { 
    484   // cout << "Enter method PatternList::PatternList(...)" << endl;  
    485409  pattern.copy(p); 
    486410  fixedColor = fColor; 
     
    488412  boardsize = bsize; 
    489413  special = -1; 
    490   // cout << "BP1" << endl;  
    491414 
    492415  patternList(); 
    493416        continuations = new Continuation[pattern.sizeX * pattern.sizeY]; 
    494   // cout << "Leave method PatternList::PatternList(...)" << endl;  
    495 
    496  
     417
     418 
     419PatternList::~PatternList() { 
     420        delete [] continuations; 
     421
    497422 
    498423PatternList::PatternList(const PatternList& pl) { 
     
    504429  return *this; 
    505430} 
    506  
    507431         
    508432char PatternList::invertColor(char co) { 
     
    517441         
    518442void PatternList::patternList() { 
    519   // cout << "Enter method PatternList::patternList" << endl;  
    520443         
    521444  vector<Pattern> lCS; 
     
    581504 
    582505    if (pNew == pattern) sy.push_back(pair<int,int>(f,0)); 
    583     // cout << "BP2" << endl;  
    584506 
    585507    if (nextMove || !fixedColor) { 
     
    736658                        else cc = 'B'; 
    737659                        cSymm = 1-cSymm; 
    738                 } else return 0; 
     660                } else { 
     661                        return 0; 
     662                } 
    739663        } 
    740664 
     
    757681} 
    758682 
     683 
     684char* PatternList::sortContinuations() { 
     685        char* labels = new char[pattern.sizeX*pattern.sizeY+1]; 
     686        labels[pattern.sizeX * pattern.sizeY] = 0; 
     687        for(int i=0; i<pattern.sizeX*pattern.sizeY; i++) { 
     688                if (continuations[i].B || continuations[i].W) labels[i] = '?'; // need to assign label 
     689                else labels[i] = '.'; 
     690        } 
     691        string labelList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 
     692        int labelIndex = 0; 
     693 
     694        // FIXME assign labels which are already in the SGF file 
     695         
     696        // now give labels to the remaining points, starting with the one with 
     697        // most hits 
     698         
     699  int max_hits = 0; 
     700        int max_hits_index; 
     701        while (max_hits != -1 && labelIndex < labelList.size()) { 
     702                for(int i=0; i<pattern.sizeX*pattern.sizeY; i++) { 
     703                        if (labels[i] == '?' && continuations[i].B + continuations[i].W > max_hits) { 
     704                                max_hits = continuations[i].B + continuations[i].W; 
     705                                max_hits_index = i; 
     706                        } 
     707                } 
     708                if (max_hits != 0) { // found another point needing a label 
     709                        labels[max_hits_index] = labelList[labelIndex++]; 
     710                        max_hits = 0; 
     711                } else max_hits = -1; // done 
     712        } 
     713  return labels; 
     714} 
    759715 
    760716DBError::DBError() { 
     
    1017973void Algo_finalpos::search(PatternList& patternList, GameList& gl, SearchOptions& options) { // progress bar?! 
    1018974 
     975        // Put the pattern into bitmap format, which is the format the final 
     976        // positions are stored in in the database. This makes the comparisons 
     977        // faster. 
     978 
     979        int plS = patternList.size(); 
     980        char_p** allbits = new char_p*[plS]; 
     981  int** allbitlengths = new int*[plS]; 
     982        for(int N=0; N<plS; N++) { 
     983                Pattern* pattern = &patternList.data[N]; 
     984                allbits[N] = new char_p[4]; 
     985                allbitlengths[N] = new int[4]; 
     986 
     987                for(int i=0; i<2; i++) { 
     988                        for(int j=0; j<2; j++) { 
     989                                int xBlocks = (pattern->sizeY+i+1)/2; 
     990                                int yBlocks = (pattern->sizeX+j+1)/2; 
     991                                char* nextBlock = new char[400]; 
     992                                int nextBlockIndex = 0; 
     993                                nextBlock[nextBlockIndex++] = yBlocks; 
     994 
     995                                for(int k1=0; k1 < yBlocks; k1++) { 
     996                                        char nlist[400]; 
     997                                        int nlistIndex = 0; 
     998 
     999                                        for(int k2=0; k2 < xBlocks; k2++) { 
     1000                                                int n = 0; 
     1001                                                for(int x=0; x<2; x++) { 
     1002                                                        for(int y=0; y<2; y++) { 
     1003                                                                int indexX = k1 * 2 + y - j; 
     1004                                                                int indexY = k2 * 2 + x - i; 
     1005                                                                if (0 <= indexX && indexX < pattern->sizeX && 0 <= indexY && indexY < pattern->sizeY) { 
     1006                                                                        if (pattern->getFinal(indexX,indexY)=='X') 
     1007                                                                                n |= 1 << (2*(2*x+y)); 
     1008                                                                        else if (pattern->getFinal(indexX,indexY)=='O') 
     1009                                                                                n |= 1 << (2*(2*x+y)+1); 
     1010                                                                } 
     1011                                                        } 
     1012                                                } 
     1013                                                nlist[nlistIndex++] = n; 
     1014                                        }               
     1015 
     1016                                        int start = 0; 
     1017                                        int end = nlistIndex; 
     1018 
     1019                                        while (start < end && !nlist[start]) start++; 
     1020                                        while (end > start && !nlist[end-1]) end--; 
     1021 
     1022                                        nextBlock[nextBlockIndex++] = start; 
     1023                                        nextBlock[nextBlockIndex++] = end-start; 
     1024                                        for(int current=start; current < end; current++)  
     1025                                                nextBlock[nextBlockIndex++] = nlist[current]; 
     1026                                } 
     1027                                char* nB = new char[nextBlockIndex]; 
     1028                                for(int ii=0; ii<nextBlockIndex; ii++) nB[ii] = nextBlock[ii]; 
     1029                                allbitlengths[N][2*i + j] = nextBlockIndex; 
     1030                                allbits[N][2*i + j] = nB; 
     1031                                delete [] nextBlock; 
     1032                        } 
     1033                } 
     1034        } 
     1035 
    10191036        int index = gl.start(); 
    10201037        int counter = 0; // to keep track of progress bar 
    1021         int plS = patternList.size(); 
    10221038        // printf("%d patterns\n", plS); 
    10231039  char start; 
     
    10451061 
    10461062                                        int pIndex = 2*(a1%2) + (a0%2); 
    1047                                         char* pbits = pattern->bits[pIndex]; 
     1063                                        char* pbits = allbits[N][pIndex]; 
    10481064                                        int pbIndex = 0; 
    10491065                                        int fpIndex = a1/2 + (a0/2)*10; 
     
    10741090                index = gl.next(); 
    10751091        } 
     1092        for(int N=0; N<plS; N++) { 
     1093    delete [] allbitlengths[N]; 
     1094    for(int i=0; i<4; i++) 
     1095      if (allbits[N][i]) delete [] allbits[N][i]; 
     1096    delete [] allbits[N]; 
     1097  } 
     1098        delete [] allbitlengths; 
     1099        delete [] allbits; 
    10761100} 
    10771101 
     
    10841108 
    10851109Algo_movelist::~Algo_movelist() { 
    1086         if (data1) delete data1; 
    1087         if (data2) delete data2; 
     1110        if (data1) { 
     1111                for(vector<char* >::iterator it = data1->begin(); it != data1->end(); it++) { 
     1112                        delete [] *it; 
     1113                } 
     1114                delete data1; 
     1115        } 
     1116        if (data2) { 
     1117                for(vector<char* >::iterator it = data2->begin(); it != data2->end(); it++) { 
     1118                        delete [] *it; 
     1119                } 
     1120                delete data2; 
     1121        } 
    10881122        if (data1l) delete data1l; 
    10891123} 
     
    12601294                // branchpoints = []; 
    12611295 
     1296                // printf("oh oh\n"); 
    12621297                char* movel = (*data1)[index-1]; 
    12631298                int movelistIndex = 0; 
    12641299                int endMovelist = (*data1l)[index-1]; 
     1300                // printf("oh oh\n"); 
    12651301                // printf("len movelist: %d\n", (*data1l)[index-1]); 
    12661302                // int nodeCtr = 0; 
     
    12931329                        int dNO = 0; 
    12941330                        Pattern* p = &patternList.data[m->orientation]; 
    1295                         char* d = new char[p->sizeX * p->sizeX]; 
     1331                        char* d = new char[p->sizeX * p->sizeY]; 
    12961332                        for(int i=0; i<p->sizeX; i++) { 
    12971333                                for(int j=0; j<p->sizeY; j++) { 
     
    13591395 
    13601396                        if (!(movel[movelistIndex+1] & REMOVE) && (movel[movelistIndex+1] & (BLACK | WHITE))) { 
     1397                                // printf("mv\n"); 
    13611398                                if (movel[movelistIndex+1] & BLACK) { 
    13621399                                        co = 'X'; 
     
    14031440                                                        } else { 
    14041441                                                                if (dictsDR[mCounter]) { // don't restore 
    1405                                                                         delete [] dicts[mCounter]; 
     1442                                                                        if (dicts[mCounter]) delete [] dicts[mCounter]; 
     1443                                                                        else printf("OUCH\n"); 
    14061444                                                                        dicts[mCounter] = 0; 
    14071445                                                                        continue; 
     
    14161454                                                        if (!(fpC[y/4 + 5*(x/2)] & (1 << (x%2 + 2*(y%4))))) { 
    14171455                                                                if (!contListIndex[mCounter]) { 
    1418                                                                         delete [] dicts[mCounter]; 
     1456                                                                        if (dicts[mCounter]) delete [] dicts[mCounter]; 
     1457                                                                        else printf("OUCH\n"); 
    14191458                                                                        dicts[mCounter] = 0; 
    14201459                                                                        continue; 
     
    14281467                                                        if (!(fpC[y/4 + 5*(x/2)] & (1 << (x%2 + 2*(y%4))))) { 
    14291468                                                                if (!contListIndex[mCounter]) { 
    1430                                                                         delete [] dicts[mCounter]; 
     1469                                                                        if (dicts[mCounter]) delete [] dicts[mCounter]; 
     1470                                                                        else printf("OUCH\n"); 
    14311471                                                                        dicts[mCounter] = 0; 
    14321472                                                                        continue; 
     
    14431483                        } 
    14441484                        else if (movel[movelistIndex+1] & REMOVE) { 
     1485                                // printf("rmv\n"); 
    14451486                                if (movel[movelistIndex+1] & BLACK) { 
    14461487                                        co = 'X'; 
     
    14701511                                                                } else { 
    14711512                                                                        if (dictsDR[mCounter]) { 
    1472                                                                                 delete [] dicts[mCounter]; 
     1513                                                                                if (dicts[mCounter]) delete [] dicts[mCounter]; 
     1514                                                                                else printf("OUCH\n"); 
    14731515                                                                                dicts[mCounter] = 0; 
    14741516                                                                                continue; 
     
    15001542 
    15011543                        if (endOfNode) { 
     1544                                // printf("eon\n"); 
    15021545                                for (int mCounter = 0; mCounter < currentMatchList->size(); mCounter++) { 
    15031546                                        if (!dicts[mCounter]) continue; 
     
    15291572                                        if (p->colorSwitch && showColorSwap) { 
    15301573                                                char* rstr = new char[3]; 
    1531                                                 rstr[0] = 0
     1574                                                rstr[0] = NO_CONT
    15321575                                                rstr[1] = 0; 
    15331576                                                rstr[2] = 1; 
     
    15351578                                        } else { 
    15361579                                                char* rstr = new char[3]; 
    1537                                                 rstr[0] = 0
     1580                                                rstr[0] = NO_CONT
    15381581                                                rstr[1] = 0; 
    15391582                                                rstr[2] = 0; 
     
    15561599                        } 
    15571600                        gl.makeCurrentHit(result); 
    1558                 } 
     1601                } else delete result; 
    15591602                index = gl.next(); 
    15601603                for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) 
    1561                       if (dicts[mCounter]) delete [] dicts[mCounter]; 
     1604              if (dicts[mCounter]) delete [] dicts[mCounter]; 
    15621605                delete [] dicts; 
    15631606                delete [] dictsDR; 
     
    15711614                delete [] contListIndex; 
    15721615        } 
    1573         // return numOfHits; // , Bwins, Wwins, self_numOfSwitched; 
    1574 
    1575  
    1576  
    1577 const int Algo_hash::hashCodes[] = { 
    1578         9149491, 4143844,  8452911, 3100691, 3196613,  7210416, 6086509, 7957641,  131916, 
    1579         6918136, 3016410,  3288711, 8539380, 758094,  7179238, 7718041, 5204153,  6711869, 
    1580         8411491, 2434388,  1162683, 927102, 197419,  9435893, 2149216, 2967038,  5557593, 
    1581         4044723, 4077413,  8810194, 7673830, 1290402,  704914, 2782252, 6972890,  2649162, 
    1582         8444272, 5863711,  8701652, 9073146, 796709,  3071327, 81078, 413463,  9899215, 
    1583         3900485, 4258038,  9853936, 5479882, 4613169,  7404562, 5251570, 1932628,  9394001, 
    1584         6022071, 216105,  4278005, 7136853, 2500566,  4107671, 4081838, 1785699,  1424534, 
    1585         3024969, 5734282,  4175470, 9404994, 8430123,  1255451, 5986866, 7055240,  6371620, 
    1586         9283568, 7313682,  7717289, 2299204, 6500542,  1976702, 7553422, 5187929,  3201058, 
    1587         2222174, 3817451,  7344416, 4960530, 6786163,  8006227, 442411, 4688575,  5012537, 
    1588         3651243, 7062230,  6716660, 4891547, 5702153,  8827952, 7097129, 9410525,  1319909, 
    1589         6697319, 6008737,  9209372, 1708104, 8930801,  3357765, 4158639, 8563534,  1000997, 
    1590         4582316, 6276028,  9658685, 4453094, 9081939,  6565077, 3029400, 3036923,   2527385, 
    1591         3663094, 1261450,  9321901, 4118265, 7506223,  8638174, 1830356, 9269438,  379190, 
    1592         5190162, 4415341,  455343, 2706427, 374332,  4806453, 3940651, 7845245,  2132422, 
    1593         313121, 1581806,   4042198, 4890562, 4352418,  5580773, 9938852, 6930891,  8376253, 
    1594         5737628, 8471297,  1142249, 848865, 883348,  9812485, 5717034, 7432763,  2354745, 
    1595         4069809, 9707233,  9588944, 3016914, 554095,  1638369, 9162618, 611584,  5407576, 
    1596         3543495, 640558,  5662155, 3501725, 7560991,  3133362, 9084840, 6812692,  1594571, 
    1597         9306451, 238482,  609444, 1700604, 3082475,  5804654, 6738079, 2956313,  3546729, 
    1598         3491719, 1214856,  888594, 4911844, 315409,  983871, 5306260, 7005661,  4089903, 
    1599         2599372, 7376553,  5249330, 1810656, 765893,  2667106, 7557868, 9214606,  5347135, 
    1600         6166404, 1400859,  1919455, 88281732, 6251839,  4004673, 20063775, 9013385,  6847406, 
    1601         70194548, 1408057,  6063976, 4380230, 8034820,  1813992, 9773930, 2520157,  1124498, 
    1602         9369992, 1110455,  1395733, 25824091, 1697715,  2368383, 745577, 8857326,  2179278, 
    1603         42674327, 6892826,  6099809, 9973299, 5025252,  3632262, 3081860, 2809085,  1683429, 
    1604         8369333, 7991628,  8365980, 465773, 1820067,   1457115, 27539283, 282741,  8546560, 
    1605         62336406, 3079605,  4697340, 4846782, 5022954,  9875417, 9168302, 6618946,  6928618, 
    1606         8503198, 5052403,  2078686, 2995926, 2194938,  820379, 76129962, 1375726,  8614873, 
    1607         59453355, 4672767,  3036307, 68408218, 3921566,  9316769, 5099779, 1957262,  82550, 
    1608         8061649, 5685904,  7357125, 3158126, 9681206,  9939320, 14165381, 9680390,  4083051, 
    1609         19707724, 8454640,  8443104, 40614927, 6778512,  5077238, 5263977, 6837884,  4767983, 
    1610         1402914, 1063494,  8805596, 2899665, 5717105,  5032108, 7482452, 95784,  6793965, 
    1611         71387213, 7934664,  6505269, 66783806, 2901608,  5665651, 3599459, 5070383,   1714950, 
    1612         8047561, 8205607,  67238, 2156761, 5827686,  1391658, 3591582, 7018330,  9232127, 
    1613         88494312, 820043,  7847325, 35832315, 2966011,  5159425, 48557138, 1079091,  2870996, 
    1614         5867619, 9327733,  4398712, 9371591, 2182067,  2409473, 709735, 4862464,   8833884, 
    1615         12607201, 37637,  2367746, 80879604, 4198525,  82482, 43895717, 787391,   8032185, 
    1616         2095647, 5448853,  850526, 2278124, 6280764,  4617893, 2879123, 806861,   4007840, 
    1617         9545335, 9072999,  1446181, 79467753, 6118313,  5073149, 82227926, 4448444,  4579004, 
    1618         5179082 
    1619 }; 
     1616
     1617 
     1618 
     1619const long long Algo_hash::hashCodes[] = { 
     1620        1448047776469843LL ,  23745670021858756LL ,  2503503679898819LL ,   
     1621        20893061577159209LL ,  10807838381971450LL ,  2362252468869198LL ,   
     1622        24259008893265414LL ,  12770534669822463LL ,  6243872632612083LL ,   
     1623        9878602848666731LL ,  15403460661141300LL ,  23328125617276831LL ,   
     1624        24399618481479321LL ,  6553504962910284LL ,  1670313139184804LL ,   
     1625        12980312942597170LL ,  20479559860862969LL ,  9622188310955879LL ,   
     1626        240315181816498LL ,  15806748501866401LL ,  11025185739521454LL ,   
     1627        9892014082139049LL ,  24468178939325513LL ,  18336761931886570LL ,   
     1628        17607110247268341LL ,  1659968630984898LL ,  15644176636883129LL ,   
     1629        21288430710467667LL ,  21718647773405600LL ,  8449573198599383LL ,   
     1630        12949198458251018LL ,  13260609204816340LL ,  15942818511406502LL ,   
     1631        19422389391992560LL ,  2306873372585698LL ,  13245768415868578LL ,   
     1632        3527685889767840LL ,  16821792770065498LL ,  14659578113224043LL ,   
     1633        8882299950073676LL ,  7855747638699870LL ,  11443553816792995LL ,   
     1634        10278034782711378LL ,  9888977721917330LL ,  8622555585025384LL , 
     1635        20622776792089008LL ,  6447699412562541LL ,  21593237574254863LL , 
     1636        4100056509197325LL ,  8358405560798101LL ,  24120904895822569LL , 
     1637        21004758159739407LL ,  4380824971205155LL ,  23810250238005035LL , 
     1638        11573868012372637LL ,  21740007761325076LL ,  20569500166060069LL , 
     1639        23367084743140030LL ,  832128940274250LL ,  3863567854976796LL , 
     1640        8401188629788306LL ,  20293444021869434LL ,  12476938100997420LL , 
     1641        5997141871489394LL ,  777596196611050LL ,  8407423122275781LL , 
     1642        23742268390341663LL ,  6606677504119583LL ,  17099083579458611LL , 
     1643        128040681345920LL ,  7441253945309846LL ,  17672412151152227LL , 
     1644        14657002484427869LL ,  3764334613856311LL ,  7399928989161192LL , 
     1645        24730167942169592LL ,  13814924480574978LL ,  5810810907567287LL , 
     1646        7008927747711241LL ,  3714629224790215LL ,  9946435535599731LL , 
     1647        20057491299504334LL ,  15866852457019228LL ,  123155262761331LL , 
     1648        1315783062254243LL ,  24497766846727950LL ,  12902532251391440LL , 
     1649        16788431106050494LL ,  15993209359043506LL ,  6163570598235227LL , 
     1650        23479274902645580LL ,  12086295521073246LL ,  14074331278381816LL , 
     1651        1049820141442769LL ,  5160957003350972LL ,  24302799572195320LL , 
     1652        23881606652035662LL ,  23969818184919245LL ,  19374430422494128LL , 
     1653        9346353622623467LL ,  13646698673919768LL ,  20787456987251805LL , 
     1654        19834903548127921LL ,  8194151691638546LL ,  7687885124853709LL , 
     1655        4843137186034754LL ,  23141719256229263LL ,  5528755394284040LL , 
     1656        22362536622784133LL ,  7624654257445620LL ,  8792845080211956LL , 
     1657        24991012676161170LL ,  5382030845010972LL ,  1942150054817210LL , 
     1658        1024267612932772LL ,  14257279792025309LL ,  11127353401828247LL , 
     1659        4123063511789286LL ,  363215666444395LL ,  15523634951795520LL , 
     1660        21114031740764324LL ,  12549698630972549LL ,  7906682572409157LL , 
     1661        9682658163949194LL ,  14445831019902887LL ,  19796086007848283LL , 
     1662        25041651202294181LL ,  434144873391024LL ,  24468825775827696LL , 
     1663        16436890395501393LL ,  16373785289815135LL ,  16626551488832360LL , 
     1664        7748715007439309LL ,  22731617567631698LL ,  14232800365889972LL , 
     1665        10951727445457549LL ,  8041373240290953LL ,  24930514145406896LL , 
     1666        9591184974667554LL ,  24880672410562956LL ,  23221721160805093LL , 
     1667        20593543181655919LL ,  23599230930155014LL ,  15520097083998302LL , 
     1668        14424914931817466LL ,  7073972177203460LL ,  16674214483955582LL , 
     1669        4557916889838393LL ,  14520120252661131LL ,  2948253205366287LL , 
     1670        18549806070390636LL ,  10409566723123418LL ,  18398906015238963LL , 
     1671        21169009649313417LL ,  18391044531337716LL ,  2911838512392375LL , 
     1672        13771057876708721LL ,  11955633853535396LL ,  18911960208175147LL , 
     1673        1483143365895487LL ,  5864164841327281LL ,  16798674080914657LL , 
     1674        21169543712647072LL ,  2554895121282201LL ,  12465286616181485LL , 
     1675        5756888636558955LL ,  2597276631190750LL ,  2560624395830604LL , 
     1676        20296901708171088LL ,  14642976680682096LL ,  12194169777111940LL , 
     1677        938262584370639LL ,  7206443811292574LL ,  501111636607822LL , 
     1678        5705951146039127LL ,  19098237626875269LL ,  5726006303511723LL , 
     1679        5717532750720198LL ,  4848344546021481LL ,  7407311808156422LL , 
     1680        2061821731974308LL ,  8556380079387133LL ,  13575103943220600LL , 
     1681        10594365938844562LL ,  19966653780019989LL ,  24412404083453688LL , 
     1682        8019373982039936LL ,  7753495706295280LL ,  838015840877266LL , 
     1683        5235642127051968LL ,  10225916255867901LL ,  14975561937408701LL , 
     1684        4914762527221109LL ,  16273933213731410LL ,  25240707945233645LL , 
     1685        6477894775523777LL ,  16128190602024745LL ,  12452291569329611LL , 
     1686        51030855211419LL ,  1848783942303739LL ,  2537297571305471LL , 
     1687        24811709277564335LL ,  23354767332363093LL ,  11338712562024830LL , 
     1688        10845782284945582LL ,  20710115514013598LL ,  19611282767915684LL , 
     1689        11160258605900113LL ,  17875966449141620LL ,  8400967803093668LL , 
     1690        6871997953834029LL ,  13914235659320051LL ,  8949576634650339LL , 
     1691        2143755776666584LL ,  13309009078638265LL ,  17871461210902733LL , 
     1692        11987276750060947LL ,  19212042799964345LL ,  9684310155516547LL , 
     1693        1307858104678668LL ,  8369225045337652LL ,  11470364009363081LL , 
     1694        10726698770860164LL ,  22857364846703600LL ,  25284735055035435LL , 
     1695        19224377054148393LL ,  16403807100295998LL ,  4653376186522389LL , 
     1696        15242640882406966LL ,  15315275662931969LL ,  11642086728644568LL , 
     1697        12158439227609947LL ,  5366950703441186LL ,  21989897136444615LL , 
     1698        21241101455718813LL ,  1591417368086590LL ,  14579493634035095LL , 
     1699        23329624772309429LL ,  4022767503269837LL ,  12858990365780377LL , 
     1700        1546772101519453LL ,  23839228242060485LL ,  3152020333001361LL , 
     1701        7700997223270546LL ,  7886359803633970LL ,  18794372628879385LL , 
     1702        22159114735365084LL ,  7999390508114986LL ,  17413096555746886LL , 
     1703        9385231705999634LL ,  15875377080359488LL ,  4319895571584052LL , 
     1704        15831501864738265LL ,  23927036136254152LL ,  9023165779396619LL , 
     1705        6131245054225200LL ,  20314359892927215LL ,  1896686091879468LL , 
     1706        14130616725563771LL ,  22653904323575475LL ,  9831497463521490LL , 
     1707        13110057076369419LL ,  5902087517632052LL ,  23714067728868348LL , 
     1708        10422641883492326LL ,  10327276345146850LL ,  795518417987648LL , 
     1709        25452954487907785LL ,  3500196309207718LL ,  14513995844064906LL , 
     1710        7844549909962914LL ,  9407804562184273LL ,  15229768031797498LL , 
     1711        14111656085687927LL ,  16834184600349678LL ,  7291182384885469LL , 
     1712        17771577974633552LL ,  21586473553657942LL ,  18166326806718423LL , 
     1713        10928317030329388LL ,  13135712137024532LL ,  12947681282864548LL , 
     1714        21220312239923983LL ,  9606249244876101LL ,  4653965165819933LL , 
     1715        5039148287631156LL ,  3987726544496362LL ,  11235885894214833LL , 
     1716        3549024987193191LL ,  6369560450327424LL ,  5296536600431238LL , 
     1717        10833371878822587LL ,  5746338282416722LL ,  20335144029844343LL , 
     1718        14857534135172842LL ,  13933887642921338LL ,  3610489245941154LL , 
     1719        7780064458218242LL ,  18217608762631328LL ,  4861734558486078LL , 
     1720        19138089389909524LL ,  162404484845663LL ,  6326150309736266LL , 
     1721        5691634479075905LL ,  14377989390160001LL ,  7788436404648140LL , 
     1722        20312143630017606LL ,  6781467023516504LL ,  7265384191721189LL , 
     1723        13990392558924592LL ,  4811546322556989LL ,  3891404257596968LL , 
     1724        19222546653408634LL ,  9733466771346453LL ,  20011679489309705LL , 
     1725        11556921572925005LL ,  13429005557512149LL ,  16680841455593148LL , 
     1726        394589115298971LL ,  22224576785554448LL ,  18262625753524808LL , 
     1727        20893780129453860LL ,  25064972830160559LL ,  241970110039610LL , 
     1728        7452533933839720LL ,  10726026396546933LL ,  17312051917081899LL , 
     1729        17281553837379637LL ,  24008819488103387LL ,  5193878516496164LL , 
     1730        21529615734706496LL ,  22844915602846365LL ,  17118246686087168LL , 
     1731        6560869056902581LL ,  10553021967047717LL ,  3729950813036887LL , 
     1732        14459986099519295LL ,  15808907290234758LL ,  6234512969275540LL , 
     1733        18690008075805909LL ,  492531108753402LL ,  7721002928884704LL , 
     1734        4886156035126456LL ,  21716374046066558LL ,  11035311630511661LL , 
     1735        16837692753538891LL ,  20172053977953882LL ,  15488511700491202LL , 
     1736        17477921115358343LL ,  24726937211646877LL ,  22480504880004621LL , 
     1737        18521326635500559LL ,  8076560603417178LL ,  22382516625473209LL , 
     1738        21696842111535623LL ,  12559160944089288LL ,  1661142873895453LL , 
     1739        18379772814447567LL ,  10295321430586466LL ,  12378145201769592LL ,   
     1740        11815752235866582LL }; 
    16201741 
    16211742 
     
    16261747} 
    16271748 
    1628 int Algo_hash::insert_hash(int hashCode, ExtendedMoveNumber& mn, Move* continuation) { 
     1749int Algo_hash::insert_hash(long long hashCode, ExtendedMoveNumber& mn, Move* continuation) { 
    16291750        char* sql = "insert into algo_hash (hash, game, position) values (?,?,?);"; 
    16301751        sqlite3_stmt *ppStmt=0; 
    16311752        int rc = sqlite3_prepare(db, sql, -1, &ppStmt, 0); 
    16321753        if (rc != SQLITE_OK || ppStmt==0) return rc; // FIXME: catch certain errors, (and/or throw DBError?) 
    1633         rc = sqlite3_bind_int(ppStmt, 1, currentHashCode); 
     1754        rc = sqlite3_bind_int64(ppStmt, 1, currentHashCode); 
    16341755        if (rc != SQLITE_OK) return rc; 
    16351756        rc = sqlite3_bind_text(ppStmt, 2, game, -1, SQLITE_TRANSIENT);  
     
    16611782        moveNumber = new ExtendedMoveNumber(0); 
    16621783        currentHashCode = 0; // start with empty board 
    1663         lfc = new vector<pair<int, ExtendedMoveNumber>* >; 
     1784        lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
    16641785  // branchpoints = []; FIXME 
    16651786} 
    16661787 
    16671788void Algo_hash::AB_process(int x, int y) { 
    1668         for(vector<p