Changeset 180
- Timestamp:
- 09/15/06 22:49:02 (2 years ago)
- Files:
-
- 06/libkombilo (modified) (1 prop)
- 06/libkombilo/cpptest.cc (modified) (1 diff)
- 06/libkombilo/process.py (modified) (1 diff)
- 06/libkombilo/search.cc (modified) (63 diffs)
- 06/libkombilo/search.h (modified) (13 diffs)
- 06/libkombilo/sgfparser.cc (modified) (1 diff)
- 06/libkombilo/sgfparser.h (modified) (1 diff)
- 06/libkombilo/testsearch.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/libkombilo
- Property svn:ignore set to
*.pyc
*.so
.*.swp
*.db
cpptest
- Property svn:ignore set to
06/libkombilo/cpptest.cc
r177 r180 2 2 3 3 int 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); 6 5 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") ; 9 7 PatternList pl(p, 0, 0, 19); 10 8 SearchOptions so; 11 9 gl.search(pl, so); 12 gl.printAll();10 printf("num games: %d\n", gl.size()); 13 11 } 06/libkombilo/process.py
r177 r180 19 19 20 20 starttime = time.time() 21 algos = ALGO_FINALPOS | ALGO_MOVELIST 21 algos = ALGO_FINALPOS | ALGO_MOVELIST # | ALGO_HASH_FULL 22 22 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) 24 24 except DBError: 25 25 print 'Database error' 06/libkombilo/search.cc
r177 r180 26 26 #include "search.h" 27 27 #include <stdio.h> 28 #include <string> 28 29 #include <cstring> 29 #include <iostream>30 31 30 32 31 PatternError::PatternError() {} … … 44 43 45 44 Symmetries::Symmetries(char sX, char sY) { 46 // cout << "Enter method Symmetries::Symmetries" << endl;47 45 sizeX = sX; 48 46 sizeY = sY; … … 163 161 164 162 Pattern::Pattern() { 165 // cout << "Enter method Pattern::Pattern()" << endl;166 163 initialPos = 0; 167 164 finalPos = 0; 168 165 contList = 0; 169 bits = 0;170 bitlengths = 0; // FIXME?!171 166 flip = 0; 172 167 colorSwitch = 0; … … 176 171 177 172 173 Pattern::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 178 233 Pattern::Pattern(int le, int ri, int to, int bo, int sX, int sY, 179 234 char* iPos, char* cList, int lenCList, char mOne) { 180 // cout << "Enter method Pattern::Pattern" << endl;181 235 flip = 0; 182 236 colorSwitch = 0; … … 191 245 bottom = bo; 192 246 193 // anchors.sort();194 195 247 sizeX = sX; 196 248 sizeY = sY; … … 210 262 } 211 263 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;264 264 } 265 265 266 266 Pattern::~Pattern() { 267 // cout << "Enter method Pattern::~Pattern" << endl;268 267 if (initialPos) delete [] initialPos; 269 268 if (finalPos) delete [] finalPos; 270 269 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;278 270 } 279 271 280 272 Pattern::Pattern(const Pattern& p) { 281 // cout << "Enter method Pattern::Pattern(const Pattern&)" << endl;282 273 left = p.left; 283 274 right = p.right; … … 303 294 } 304 295 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 }324 296 } 325 297 326 298 Pattern& Pattern::operator=(const Pattern& p) { 327 // cout << "Enter method Pattern::operator=" << endl;328 299 if (&p != this) { 329 300 left = p.left; … … 341 312 if (finalPos) delete [] finalPos; 342 313 if (contList) delete [] contList; 343 if (bits) delete [] bits;344 if (bitlengths) delete [] bitlengths;345 314 346 315 initialPos = new char[sizeX*sizeY]; … … 355 324 contList[lenContList*4] = 0; 356 325 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 }376 326 } 377 327 return *this; 378 // cout << "Leave method Pattern::op= " << endl;379 328 } 380 329 381 330 382 331 Pattern& Pattern::copy(const Pattern& p) { 383 // cout << "Enter method Pattern::copy" << endl;384 332 if (&p != this) { 385 333 left = p.left; … … 397 345 if (finalPos) delete [] finalPos; 398 346 if (contList) delete [] contList; 399 if (bits) delete [] bits;400 if (bitlengths) delete [] bitlengths;401 347 402 348 initialPos = new char[sizeX*sizeY]; … … 410 356 for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 411 357 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 }432 358 } 433 359 return *this; 434 // cout << "Leave method Pattern::copy " << endl;435 360 } 436 361 … … 482 407 483 408 PatternList::PatternList(Pattern& p, int fColor, int nMove, int bsize) { 484 // cout << "Enter method PatternList::PatternList(...)" << endl;485 409 pattern.copy(p); 486 410 fixedColor = fColor; … … 488 412 boardsize = bsize; 489 413 special = -1; 490 // cout << "BP1" << endl;491 414 492 415 patternList(); 493 416 continuations = new Continuation[pattern.sizeX * pattern.sizeY]; 494 // cout << "Leave method PatternList::PatternList(...)" << endl; 495 } 496 417 } 418 419 PatternList::~PatternList() { 420 delete [] continuations; 421 } 497 422 498 423 PatternList::PatternList(const PatternList& pl) { … … 504 429 return *this; 505 430 } 506 507 431 508 432 char PatternList::invertColor(char co) { … … 517 441 518 442 void PatternList::patternList() { 519 // cout << "Enter method PatternList::patternList" << endl;520 443 521 444 vector<Pattern> lCS; … … 581 504 582 505 if (pNew == pattern) sy.push_back(pair<int,int>(f,0)); 583 // cout << "BP2" << endl;584 506 585 507 if (nextMove || !fixedColor) { … … 736 658 else cc = 'B'; 737 659 cSymm = 1-cSymm; 738 } else return 0; 660 } else { 661 return 0; 662 } 739 663 } 740 664 … … 757 681 } 758 682 683 684 char* 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 } 759 715 760 716 DBError::DBError() { … … 1017 973 void Algo_finalpos::search(PatternList& patternList, GameList& gl, SearchOptions& options) { // progress bar?! 1018 974 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 1019 1036 int index = gl.start(); 1020 1037 int counter = 0; // to keep track of progress bar 1021 int plS = patternList.size();1022 1038 // printf("%d patterns\n", plS); 1023 1039 char start; … … 1045 1061 1046 1062 int pIndex = 2*(a1%2) + (a0%2); 1047 char* pbits = pattern->bits[pIndex];1063 char* pbits = allbits[N][pIndex]; 1048 1064 int pbIndex = 0; 1049 1065 int fpIndex = a1/2 + (a0/2)*10; … … 1074 1090 index = gl.next(); 1075 1091 } 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; 1076 1100 } 1077 1101 … … 1084 1108 1085 1109 Algo_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 } 1088 1122 if (data1l) delete data1l; 1089 1123 } … … 1260 1294 // branchpoints = []; 1261 1295 1296 // printf("oh oh\n"); 1262 1297 char* movel = (*data1)[index-1]; 1263 1298 int movelistIndex = 0; 1264 1299 int endMovelist = (*data1l)[index-1]; 1300 // printf("oh oh\n"); 1265 1301 // printf("len movelist: %d\n", (*data1l)[index-1]); 1266 1302 // int nodeCtr = 0; … … 1293 1329 int dNO = 0; 1294 1330 Pattern* p = &patternList.data[m->orientation]; 1295 char* d = new char[p->sizeX * p->size X];1331 char* d = new char[p->sizeX * p->sizeY]; 1296 1332 for(int i=0; i<p->sizeX; i++) { 1297 1333 for(int j=0; j<p->sizeY; j++) { … … 1359 1395 1360 1396 if (!(movel[movelistIndex+1] & REMOVE) && (movel[movelistIndex+1] & (BLACK | WHITE))) { 1397 // printf("mv\n"); 1361 1398 if (movel[movelistIndex+1] & BLACK) { 1362 1399 co = 'X'; … … 1403 1440 } else { 1404 1441 if (dictsDR[mCounter]) { // don't restore 1405 delete [] dicts[mCounter]; 1442 if (dicts[mCounter]) delete [] dicts[mCounter]; 1443 else printf("OUCH\n"); 1406 1444 dicts[mCounter] = 0; 1407 1445 continue; … … 1416 1454 if (!(fpC[y/4 + 5*(x/2)] & (1 << (x%2 + 2*(y%4))))) { 1417 1455 if (!contListIndex[mCounter]) { 1418 delete [] dicts[mCounter]; 1456 if (dicts[mCounter]) delete [] dicts[mCounter]; 1457 else printf("OUCH\n"); 1419 1458 dicts[mCounter] = 0; 1420 1459 continue; … … 1428 1467 if (!(fpC[y/4 + 5*(x/2)] & (1 << (x%2 + 2*(y%4))))) { 1429 1468 if (!contListIndex[mCounter]) { 1430 delete [] dicts[mCounter]; 1469 if (dicts[mCounter]) delete [] dicts[mCounter]; 1470 else printf("OUCH\n"); 1431 1471 dicts[mCounter] = 0; 1432 1472 continue; … … 1443 1483 } 1444 1484 else if (movel[movelistIndex+1] & REMOVE) { 1485 // printf("rmv\n"); 1445 1486 if (movel[movelistIndex+1] & BLACK) { 1446 1487 co = 'X'; … … 1470 1511 } else { 1471 1512 if (dictsDR[mCounter]) { 1472 delete [] dicts[mCounter]; 1513 if (dicts[mCounter]) delete [] dicts[mCounter]; 1514 else printf("OUCH\n"); 1473 1515 dicts[mCounter] = 0; 1474 1516 continue; … … 1500 1542 1501 1543 if (endOfNode) { 1544 // printf("eon\n"); 1502 1545 for (int mCounter = 0; mCounter < currentMatchList->size(); mCounter++) { 1503 1546 if (!dicts[mCounter]) continue; … … 1529 1572 if (p->colorSwitch && showColorSwap) { 1530 1573 char* rstr = new char[3]; 1531 rstr[0] = 0;1574 rstr[0] = NO_CONT; 1532 1575 rstr[1] = 0; 1533 1576 rstr[2] = 1; … … 1535 1578 } else { 1536 1579 char* rstr = new char[3]; 1537 rstr[0] = 0;1580 rstr[0] = NO_CONT; 1538 1581 rstr[1] = 0; 1539 1582 rstr[2] = 0; … … 1556 1599 } 1557 1600 gl.makeCurrentHit(result); 1558 } 1601 } else delete result; 1559 1602 index = gl.next(); 1560 1603 for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) 1561 if (dicts[mCounter]) delete [] dicts[mCounter];1604 if (dicts[mCounter]) delete [] dicts[mCounter]; 1562 1605 delete [] dicts; 1563 1606 delete [] dictsDR; … … 1571 1614 delete [] contListIndex; 1572 1615 } 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 1619 const 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 }; 1620 1741 1621 1742 … … 1626 1747 } 1627 1748 1628 int Algo_hash::insert_hash( inthashCode, ExtendedMoveNumber& mn, Move* continuation) {1749 int Algo_hash::insert_hash(long long hashCode, ExtendedMoveNumber& mn, Move* continuation) { 1629 1750 char* sql = "insert into algo_hash (hash, game, position) values (?,?,?);"; 1630 1751 sqlite3_stmt *ppStmt=0; 1631 1752 int rc = sqlite3_prepare(db, sql, -1, &ppStmt, 0); 1632 1753 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); 1634 1755 if (rc != SQLITE_OK) return rc; 1635 1756 rc = sqlite3_bind_text(ppStmt, 2, game, -1, SQLITE_TRANSIENT); … … 1661 1782 moveNumber = new ExtendedMoveNumber(0); 1662 1783 currentHashCode = 0; // start with empty board 1663 lfc = new vector<pair< int, ExtendedMoveNumber>* >;1784 lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 1664 1785 // branchpoints = []; FIXME 1665 1786 } 1666 1787 1667 1788 void Algo_hash::AB_process(int x, int y) { 1668 for(vector<p
