| 211 | | for(int k1=0; k1 < yBlocks; k1++) { |
|---|
| 212 | | char nlist[400]; |
|---|
| 213 | | int nlistIndex = 0; |
|---|
| 214 | | |
|---|
| 215 | | for(int k2=0; k2 < xBlocks; k2++) { |
|---|
| 216 | | int n = 0; |
|---|
| 217 | | for(int x=0; x<2; x++) { |
|---|
| 218 | | for(int y=0; y<2; y++) { |
|---|
| 219 | | int indexX = k1 * 2 + y - j; |
|---|
| 220 | | int indexY = k2 * 2 + x - i; |
|---|
| 221 | | if (0 <= indexX && indexX < sizeX && 0 <= indexY && indexY < sizeY) { |
|---|
| 222 | | if (getFinal(indexX,indexY)=='X') |
|---|
| 223 | | n |= 1 << (2*(2*x+y)); |
|---|
| 224 | | else if (getFinal(indexX,indexY)=='O') |
|---|
| 225 | | n |= 1 << (2*(2*x+y)+1); |
|---|
| 226 | | } |
|---|
| 227 | | } |
|---|
| 228 | | } |
|---|
| 229 | | nlist[nlistIndex++] = n; |
|---|
| 230 | | } |
|---|
| 231 | | |
|---|
| 232 | | int start = 0; |
|---|
| 233 | | int end = nlistIndex; |
|---|
| 234 | | |
|---|
| 235 | | while (start < end && !nlist[start]) start++; |
|---|
| 236 | | while (end > start && !nlist[end-1]) end--; |
|---|
| 237 | | |
|---|
| 238 | | nextBlock[nextBlockIndex++] = start; |
|---|
| 239 | | nextBlock[nextBlockIndex++] = end-start; |
|---|
| 240 | | for(int current=start; current < end; current++) |
|---|
| 241 | | nextBlock[nextBlockIndex++] = nlist[current]; |
|---|
| 242 | | } |
|---|
| 243 | | char* nB = new char[nextBlockIndex]; |
|---|
| 244 | | for(int ii=0; ii<nextBlockIndex; ii++) nB[ii] = nextBlock[ii]; |
|---|
| 245 | | bitlengths[2*i + j] = nextBlockIndex; |
|---|
| 246 | | bits[2*i + j] = nB; |
|---|
| 247 | | delete [] nextBlock; |
|---|
| 248 | | } |
|---|
| 249 | | } |
|---|
| 250 | | // cout << "Leave method Pattern::Pattern(...)" << endl; |
|---|
| | 211 | for(int k1=0; k1 < yBlocks; k1++) { |
|---|
| | 212 | char nlist[400]; |
|---|
| | 213 | int nlistIndex = 0; |
|---|
| | 214 | |
|---|
| | 215 | for(int k2=0; k2 < xBlocks; k2++) { |
|---|
| | 216 | int n = 0; |
|---|
| | 217 | for(int x=0; x<2; x++) { |
|---|
| | 218 | for(int y=0; y<2; y++) { |
|---|
| | 219 | int indexX = k1 * 2 + y - j; |
|---|
| | 220 | int indexY = k2 * 2 + x - i; |
|---|
| | 221 | if (0 <= indexX && indexX < sizeX && 0 <= indexY && indexY < sizeY) { |
|---|
| | 222 | if (getFinal(indexX,indexY)=='X') |
|---|
| | 223 | n |= 1 << (2*(2*x+y)); |
|---|
| | 224 | else if (getFinal(indexX,indexY)=='O') |
|---|
| | 225 | n |= 1 << (2*(2*x+y)+1); |
|---|
| | 226 | } |
|---|
| | 227 | } |
|---|
| | 228 | } |
|---|
| | 229 | nlist[nlistIndex++] = n; |
|---|
| | 230 | } |
|---|
| | 231 | |
|---|
| | 232 | int start = 0; |
|---|
| | 233 | int end = nlistIndex; |
|---|
| | 234 | |
|---|
| | 235 | while (start < end && !nlist[start]) start++; |
|---|
| | 236 | while (end > start && !nlist[end-1]) end--; |
|---|
| | 237 | |
|---|
| | 238 | nextBlock[nextBlockIndex++] = start; |
|---|
| | 239 | nextBlock[nextBlockIndex++] = end-start; |
|---|
| | 240 | for(int current=start; current < end; current++) |
|---|
| | 241 | nextBlock[nextBlockIndex++] = nlist[current]; |
|---|
| | 242 | } |
|---|
| | 243 | char* nB = new char[nextBlockIndex]; |
|---|
| | 244 | for(int ii=0; ii<nextBlockIndex; ii++) nB[ii] = nextBlock[ii]; |
|---|
| | 245 | bitlengths[2*i + j] = nextBlockIndex; |
|---|
| | 246 | bits[2*i + j] = nB; |
|---|
| | 247 | delete [] nextBlock; |
|---|
| | 248 | } |
|---|
| | 249 | } |
|---|
| | 250 | // cout << "Leave method Pattern::Pattern(...)" << endl; |
|---|
| 488 | | pNew.flip = f; |
|---|
| 489 | | // cout << "BP1" << endl; |
|---|
| 490 | | |
|---|
| 491 | | // delete [] newInitialPos; |
|---|
| 492 | | // delete [] newContList; FIXME |
|---|
| 493 | | // cout << "BP1.5" << endl; |
|---|
| 494 | | |
|---|
| 495 | | vector<Pattern>::iterator it; |
|---|
| 496 | | bool foundNewPattern = true; |
|---|
| 497 | | for(it = l.begin(); it != l.end(); it++) { |
|---|
| 498 | | if (pNew == *it) { |
|---|
| 499 | | foundNewPattern = false; |
|---|
| 500 | | break; |
|---|
| 501 | | } |
|---|
| 502 | | } |
|---|
| 503 | | if (foundNewPattern) l.push_back(pNew); |
|---|
| 504 | | |
|---|
| 505 | | if (pNew == pattern) sy.push_back(pair<int,int>(f,0)); |
|---|
| 506 | | // cout << "BP2" << endl; |
|---|
| 507 | | |
|---|
| 508 | | if (nextMove || !fixedColor) { |
|---|
| 509 | | // FIXME: nach flip "entspricht" links oben nicht mehr 0,0, also newInitialPos, newContList anpassen |
|---|
| 510 | | // FIXME ... verstehe diese Bemerkung nicht!!! |
|---|
| 511 | | // FIXME |
|---|
| 512 | | char* newInitialPos = new char[pattern.sizeX*pattern.sizeY]; |
|---|
| 513 | | for(int i=0; i<pattern.sizeX; i++) { |
|---|
| 514 | | for(int j=0; j<pattern.sizeY; j++) { |
|---|
| 515 | | newInitialPos[Pattern::flipsX(f,i,j,pattern.sizeX-1,pattern.sizeY-1) + newSizeX*Pattern::flipsY(f,i,j,pattern.sizeX-1,pattern.sizeY-1)] = |
|---|
| 516 | | invertColor(pattern.getInitial(i, j)); |
|---|
| 517 | | } |
|---|
| 518 | | } |
|---|
| 519 | | |
|---|
| 520 | | char* newContList = new char[pattern.lenContList*4+1]; |
|---|
| 521 | | for(int i=0; i<pattern.lenContList; i++) { |
|---|
| 522 | | newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); |
|---|
| 523 | | newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); |
|---|
| 524 | | newContList[4*i+2] = invertColor(pattern.contList[4*i+2]); |
|---|
| 525 | | newContList[4*i+3] = '/'; // FIXME siehe oben |
|---|
| 526 | | } |
|---|
| 527 | | newContList[pattern.lenContList*4] = 0; |
|---|
| 528 | | |
|---|
| 529 | | Pattern pNew1(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, |
|---|
| 530 | | newInitialPos, newContList, pattern.lenContList, pattern.moveTwo); |
|---|
| 531 | | pNew.flip = f; |
|---|
| 532 | | pNew1.colorSwitch = 1; |
|---|
| 533 | | |
|---|
| 534 | | delete [] newInitialPos; |
|---|
| 535 | | delete [] newContList; |
|---|
| 536 | | |
|---|
| 537 | | if (!fixedColor) { |
|---|
| 538 | | vector<Pattern>::iterator it; |
|---|
| 539 | | bool foundNewPattern = true; |
|---|
| 540 | | for(it = lCS.begin(); it != lCS.end(); it++) { |
|---|
| 541 | | if (pNew == *it) { |
|---|
| 542 | | foundNewPattern = false; |
|---|
| 543 | | break; |
|---|
| 544 | | } |
|---|
| 545 | | } |
|---|
| 546 | | if (foundNewPattern) l.push_back(pNew); |
|---|
| 547 | | } |
|---|
| 548 | | |
|---|
| 549 | | if (pNew1 == pattern) { |
|---|
| 550 | | if (!fixedColor) sy.push_back(pair<int,int>(f,1)); |
|---|
| 551 | | if (nextMove) special = f; |
|---|
| 552 | | } |
|---|
| 553 | | } |
|---|
| 554 | | } |
|---|
| 555 | | |
|---|
| 556 | | vector<Pattern>::iterator it; |
|---|
| 557 | | for(it = lCS.begin(); it != lCS.end(); it++) { |
|---|
| 558 | | vector<Pattern>::iterator it_l; |
|---|
| 559 | | bool contained_in_l = false; |
|---|
| 560 | | for(it_l = l.begin(); it_l != l.begin(); it_l++) |
|---|
| 561 | | if (*it == *it_l) { |
|---|
| 562 | | contained_in_l = true; |
|---|
| 563 | | break; |
|---|
| 564 | | } |
|---|
| 565 | | if (!contained_in_l) l.push_back(*it); |
|---|
| 566 | | } |
|---|
| 567 | | |
|---|
| 568 | | Symmetries symm(pattern.sizeX, pattern.sizeY); |
|---|
| 569 | | for(int i=0; i<symm.sizeX; i++) |
|---|
| 570 | | for(int j=0; j<symm.sizeY; j++) |
|---|
| 571 | | symm.set(i,j,i,j,0); |
|---|
| 572 | | |
|---|
| 573 | | vector<pair<int,int> >::iterator it_s; |
|---|
| 574 | | for(it_s=sy.begin(); it_s!=sy.end(); it_s++) { |
|---|
| 575 | | int s = it_s->first; |
|---|
| 576 | | int newSizeX = max(Pattern::flipsX(s,0,0,pattern.sizeX,pattern.sizeY), |
|---|
| | 488 | pNew.flip = f; |
|---|
| | 489 | // cout << "BP1" << endl; |
|---|
| | 490 | |
|---|
| | 491 | delete [] newInitialPos; |
|---|
| | 492 | delete [] newContList; |
|---|
| | 493 | // cout << "BP1.5" << endl; |
|---|
| | 494 | |
|---|
| | 495 | vector<Pattern>::iterator it; |
|---|
| | 496 | bool foundNewPattern = true; |
|---|
| | 497 | for(it = l.begin(); it != l.end(); it++) { |
|---|
| | 498 | if (pNew == *it) { |
|---|
| | 499 | foundNewPattern = false; |
|---|
| | 500 | break; |
|---|
| | 501 | } |
|---|
| | 502 | } |
|---|
| | 503 | if (foundNewPattern) l.push_back(pNew); |
|---|
| | 504 | |
|---|
| | 505 | if (pNew == pattern) sy.push_back(pair<int,int>(f,0)); |
|---|
| | 506 | // cout << "BP2" << endl; |
|---|
| | 507 | |
|---|
| | 508 | if (nextMove || !fixedColor) { |
|---|
| | 509 | // FIXME: nach flip "entspricht" links oben nicht mehr 0,0, also newInitialPos, newContList anpassen |
|---|
| | 510 | // FIXME ... verstehe diese Bemerkung nicht!!! |
|---|
| | 511 | // FIXME |
|---|
| | 512 | char* newInitialPos = new char[pattern.sizeX*pattern.sizeY]; |
|---|
| | 513 | for(int i=0; i<pattern.sizeX; i++) { |
|---|
| | 514 | for(int j=0; j<pattern.sizeY; j++) { |
|---|
| | 515 | newInitialPos[Pattern::flipsX(f,i,j,pattern.sizeX-1,pattern.sizeY-1) + newSizeX*Pattern::flipsY(f,i,j,pattern.sizeX-1,pattern.sizeY-1)] = |
|---|
| | 516 | invertColor(pattern.getInitial(i, j)); |
|---|
| | 517 | } |
|---|
| | 518 | } |
|---|
| | 519 | |
|---|
| | 520 | char* newContList = new char[pattern.lenContList*4+1]; |
|---|
| | 521 | for(int i=0; i<pattern.lenContList; i++) { |
|---|
| | 522 | newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); |
|---|
| | 523 | newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); |
|---|
| | 524 | newContList[4*i+2] = invertColor(pattern.contList[4*i+2]); |
|---|
| | 525 | newContList[4*i+3] = '/'; // FIXME siehe oben |
|---|
| | 526 | } |
|---|
| | 527 | newContList[pattern.lenContList*4] = 0; |
|---|
| | 528 | |
|---|
| | 529 | Pattern pNew1(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, |
|---|
| | 530 | newInitialPos, newContList, pattern.lenContList, pattern.moveTwo); |
|---|
| | 531 | pNew1.flip = f; |
|---|
| | 532 | pNew1.colorSwitch = 1; |
|---|
| | 533 | |
|---|
| | 534 | delete [] newInitialPos; |
|---|
| | 535 | delete [] newContList; |
|---|
| | 536 | |
|---|
| | 537 | if (!fixedColor) { |
|---|
| | 538 | vector<Pattern>::iterator it; |
|---|
| | 539 | bool foundNewPattern = true; |
|---|
| | 540 | for(it = lCS.begin(); it != lCS.end(); it++) { |
|---|
| | 541 | if (pNew1 == *it) { |
|---|
| | 542 | foundNewPattern = false; |
|---|
| | 543 | break; |
|---|
| | 544 | } |
|---|
| | 545 | } |
|---|
| | 546 | if (foundNewPattern) l.push_back(pNew1); |
|---|
| | 547 | } |
|---|
| | 548 | |
|---|
| | 549 | if (pNew1 == pattern) { |
|---|
| | 550 | if (!fixedColor) sy.push_back(pair<int,int>(f,1)); |
|---|
| | 551 | if (nextMove) special = f; |
|---|
| | 552 | } |
|---|
| | 553 | } |
|---|
| | 554 | } |
|---|
| | 555 | |
|---|
| | 556 | vector<Pattern>::iterator it; |
|---|
| | 557 | for(it = lCS.begin(); it != lCS.end(); it++) { |
|---|
| | 558 | vector<Pattern>::iterator it_l; |
|---|
| | 559 | bool contained_in_l = false; |
|---|
| | 560 | for(it_l = l.begin(); it_l != l.begin(); it_l++) |
|---|
| | 561 | if (*it == *it_l) { |
|---|
| | 562 | contained_in_l = true; |
|---|
| | 563 | break; |
|---|
| | 564 | } |
|---|
| | 565 | if (!contained_in_l) l.push_back(*it); |
|---|
| | 566 | } |
|---|
| | 567 | |
|---|
| | 568 | Symmetries symm(pattern.sizeX, pattern.sizeY); |
|---|
| | 569 | for(int i=0; i<symm.sizeX; i++) |
|---|
| | 570 | for(int j=0; j<symm.sizeY; j++) |
|---|
| | 571 | symm.set(i,j,i,j,0); |
|---|
| | 572 | |
|---|
| | 573 | vector<pair<int,int> >::iterator it_s; |
|---|
| | 574 | for(it_s=sy.begin(); it_s!=sy.end(); it_s++) { |
|---|
| | 575 | int s = it_s->first; |
|---|
| | 576 | int newSizeX = max(Pattern::flipsX(s,0,0,pattern.sizeX,pattern.sizeY), |
|---|
| 580 | | int c = it_s->second; |
|---|
| 581 | | Symmetries symm1(newSizeX, newSizeY); |
|---|
| 582 | | |
|---|
| 583 | | for(int i=0; i < pattern.sizeX; i++) { |
|---|
| 584 | | for(int j=0; j < pattern.sizeY; j++) { |
|---|
| 585 | | int fX = Pattern::flipsX(s, i, j, pattern.sizeX-1, pattern.sizeY-1); |
|---|
| 586 | | int fY = Pattern::flipsY(s, i, j, pattern.sizeX-1, pattern.sizeY-1); |
|---|
| 587 | | if ((i != fX || j != fY) && !symm1.has_key(fX, fY)) |
|---|
| 588 | | symm1.set(i,j, fX, fY, c); |
|---|
| 589 | | } |
|---|
| 590 | | } |
|---|
| 591 | | |
|---|
| 592 | | int cs; |
|---|
| 593 | | for(int i=0; i<symm.sizeX; i++) |
|---|
| 594 | | for(int j=0; j<symm.sizeY; j++) |
|---|
| 595 | | if (symm1.has_key(symm.getX(i,j), symm.getY(i,j))) { |
|---|
| 596 | | if ((symm1.getCS(symm.getX(i,j),symm.getY(i,j)) || symm.getCS(i,j)) && |
|---|
| 597 | | !(symm1.getCS(symm.getX(i,j),symm.getY(i,j)) && symm.getCS(i,j))) |
|---|
| 598 | | cs = 1; |
|---|
| 599 | | else cs = 0; |
|---|
| 600 | | symm.set(i,j,symm1.getX(symm.getX(i,j),symm.getY(i,j)), |
|---|
| 601 | | symm1.getY(symm.getX(i,j),symm.getY(i,j)), cs); |
|---|
| 602 | | } |
|---|
| 603 | | } |
|---|
| 604 | | |
|---|
| 605 | | if (special == -1) |
|---|
| 606 | | symm.special = -1; |
|---|
| 607 | | else |
|---|
| 608 | | symm.special = Pattern::PatternInvFlip(special); |
|---|
| 609 | | |
|---|
| 610 | | symmetries = symm; |
|---|
| 611 | | return l; |
|---|
| 612 | | cout << "Leave method PatternList::patternList" << endl; |
|---|
| | 580 | int c = it_s->second; |
|---|
| | 581 | Symmetries symm1(newSizeX, newSizeY); |
|---|
| | 582 | |
|---|
| | 583 | for(int i=0; i < pattern.sizeX; i++) { |
|---|
| | 584 | for(int j=0; j < pattern.sizeY; j++) { |
|---|
| | 585 | int fX = Pattern::flipsX(s, i, j, pattern.sizeX-1, pattern.sizeY-1); |
|---|
| | 586 | int fY = Pattern::flipsY(s, i, j, pattern.sizeX-1, pattern.sizeY-1); |
|---|
| | 587 | if ((i != fX || j != fY) && !symm1.has_key(fX, fY)) |
|---|
| | 588 | symm1.set(i,j, fX, fY, c); |
|---|
| | 589 | } |
|---|
| | 590 | } |
|---|
| | 591 | |
|---|
| | 592 | int cs; |
|---|
| | 593 | for(int i=0; i<symm.sizeX; i++) |
|---|
| | 594 | for(int j=0; j<symm.sizeY; j++) |
|---|
| | 595 | if (symm1.has_key(symm.getX(i,j), symm.getY(i,j))) { |
|---|
| | 596 | if ((symm1.getCS(symm.getX(i,j),symm.getY(i,j)) || symm.getCS(i,j)) && |
|---|
| | 597 | !(symm1.getCS(symm.getX(i,j),symm.getY(i,j)) && symm.getCS(i,j))) |
|---|
| | 598 | cs = 1; |
|---|
| | 599 | else cs = 0; |
|---|
| | 600 | symm.set(i,j,symm1.getX(symm.getX(i,j),symm.getY(i,j)), |
|---|
| | 601 | symm1.getY(symm.getX(i,j),symm.getY(i,j)), cs); |
|---|
| | 602 | } |
|---|
| | 603 | } |
|---|
| | 604 | |
|---|
| | 605 | if (special == -1) |
|---|
| | 606 | symm.special = -1; |
|---|
| | 607 | else |
|---|
| | 608 | symm.special = Pattern::PatternInvFlip(special); |
|---|
| | 609 | |
|---|
| | 610 | symmetries = symm; |
|---|
| | 611 | return l; |
|---|
| | 612 | cout << "Leave method PatternList::patternList" << endl; |
|---|
| 669 | | if (cc == 'B') cc='W'; |
|---|
| 670 | | else cc = 'B'; |
|---|
| 671 | | |
|---|
| 672 | | xx += XX; |
|---|
| 673 | | yy += YY; |
|---|
| 674 | | |
|---|
| 675 | | xxN = Pattern::flipsX(symmetries.special, xx, yy, boardsize-1, boardsize-1); |
|---|
| 676 | | yyN = Pattern::flipsY(symmetries.special, xx, yy, boardsize-1, boardsize-1); |
|---|
| 677 | | xx = xxN; |
|---|
| 678 | | yy = yyN; |
|---|
| 679 | | |
|---|
| 680 | | int XX1N = Pattern::flipsX(symmetries.special, XX1, YY1, boardsize-1, boardsize-1); |
|---|
| 681 | | int YY1N = Pattern::flipsY(symmetries.special, XX1, YY1, boardsize-1, boardsize-1); |
|---|
| 682 | | XX1 = XX1N; |
|---|
| 683 | | YY1 = YY1N; |
|---|
| 684 | | |
|---|
| 685 | | int XX2N = Pattern::flipsX(symmetries.special, XX2, YY2, boardsize-1, boardsize-1); |
|---|
| 686 | | int YY2N = Pattern::flipsY(symmetries.special, XX2, YY2, boardsize-1, boardsize-1); |
|---|
| 687 | | XX2 = XX2N; |
|---|
| 688 | | YY2 = YY2N; |
|---|
| 689 | | |
|---|
| 690 | | XX = XX1 < XX2 ? XX1 : XX2; |
|---|
| 691 | | YY = YY1 < YY2 ? YY1 : YY2; |
|---|
| 692 | | |
|---|
| 693 | | xx -= XX; |
|---|
| 694 | | yy -= YY; |
|---|
| 695 | | |
|---|
| 696 | | int xx1 = symmetries.getX(xx,yy); |
|---|
| 697 | | int yy1 = symmetries.getY(xx,yy); |
|---|
| 698 | | int cSymm1 = symmetries.getCS(xx,yy); |
|---|
| 699 | | |
|---|
| 700 | | if (!cSymm1) { |
|---|
| 701 | | xx = xx1; |
|---|
| 702 | | yy = yy1; |
|---|
| 703 | | } |
|---|
| 704 | | |
|---|
| 705 | | colorSwitch = 1-cSymm; |
|---|
| 706 | | // if (colorSwitch) numOfSwitched++; FIXME?! |
|---|
| | 667 | if (cc == 'B') cc='W'; |
|---|
| | 668 | else cc = 'B'; |
|---|
| | 669 | |
|---|
| | 670 | xx += XX; |
|---|
| | 671 | yy += YY; |
|---|
| | 672 | |
|---|
| | 673 | xxN = Pattern::flipsX(symmetries.special, xx, yy, boardsize-1, boardsize-1); |
|---|
| | 674 | yyN = Pattern::flipsY(symmetries.special, xx, yy, boardsize-1, boardsize-1); |
|---|
| | 675 | xx = xxN; |
|---|
| | 676 | yy = yyN; |
|---|
| | 677 | |
|---|
| | 678 | int XX1N = Pattern::flipsX(symmetries.special, XX1, YY1, boardsize-1, boardsize-1); |
|---|
| | 679 | int YY1N = Pattern::flipsY(symmetries.special, XX1, YY1, boardsize-1, boardsize-1); |
|---|
| | 680 | XX1 = XX1N; |
|---|
| | 681 | YY1 = YY1N; |
|---|
| | 682 | |
|---|
| | 683 | int XX2N = Pattern::flipsX(symmetries.special, XX2, YY2, boardsize-1, boardsize-1); |
|---|
| | 684 | int YY2N = Pattern::flipsY(symmetries.special, XX2, YY2, boardsize-1, boardsize-1); |
|---|
| | 685 | XX2 = XX2N; |
|---|
| | 686 | YY2 = YY2N; |
|---|
| | 687 | |
|---|
| | 688 | XX = XX1 < XX2 ? XX1 : XX2; |
|---|
| | 689 | YY = YY1 < YY2 ? YY1 : YY2; |
|---|
| | 690 | |
|---|
| | 691 | xx -= XX; |
|---|
| | 692 | yy -= YY; |
|---|
| | 693 | |
|---|
| | 694 | int xx1 = symmetries.getX(xx,yy); |
|---|
| | 695 | int yy1 = symmetries.getY(xx,yy); |
|---|
| | 696 | int cSymm1 = symmetries.getCS(xx,yy); |
|---|
| | 697 | |
|---|
| | 698 | if (!cSymm1) { |
|---|
| | 699 | xx = xx1; |
|---|
| | 700 | yy = yy1; |
|---|
| | 701 | } |
|---|
| | 702 | |
|---|
| | 703 | colorSwitch = 1-cSymm; |
|---|
| | 704 | // if (colorSwitch) numOfSwitched++; // FIXME?! |
|---|
| 787 | | if (winner == 'B') |
|---|
| 788 | | if (!(data[index].colorSwitch || colorSwitch)) { |
|---|
| 789 | | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, wcc))+1); |
|---|
| 790 | | PyDict_SetItemString(scxy, wcc, temp); |
|---|
| 791 | | Py_DECREF(temp); |
|---|
| 792 | | } |
|---|
| 793 | | else { |
|---|
| 794 | | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, lcc))+1); |
|---|
| 795 | | PyDict_SetItemString(scxy, lcc, temp); |
|---|
| 796 | | Py_DECREF(temp); |
|---|
| 797 | | } |
|---|
| 798 | | else if (winner == 'W') |
|---|
| 799 | | if (!(data[index].colorSwitch || colorSwitch)) { |
|---|
| 800 | | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, lcc))+1); |
|---|
| 801 | | PyDict_SetItemString(scxy, lcc, temp); |
|---|
| 802 | | Py_DECREF(temp); |
|---|
| 803 | | } |
|---|
| 804 | | else { |
|---|
| 805 | | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, wcc))+1); |
|---|
| 806 | | PyDict_SetItemString(scxy, wcc, temp); |
|---|
| 807 | | Py_DECREF(temp); |
|---|
| 808 | | } |
|---|
| 809 | | } |
|---|
| | 785 | if (winner == 'B') |
|---|
| | 786 | if (!(data[index].colorSwitch || colorSwitch)) { |
|---|
| | 787 | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, wcc))+1); |
|---|
| | 788 | PyDict_SetItemString(scxy, wcc, temp); |
|---|
| | 789 | Py_DECREF(temp); |
|---|
| | 790 | } |
|---|
| | 791 | else { |
|---|
| | 792 | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, lcc))+1); |
|---|
| | 793 | PyDict_SetItemString(scxy, lcc, temp); |
|---|
| | 794 | Py_DECREF(temp); |
|---|
| | 795 | } |
|---|
| | 796 | else if (winner == 'W') |
|---|
| | 797 | if (!(data[index].colorSwitch || colorSwitch)) { |
|---|
| | 798 | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, lcc))+1); |
|---|
| | 799 | PyDict_SetItemString(scxy, lcc, temp); |
|---|
| | 800 | Py_DECREF(temp); |
|---|
| | 801 | } |
|---|
| | 802 | else { |
|---|
| | 803 | PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, wcc))+1); |
|---|
| | 804 | PyDict_SetItemString(scxy, wcc, temp); |
|---|
| | 805 | Py_DECREF(temp); |
|---|
| | 806 | } |
|---|
| | 807 | } |
|---|