| 116 | | |
|---|
| 117 | | if (strcmp(currentDatap,datap)) { |
|---|
| 118 | | delete [] currentDatap; |
|---|
| 119 | | currentDatap = new char[strlen(datap)+1]; |
|---|
| 120 | | strcpy(currentDatap, datap); |
|---|
| 121 | | |
|---|
| 122 | | char* currentFP = new char[]; |
|---|
| 123 | | |
|---|
| 124 | | try { |
|---|
| 125 | | file = open(os.path.join(datap[0], 'finalpos'+datap[1]+'.db'), 'rb'); |
|---|
| 126 | | while (1) { |
|---|
| 127 | | try self.currentFP.fromfile(file, 1000000); |
|---|
| 128 | | except EOFError break; |
|---|
| 129 | | } |
|---|
| 130 | | file.close(); |
|---|
| 131 | | } |
|---|
| 132 | | except return 0; |
|---|
| 133 | | } |
|---|
| 134 | | |
|---|
| 135 | | for(int i=0; i<100; i++) |
|---|
| 136 | | if (currentFP[sli*100+i] != fp[i]) |
|---|
| 137 | | return 0; |
|---|
| 138 | | return 1; |
|---|
| 139 | | } |
|---|
| 140 | | |
|---|
| 141 | | int Algo_finalpos::retrieve_db(datap) { |
|---|
| 142 | | String fn = retrieve_datap0(datap) + "/finalpos" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| 143 | | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| 144 | | if (file.is_open()) { |
|---|
| 145 | | ifstream::pos_type size = file.tellg(); |
|---|
| 146 | | delete [] finalpos; |
|---|
| 147 | | finalpos = new char[size]; |
|---|
| 148 | | file.seekg (0, ios::beg); |
|---|
| 149 | | file.read (memblock, size); |
|---|
| 150 | | file.close(); |
|---|
| | 116 | return 0; // FIXME |
|---|
| | 117 | |
|---|
| | 118 | // if (strcmp(currentDatap,datap)) { |
|---|
| | 119 | // delete [] currentDatap; |
|---|
| | 120 | // currentDatap = new char[strlen(datap)+1]; |
|---|
| | 121 | // strcpy(currentDatap, datap); |
|---|
| | 122 | // |
|---|
| | 123 | // char* currentFP = new char[]; |
|---|
| | 124 | // |
|---|
| | 125 | // try { |
|---|
| | 126 | // file = open(os.path.join(datap[0], 'finalpos'+datap[1]+'.db'), 'rb'); |
|---|
| | 127 | // while (1) { |
|---|
| | 128 | // try self.currentFP.fromfile(file, 1000000); |
|---|
| | 129 | // except EOFError break; |
|---|
| | 130 | // } |
|---|
| | 131 | // file.close(); |
|---|
| | 132 | // } |
|---|
| | 133 | // except return 0; |
|---|
| | 134 | // } |
|---|
| | 135 | // |
|---|
| | 136 | // for(int i=0; i<100; i++) |
|---|
| | 137 | // if (currentFP[sli*100+i] != fp[i]) |
|---|
| | 138 | // return 0; |
|---|
| | 139 | // return 1; |
|---|
| | 140 | } |
|---|
| | 141 | |
|---|
| | 142 | int Algo_finalpos::retrieve_db(PyObject* datap) { |
|---|
| | 143 | String fn = retrieve_datap0(datap) + "/finalpos" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| | 144 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 145 | if (file.is_open()) { |
|---|
| | 146 | ifstream::pos_type size = file.tellg(); |
|---|
| | 147 | delete [] finalpos; |
|---|
| | 148 | finalpos = new char[size]; |
|---|
| | 149 | file.seekg (0, ios::beg); |
|---|
| | 150 | file.read (memblock, size); |
|---|
| | 151 | file.close(); |
|---|
| 353 | | String fn = retrieve_datap0(datap) + "/finalposC" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| 354 | | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| 355 | | if (file.is_open()) { |
|---|
| 356 | | ifstream::pos_type size = file.tellg(); |
|---|
| 357 | | delete [] finalposC; |
|---|
| 358 | | finalposC = new char[size]; |
|---|
| 359 | | file.seekg (0, ios::beg); |
|---|
| 360 | | file.read (memblock, size); |
|---|
| 361 | | file.close(); |
|---|
| 362 | | } |
|---|
| | 354 | String fn = retrieve_datap0(datap) + "/finalposC" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| | 355 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 356 | if (file.is_open()) { |
|---|
| | 357 | ifstream::pos_type size = file.tellg(); |
|---|
| | 358 | delete [] finalposC; |
|---|
| | 359 | finalposC = new char[size]; |
|---|
| | 360 | file.seekg (0, ios::beg); |
|---|
| | 361 | file.read (memblock, size); |
|---|
| | 362 | file.close(); |
|---|
| | 363 | } |
|---|
| 364 | | cout << "Unable to open file"; |
|---|
| 365 | | return 0; |
|---|
| 366 | | } |
|---|
| 367 | | fn = retrieve_datap0(datap) + "/lists" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| 368 | | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| 369 | | if (file.is_open()) { |
|---|
| 370 | | ifstream::pos_type size = file.tellg(); |
|---|
| 371 | | delete [] mainlistArr; |
|---|
| 372 | | mainlistArr = new char[size]; |
|---|
| 373 | | file.seekg (0, ios::beg); |
|---|
| 374 | | file.read (memblock, size); |
|---|
| 375 | | file.close(); |
|---|
| 376 | | } |
|---|
| | 365 | cout << "Unable to open file"; |
|---|
| | 366 | return 0; |
|---|
| | 367 | } |
|---|
| | 368 | fn = retrieve_datap0(datap) + "/lists" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| | 369 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 370 | if (file.is_open()) { |
|---|
| | 371 | ifstream::pos_type size = file.tellg(); |
|---|
| | 372 | delete [] mainlistArr; |
|---|
| | 373 | mainlistArr = new char[size]; |
|---|
| | 374 | file.seekg (0, ios::beg); |
|---|
| | 375 | file.read (memblock, size); |
|---|
| | 376 | file.close(); |
|---|
| | 377 | } |
|---|
| 378 | | cout << "Unable to open file"; |
|---|
| 379 | | return 0; |
|---|
| 380 | | } |
|---|
| 381 | | fn = retrieve_datap0(datap) + "/posTable" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| 382 | | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| 383 | | if (file.is_open()) { |
|---|
| 384 | | ifstream::pos_type size = file.tellg(); |
|---|
| 385 | | delete [] posTable; |
|---|
| 386 | | posTable = new char[size]; // FIXME: not a char array??? |
|---|
| 387 | | file.seekg (0, ios::beg); |
|---|
| 388 | | file.read (memblock, size); |
|---|
| 389 | | file.close(); |
|---|
| | 379 | cout << "Unable to open file"; |
|---|
| | 380 | return 0; |
|---|
| | 381 | } |
|---|
| | 382 | fn = retrieve_datap0(datap) + "/posTable" + retrieve_datap1(datap) + ".db"; // FIXME: linux specific!? |
|---|
| | 383 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 384 | if (file.is_open()) { |
|---|
| | 385 | ifstream::pos_type size = file.tellg(); |
|---|
| | 386 | delete [] posTable; |
|---|
| | 387 | posTable = new char[size]; // FIXME: not a char array??? |
|---|
| | 388 | file.seekg (0, ios::beg); |
|---|
| | 389 | file.read (memblock, size); |
|---|
| | 390 | file.close(); |
|---|
| 483 | | if (!patternList.nextMove) { |
|---|
| 484 | | for(m in dicts.keys()) |
|---|
| 485 | | if (dicts[m].has_key('found')) { |
|---|
| 486 | | Pattern p = patternList.get(m[0]); // FIXME: besser pointer uebergeben? |
|---|
| 487 | | if (p.colorSwitch) numOfSwitched++; |
|---|
| 488 | | if (p.colorSwitch && showColorSwap) |
|---|
| 489 | | result.append((dicts[m]['found'], '-')); |
|---|
| 490 | | else result.append((dicts[m]['found'], '')); |
|---|
| 491 | | } |
|---|
| 492 | | } |
|---|
| 493 | | dicts, dictsNO, contList, contListIndex, counter = self.branchpoints.pop(); |
|---|
| 494 | | movelistIndex += 2; |
|---|
| 495 | | continue; |
|---|
| | 484 | if (!patternList.nextMove) { |
|---|
| | 485 | for(m in dicts.keys()) |
|---|
| | 486 | if (dicts[m].has_key('found')) { |
|---|
| | 487 | Pattern p = patternList.get(m[0]); // FIXME: besser pointer uebergeben? |
|---|
| | 488 | if (p.colorSwitch) numOfSwitched++; |
|---|
| | 489 | if (p.colorSwitch && showColorSwap) |
|---|
| | 490 | result.append((dicts[m]['found'], '-')); |
|---|
| | 491 | else result.append((dicts[m]['found'], '')); |
|---|
| | 492 | } |
|---|
| | 493 | } |
|---|
| | 494 | dicts, dictsNO, contList, contListIndex, counter = self.branchpoints.pop(); |
|---|
| | 495 | movelistIndex += 2; |
|---|
| | 496 | continue; |
|---|
| 507 | | if (mainlistArr[movelistIndex+1] & BLACK) { |
|---|
| 508 | | co = 'X'; |
|---|
| 509 | | invco = 'O'; |
|---|
| 510 | | } |
|---|
| 511 | | else { |
|---|
| 512 | | co = 'O'; |
|---|
| 513 | | invco = 'X'; |
|---|
| 514 | | } |
|---|
| 515 | | |
|---|
| 516 | | for(m in dicts.keys()) { |
|---|
| 517 | | if (Xinterv[m][0] <= x && x < Xinterv[m][1] && Yinterv[m][0] <= y && y < Yinterv[m][1]) { |
|---|
| 518 | | if (dicts[m].has_key('found')) { |
|---|
| 519 | | hit, label, contLabelsIndex, switched = patternList.updateContinuations(m[0], x, y, invco, |
|---|
| 520 | | Xinterv[m], Yinterv[m], |
|---|
| 521 | | dicts[m]['found'], counter, |
|---|
| 522 | | continuations, contLabels, |
|---|
| 523 | | contLabelsIndex, |
|---|
| 524 | | db.getCurrentWinner()); |
|---|
| 525 | | if (!hit) { |
|---|
| 526 | | del dicts[m]; |
|---|
| 527 | | del dictsNO[m]; |
|---|
| 528 | | continue; |
|---|
| 529 | | } |
|---|
| 530 | | |
|---|
| 531 | | numOfSwitched += switched; // FIXME: CHECK, was: patternList[m[0]].colorSwitch |
|---|
| 532 | | |
|---|
| 533 | | if (switched && showColorSwap) |
|---|
| 534 | | // FIXME: CHECK,was: (patternList[m[0]].colorSwitch or colorSwitch) and showColorSwap: |
|---|
| 535 | | result.append((dicts[m]['found'], label + '-')); |
|---|
| 536 | | else result.append((dicts[m]['found'], label)); |
|---|
| 537 | | del dicts[m]; |
|---|
| 538 | | del dictsNO[m]; |
|---|
| 539 | | continue; // with for m in dicts.keys() |
|---|
| 540 | | } |
|---|
| 541 | | else if (dicts[m].has_key('foundInitial')) { |
|---|
| 542 | | if ((x, y, co) == contList[m][contListIndex[m]]) { |
|---|
| 543 | | contListIndex[m]++; |
|---|
| 544 | | if (contListIndex[m] == len(contList[m])) { |
|---|
| 545 | | dicts[m]['found'] = counter; |
|---|
| 546 | | del dicts[m]['foundInitial']; |
|---|
| 547 | | } |
|---|
| 548 | | } |
|---|
| 549 | | else { |
|---|
| 550 | | if (dicts[m].has_key('dontRestore')) { |
|---|
| 551 | | del dicts[m]; |
|---|
| 552 | | continue; |
|---|
| 553 | | } |
|---|
| 554 | | else { |
|---|
| 555 | | contListIndex[m] = 0; |
|---|
| 556 | | del dicts[m]['foundInitial']; |
|---|
| 557 | | } |
|---|
| 558 | | } |
|---|
| 559 | | } |
|---|
| | 508 | if (mainlistArr[movelistIndex+1] & BLACK) { |
|---|
| | 509 | co = 'X'; |
|---|
| | 510 | invco = 'O'; |
|---|
| | 511 | } |
|---|
| | 512 | else { |
|---|
| | 513 | co = 'O'; |
|---|
| | 514 | invco = 'X'; |
|---|
| | 515 | } |
|---|
| | 516 | |
|---|
| | 517 | for(m in dicts.keys()) { |
|---|
| | 518 | if (Xinterv[m][0] <= x && x < Xinterv[m][1] && Yinterv[m][0] <= y && y < Yinterv[m][1]) { |
|---|
| | 519 | if (dicts[m].has_key('found')) { |
|---|
| | 520 | hit, label, contLabelsIndex, switched = patternList.updateContinuations(m[0], x, y, invco, |
|---|
| | 521 | Xinterv[m], Yinterv[m], |
|---|
| | 522 | dicts[m]['found'], counter, |
|---|
| | 523 | continuations, contLabels, |
|---|
| | 524 | contLabelsIndex, |
|---|
| | 525 | db.getCurrentWinner()); |
|---|
| | 526 | if (!hit) { |
|---|
| | 527 | del dicts[m]; |
|---|
| | 528 | del dictsNO[m]; |
|---|
| | 529 | continue; |
|---|
| | 530 | } |
|---|
| | 531 | |
|---|
| | 532 | numOfSwitched += switched; // FIXME: CHECK, was: patternList[m[0]].colorSwitch |
|---|
| | 533 | |
|---|
| | 534 | if (switched && showColorSwap) |
|---|
| | 535 | // FIXME: CHECK,was: (patternList[m[0]].colorSwitch or colorSwitch) and showColorSwap: |
|---|
| | 536 | result.append((dicts[m]['found'], label + '-')); |
|---|
| | 537 | else result.append((dicts[m]['found'], label)); |
|---|
| | 538 | del dicts[m]; |
|---|
| | 539 | del dictsNO[m]; |
|---|
| | 540 | continue; // with for m in dicts.keys() |
|---|
| | 541 | } |
|---|
| | 542 | else if (dicts[m].has_key('foundInitial')) { |
|---|
| | 543 | if ((x, y, co) == contList[m][contListIndex[m]]) { |
|---|
| | 544 | contListIndex[m]++; |
|---|
| | 545 | if (contListIndex[m] == len(contList[m])) { |
|---|
| | 546 | dicts[m]['found'] = counter; |
|---|
| | 547 | del dicts[m]['foundInitial']; |
|---|
| | 548 | } |
|---|
| | 549 | } |
|---|
| | 550 | else { |
|---|
| | 551 | if (dicts[m].has_key('dontRestore')) { |
|---|
| | 552 | del dicts[m]; |
|---|
| | 553 | continue; |
|---|
| | 554 | } |
|---|
| | 555 | else { |
|---|
| | 556 | contListIndex[m] = 0; |
|---|
| | 557 | del dicts[m]['foundInitial']; |
|---|
| | 558 | } |
|---|
| | 559 | } |
|---|
| | 560 | } |
|---|
| 593 | | if (mainlistArr[movelistIndex+1] & BLACK) { |
|---|
| 594 | | co = 'X'; |
|---|
| 595 | | invco = 'O'; |
|---|
| 596 | | } |
|---|
| 597 | | else if mainlistArr[movelistIndex+1] & WHITE { |
|---|
| 598 | | co = 'O'; |
|---|
| 599 | | invco = 'X'; |
|---|
| 600 | | } |
|---|
| 601 | | else printf("oops\n"); // FIXME |
|---|
| 602 | | |
|---|
| 603 | | for (m in dicts.keys()) { |
|---|
| 604 | | if (!dicts[m].has_key('found')) { |
|---|
| 605 | | if (Xinterv[m][0] <= x && x < Xinterv[m][1] && Yinterv[m][0] <= y && y < Yinterv[m][1]) { |
|---|
| 606 | | if (dicts[m].has_key('foundInitial')) { |
|---|
| 607 | | int ii = contListIndex[m]; |
|---|
| 608 | | while (ii < len(contList[m]) && contList[m][ii][2] == '-' && |
|---|
| 609 | | (x != contList[m][ii][0] || y != contList[m][ii][1])) |
|---|
| 610 | | ii++; |
|---|
| 611 | | if (ii < len(contList[m]) && contList[m][ii][2] == '-') { |
|---|
| 612 | | help = contList[m][ii]; |
|---|
| 613 | | contList[m][ii] = contList[m][contListIndex[m]]; |
|---|
| 614 | | contlist[contListIndex[m]] = help; |
|---|
| 615 | | |
|---|
| 616 | | contListIndex[m]++; |
|---|
| 617 | | } |
|---|
| 618 | | else { |
|---|
| 619 | | if (dicts[m].has_key('dontRestore')) { |
|---|
| 620 | | del dicts[m]; |
|---|
| 621 | | continue; |
|---|
| 622 | | } |
|---|
| 623 | | else { |
|---|
| 624 | | contListIndex[m] = 0; |
|---|
| 625 | | del dicts[m]['foundInitial']; |
|---|
| 626 | | } |
|---|
| 627 | | } |
|---|
| 628 | | } |
|---|
| 629 | | if (!dicts[m].has_key((x,y))) { |
|---|
| 630 | | dicts[m][(x,y)] = co; |
|---|
| 631 | | dictsNO[m]++; |
|---|
| 632 | | } |
|---|
| 633 | | else if (dicts[m][(x,y)] == lower(invco)) { |
|---|
| 634 | | dictsNO[m]--; |
|---|
| 635 | | } |
|---|
| 636 | | else if (dicts[m][(x,y)] == '.') { |
|---|
| 637 | | del dicts[m][(x,y)]; |
|---|
| 638 | | dictsNO[m]--; |
|---|
| 639 | | } |
|---|
| 640 | | } |
|---|
| 641 | | } |
|---|
| 642 | | } |
|---|
| | 594 | if (mainlistArr[movelistIndex+1] & BLACK) { |
|---|
| | 595 | co = 'X'; |
|---|
| | 596 | invco = 'O'; |
|---|
| | 597 | } |
|---|
| | 598 | else if mainlistArr[movelistIndex+1] & WHITE { |
|---|
| | 599 | co = 'O'; |
|---|
| | 600 | invco = 'X'; |
|---|
| | 601 | } |
|---|
| | 602 | else printf("oops\n"); // FIXME |
|---|
| | 603 | |
|---|
| | 604 | for (m in dicts.keys()) { |
|---|
| | 605 | if (!dicts[m].has_key('found')) { |
|---|
| | 606 | if (Xinterv[m][0] <= x && x < Xinterv[m][1] && Yinterv[m][0] <= y && y < Yinterv[m][1]) { |
|---|
| | 607 | if (dicts[m].has_key('foundInitial')) { |
|---|
| | 608 | int ii = contListIndex[m]; |
|---|
| | 609 | while (ii < len(contList[m]) && contList[m][ii][2] == '-' && |
|---|
| | 610 | (x != contList[m][ii][0] || y != contList[m][ii][1])) |
|---|
| | 611 | ii++; |
|---|
| | 612 | if (ii < len(contList[m]) && contList[m][ii][2] == '-') { |
|---|
| | 613 | help = contList[m][ii]; |
|---|
| | 614 | contList[m][ii] = contList[m][contListIndex[m]]; |
|---|
| | 615 | contlist[contListIndex[m]] = help; |
|---|
| | 616 | |
|---|
| | 617 | contListIndex[m]++; |
|---|
| | 618 | } |
|---|
| | 619 | else { |
|---|
| | 620 | if (dicts[m].has_key('dontRestore')) { |
|---|
| | 621 | del dicts[m]; |
|---|
| | 622 | continue; |
|---|
| | 623 | } |
|---|
| | 624 | else { |
|---|
| | 625 | contListIndex[m] = 0; |
|---|
| | 626 | del dicts[m]['foundInitial']; |
|---|
| | 627 | } |
|---|
| | 628 | } |
|---|
| | 629 | } |
|---|
| | 630 | if (!dicts[m].has_key((x,y))) { |
|---|
| | 631 | dicts[m][(x,y)] = co; |
|---|
| | 632 | dictsNO[m]++; |
|---|
| | 633 | } |
|---|
| | 634 | else if (dicts[m][(x,y)] == lower(invco)) { |
|---|
| | 635 | dictsNO[m]--; |
|---|
| | 636 | } |
|---|
| | 637 | else if (dicts[m][(x,y)] == '.') { |
|---|
| | 638 | del dicts[m][(x,y)]; |
|---|
| | 639 | dictsNO[m]--; |
|---|
| | 640 | } |
|---|
| | 641 | } |
|---|
| | 642 | } |
|---|
| | 643 | } |
|---|
| 661 | | Pattern p = patternList.get(m[0]); |
|---|
| 662 | | if (dicts[m].has_key('found')) { |
|---|
| 663 | | if (p.colorSwitch) numOfSwitched++; |
|---|
| 664 | | if (p.colorSwitch && showColorSwap) result.append((dicts[m]['found'], '-')); |
|---|
| 665 | | else result.append((dicts[m]['found'], '')); |
|---|
| 666 | | } |
|---|
| | 662 | Pattern p = patternList.get(m[0]); |
|---|
| | 663 | if (dicts[m].has_key('found')) { |
|---|
| | 664 | if (p.colorSwitch) numOfSwitched++; |
|---|
| | 665 | if (p.colorSwitch && showColorSwap) result.append((dicts[m]['found'], '-')); |
|---|
| | 666 | else result.append((dicts[m]['found'], '')); |
|---|
| | 667 | } |
|---|
| 823 | | // String fn = ... filename ...; // FIXME |
|---|
| 824 | | // ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| 825 | | // if (file.is_open()) { |
|---|
| 826 | | // ifstream::pos_type size = file.tellg(); |
|---|
| 827 | | // delete [] hash; |
|---|
| 828 | | // hash = new char[size]; // FIXME: not a char array? |
|---|
| 829 | | // file.seekg (0, ios::beg); |
|---|
| 830 | | // file.read (memblock, size); |
|---|
| 831 | | // file.close(); |
|---|
| 832 | | // } |
|---|
| | 824 | // String fn = ... filename ...; // FIXME |
|---|
| | 825 | // ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 826 | // if (file.is_open()) { |
|---|
| | 827 | // ifstream::pos_type size = file.tellg(); |
|---|
| | 828 | // delete [] hash; |
|---|
| | 829 | // hash = new char[size]; // FIXME: not a char array? |
|---|
| | 830 | // file.seekg (0, ios::beg); |
|---|
| | 831 | // file.read (memblock, size); |
|---|
| | 832 | // file.close(); |
|---|
| | 833 | // } |
|---|
| 834 | | // cout << "Unable to open file"; |
|---|
| 835 | | // return 0; |
|---|
| 836 | | // } |
|---|
| 837 | | // String fn = ... filename + "T" ...; // FIXME |
|---|
| 838 | | // ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| 839 | | // if (file.is_open()) { |
|---|
| 840 | | // ifstream::pos_type size = file.tellg(); |
|---|
| 841 | | // delete [] hashT; |
|---|
| 842 | | // hashT = new char[size]; |
|---|
| 843 | | // file.seekg (0, ios::beg); |
|---|
| 844 | | // file.read (memblock, size); |
|---|
| 845 | | // file.close(); |
|---|
| 846 | | // } |
|---|
| | 835 | // cout << "Unable to open file"; |
|---|
| | 836 | // return 0; |
|---|
| | 837 | // } |
|---|
| | 838 | // String fn = ... filename + "T" ...; // FIXME |
|---|
| | 839 | // ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 840 | // if (file.is_open()) { |
|---|
| | 841 | // ifstream::pos_type size = file.tellg(); |
|---|
| | 842 | // delete [] hashT; |
|---|
| | 843 | // hashT = new char[size]; |
|---|
| | 844 | // file.seekg (0, ios::beg); |
|---|
| | 845 | // file.read (memblock, size); |
|---|
| | 846 | // file.close(); |
|---|
| | 847 | // } |
|---|
| 861 | | // pattern_hashkeys[(a0,a1)] = []; |
|---|
| 862 | | // for(p in self.poslist) { |
|---|
| 863 | | // if (a0 <= p[2] && a0+pattern.sizeX >= p[4] a1 <= p[3] && a1+pattern.sizeY >= p[5]) { |
|---|
| 864 | | // hk = self.compute_hashkey(pattern, p[2:]); |
|---|
| 865 | | // |
|---|
| 866 | | // if (hk != NOT_HASHABLE) pattern.hashkeys[(a0,a1)].append([hk]); |
|---|
| 867 | | // } |
|---|
| 868 | | // } |
|---|
| 869 | | // if (!pattern.hashkeys[(a0,a1)]) return; |
|---|
| | 862 | // pattern_hashkeys[(a0,a1)] = []; |
|---|
| | 863 | // for(p in self.poslist) { |
|---|
| | 864 | // if (a0 <= p[2] && a0+pattern.sizeX >= p[4] a1 <= p[3] && a1+pattern.sizeY >= p[5]) { |
|---|
| | 865 | // hk = self.compute_hashkey(pattern, p[2:]); |
|---|
| | 866 | // |
|---|
| | 867 | // if (hk != NOT_HASHABLE) pattern.hashkeys[(a0,a1)].append([hk]); |
|---|
| | 868 | // } |
|---|
| | 869 | // } |
|---|
| | 870 | // if (!pattern.hashkeys[(a0,a1)]) return; |
|---|
| 891 | | // int hash_start; |
|---|
| 892 | | // int hash_end; |
|---|
| 893 | | // |
|---|
| 894 | | // while (start < end) { |
|---|
| 895 | | // int help = self.hashT[2*((start+end)/2)]; |
|---|
| 896 | | // if (help == hashkey) { |
|---|
| 897 | | // hash_start = self.hashT[2*((start+end)/2)+1]; |
|---|
| 898 | | // if (2*((start+end)/2)+3 >= len(self.hashT)) hash_end = len(hash); |
|---|
| 899 | | // else hash_end = self.hashT[2*((start+end)/2)+3]; |
|---|
| 900 | | // |
|---|
| 901 | | // pattern.hashkeys[(a0,a1)][hk].extend([hash_start, hash_start, hash_end]); |
|---|
| 902 | | // break; |
|---|
| 903 | | // } |
|---|
| 904 | | // else if (help > hashkey) end = (start+end)/2; |
|---|
| 905 | | // else if (help < hashkey) start = (start+end)/2 + 1; |
|---|
| 906 | | // } |
|---|
| 907 | | // } |
|---|
| | 892 | // int hash_start; |
|---|
| | 893 | // int hash_end; |
|---|
| | 894 | // |
|---|
| | 895 | // while (start < end) { |
|---|
| | 896 | // int help = self.hashT[2*((start+end)/2)]; |
|---|
| | 897 | // if (help == hashkey) { |
|---|
| | 898 | // hash_start = self.hashT[2*((start+end)/2)+1]; |
|---|
| | 899 | // if (2*((start+end)/2)+3 >= len(self.hashT)) hash_end = len(hash); |
|---|
| | 900 | // else hash_end = self.hashT[2*((start+end)/2)+3]; |
|---|
| | 901 | // |
|---|
| | 902 | // pattern.hashkeys[(a0,a1)][hk].extend([hash_start, hash_start, hash_end]); |
|---|
| | 903 | // break; |
|---|
| | 904 | // } |
|---|
| | 905 | // else if (help > hashkey) end = (start+end)/2; |
|---|
| | 906 | // else if (help < hashkey) start = (start+end)/2 + 1; |
|---|
| | 907 | // } |
|---|
| | 908 | // } |
|---|
| 1110 | | // vector<int>* mvs = moves[self.boardsize*x+y]; |
|---|
| 1111 | | // long d = moveIntsArr.size() | FLAG_POINTER; |
|---|
| 1112 | | // |
|---|
| 1113 | | // vector<long> Blist; |
|---|
| 1114 | | // vector<long> Wlist; |
|---|
| 1115 | | // vector<long> Elist; |
|---|
| 1116 | | // |
|---|
| 1117 | | // Elist.push_back(0); |
|---|
| 1118 | | // |
|---|
| 1119 | | // int moveIndex = 0; |
|---|
| 1120 | | // while (moveIndex < mvs.size()) { |
|---|
| 1121 | | // if (mvs[moveIndex] & FLAG_BLACK) { |
|---|
| 1122 | | // d = d | FLAG_BLACK; |
|---|
| 1123 | | // Blist.push_back(mvs[moveIndex] & ~FLAG_BLACK); |
|---|
| 1124 | | // Elist.push_back(mvs[moveIndex] & ~FLAG_BLACK); |
|---|
| 1125 | | // if (moveIndex + 1 < mvs->size()) { |
|---|
| 1126 | | // Blist.push_back(mvs[moveIndex+1] & ~(FLAG_BLACK|FLAG_WHITE|FLAG_REMOVE)); |
|---|
| 1127 | | // Elist.push_back(mvs[moveIndex+1] & ~(FLAG_BLACK|FLAG_WHITE|FLAG_REMOVE)); |
|---|
| 1128 | | // } |
|---|
| 1129 | | // else Blist.push_back(MAXNOMOVES); |
|---|
| 1130 | | // } |
|---|
| 1131 | | // if (mvs[moveIndex] & FLAG_WHITE) { |
|---|
| 1132 | | // d = d | FLAG_WHITE; |
|---|
| 1133 | | // Wlist.push_back(mvs[moveIndex] & ~FLAG_WHITE); |
|---|
| 1134 | | // Elist.push_back(mvs[moveIndex] & ~FLAG_WHITE); |
|---|
| 1135 | | // if (moveIndex + 1 < mvs->size()) { |
|---|
| 1136 | | // Wlist.push_back(mvs[moveIndex+1] & ~(FLAG_BLACK|FLAG_WHITE|FLAG_REMOVE)); |
|---|
| 1137 | | // Elist.push_back(mvs[moveIndex+1] & ~(FLAG_BLACK|FLAG_WHITE|FLAG_REMOVE)); |
|---|
| 1138 | | // } |
|---|
| 1139 | | // else Wlist.append(MAXNOMOVES); |
|---|
| 1140 | | // } |
|---|
| 1141 | | // moveIndex += 2; |
|---|
| 1142 | | // } |
|---|
| | 1111 | // vector<int>* mvs = moves[self.boardsize*x+y]; |
|---|
| | 1112 | // long d = moveIntsArr.size() | FLAG_POINTER; |
|---|
| | 1113 | // |
|---|
| | 1114 | // vector<long> Blist; |
|---|
| | 1115 | // vector<long> Wlist; |
|---|
| | 1116 | // vector<long> Elist; |
|---|
| | 1117 | // |
|---|
| | 1118 | // Elist.push_back(0); |
|---|
| | 1119 | // |
|---|
| | 1120 | // int moveIndex = 0; |
|---|
| | 1121 | // while (moveIndex < mvs.size()) { |
|---|
| | 1122 | // if (mvs[moveIndex] & FLAG_BLACK) { |
|---|
| | 1123 | // d = d | FLAG_BLACK; |
|---|
| | 1124 | // Blist.push_back(mvs[moveIndex] & ~FLAG_BLACK); |
|---|
| | 1125 | // Elist.push_back(mvs[moveIndex] & ~FLAG_BLACK); |
|---|
| | 1126 | // if (moveIndex + 1 < mvs->size()) { |
|---|
| | 1127 | // Blist.push_back(mvs[moveIndex+1] & ~(FLAG_BLACK|FLAG_WHITE|FLAG_REMOVE)); |
|---|
| | 1128 | // Elist.push_back(mvs[moveIndex+1] & ~(FLAG_BLACK|FLAG_WHITE|FLAG_REMOVE)); |
|---|
| | 1129 | // } |
|---|