Show
Ignore:
Timestamp:
08/16/06 22:26:22 (2 years ago)
Author:
ug
Message:

Worked some more on pattern.cc ... not done yet, though.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/devel/pattern.cc

    r153 r174  
    11// File: pattern.cc 
    22 
    3 //   Copyright (C) 2001-4 Ulrich Goertz (u@g0ertz.de) 
     3//   Copyright (C) 2001-6 Ulrich Goertz (u@g0ertz.de) 
    44 
    55//   This file is part of Kombilo 0.6, a go database program. 
     
    2424 
    2525#include "pattern.h" 
     26#include <iostream> 
    2627 
    2728Symmetries::Symmetries(int sX, int sY) { 
     29        cout << "Enter method Symmetries::Symmetries" << endl;  
    2830  sizeX = sX; 
    2931  sizeY = sY; 
     
    8688    dataCS[i + j*sizeX] = cs; 
    8789  } 
    88   else printf("Error Symmetries\n"); // FIXME 
     90  else printf("Error Symmetries1\n"); // FIXME 
    8991} 
    9092 
    9193int Symmetries::getX(int i, int j) { 
    9294  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) return dataX[i + j*sizeX]; 
    93   else printf("Error Symmetries\n"); // FIXME 
     95  else printf("Error Symmetries2\n"); // FIXME 
    9496  return -1; 
    9597} 
     
    9799int Symmetries::getY(int i, int j) { 
    98100  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) return dataY[i + j*sizeX]; 
    99   else printf("Error Symmetries\n"); // FIXME 
     101  else printf("Error Symmetries3\n"); // FIXME 
    100102  return -1; 
    101103} 
     
    103105int Symmetries::getCS(int i, int j) { 
    104106  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) return dataCS[i + j*sizeX]; 
    105   else printf("Error Symmetries\n"); // FIXME 
     107  else printf("Error Symmetries4\n"); // FIXME 
    106108  return -1; 
    107109} 
     
    112114    else return 1; 
    113115  } 
    114   else printf("Error Symmetries\n"); // FIXME 
     116  else printf("Error Symmetries5\n"); // FIXME 
    115117  return 0; 
    116118} 
     
    146148} 
    147149  
    148 char Pattern::getBits(int b, int i) { 
    149   return bits[b][i]; 
     150int Pattern::getBits(int b, int i) { 
     151  return (int)bits[b][i]; 
    150152} 
    151153 
    152154 
    153155Pattern::Pattern() { 
    154   // FIXME?! 
     156        // cout << "Enter method Pattern::Pattern()" << endl;  
     157  initialPos = 0; 
     158        finalPos = 0; 
     159        contList = 0; 
     160        bits = 0; 
     161        bitlengths = 0; // FIXME?! 
    155162} 
    156163 
    157164 
    158165Pattern::Pattern(int le, int ri, int to, int bo, int sX, int sY, 
    159                  char* iPos, char* cList, int lenCList, char mOne) { 
     166                         char* iPos, char* cList, int lenCList, char mOne) { 
     167        // cout << "Enter method Pattern::Pattern" << endl;  
    160168  flip = 0; 
    161169  colorSwitch = 0; 
     
    183191 
    184192  lenContList = lenCList; 
    185   if (lenCList) { 
    186     contList = new char[lenCList*4]; 
    187     for(int i=0; i<4*lenCList; i++) contList[i] = cList[i]; 
    188     for(int i=0; i<lenContList; i++) { 
    189       finalPos[contList[4*i] + sizeX * contList[4*i+1]] = BW2XO(contList[4*i+2]); 
    190     } 
    191   } 
    192   else contList = 0; 
     193        contList = new char[lenCList*4+1]; 
     194        for(int i=0; i<4*lenCList; i++) contList[i] = cList[i]; 
     195        for(int i=0; i<lenContList; i++) { 
     196                finalPos[contList[4*i] + sizeX * contList[4*i+1]] = BW2XO(contList[4*i+2]); 
     197        } 
     198  contList[lenCList*4] = 0; 
    193199 
    194200  bits = new charp[4]; 
    195  
    196   for(int i=0; i>2; i++) { 
     201        bitlengths = new int[4]; 
     202 
     203  for(int i=0; i<2; i++) { 
    197204    for(int j=0; j<2; j++) { 
    198205      int xBlocks = (sizeY+i+1)/2; 
     
    202209      nextBlock[nextBlockIndex++] = yBlocks; 
    203210 
    204       for(int k1=0; k1 < yBlocks; k1++) { 
    205         char nlist[400]; 
    206         int nlistIndex = 0; 
    207  
    208         for(int k2; k2 < xBlocks; k2++) { 
    209           int n = 0; 
    210           for(int x=0; x<2; x++) { 
    211             for(int y=0; y<2; y++) { 
    212               int indexX = k1 * 2 + y - j; 
    213               int indexY = k2 * 2 + x - i; 
    214               if (0 <= indexX && indexX < sizeX && 0 <= indexY && indexY < sizeY) { 
    215                 if (getFinal(indexX,indexY)=='X') 
    216                   n |= 1 << (2*(2*x+y)); 
    217                 else if (getFinal(indexX,indexY)=='O') 
    218                   n |= 1 << (2*(2*x+y)+1); 
    219               } 
    220             } 
    221           } 
    222           nlist[nlistIndex++] = n; 
    223         }               
    224          
    225         int start = 0; 
    226         int end = nlistIndex; 
    227          
    228         while (start < end && !nlist[start]) start++; 
    229         while (end > start && !nlist[end-1]) end--; 
    230  
    231         nextBlock[nextBlockIndex++] = start; 
    232         nextBlock[nextBlockIndex++] = end-start; 
    233         for(int current=start; current < end; current++)  
    234           nextBlock[nextBlockIndex++] = nlist[current]; 
    235       } 
    236       char* nB = new char[nextBlockIndex]; 
    237       for(int ii=0; ii<nextBlockIndex; ii++) nB[ii] = nextBlock[ii]; 
    238       bits[2*i + j] = nB; 
    239       delete [] nextBlock; 
    240     } 
    241   } 
     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;  
    242251} 
    243252 
    244253Pattern::~Pattern() { 
     254        // cout << "Enter method Pattern::~Pattern" << endl;  
    245255  if (initialPos) delete [] initialPos; 
    246256  if (finalPos) delete [] finalPos; 
    247257  if (contList) delete [] contList; 
    248   if (bits) delete [] bits; 
     258  if (bitlengths) { 
     259                delete [] bitlengths; 
     260                for(int i=0; i<4; i++) 
     261                        if (bits[i]) delete [] bits[i]; 
     262                delete [] bits; 
     263        } 
     264        // cout << "Leave method Pattern::~Pattern" << endl;  
    249265} 
    250266 
    251267Pattern::Pattern(const Pattern& p) { 
     268        // cout << "Enter method Pattern::Pattern(const Pattern&)" << endl;  
    252269  left = p.left; 
    253270  right = p.right; 
     
    273290  } 
    274291  else contList = 0; 
     292        if (p.bitlengths) { 
     293                bits = new charp[4]; 
     294                bitlengths = new int[4]; 
     295 
     296                for(int i=0; i<4; i++) { 
     297                        bitlengths[i] = p.bitlengths[i]; 
     298                        if (bitlengths[i]>0) bits[i] = new char[bitlengths[i]]; 
     299                        else { 
     300                                bits[i] = 0; 
     301                                continue; 
     302                        } 
     303                        for(int j=0; j<bitlengths[i]; j++) 
     304                                bits[i][j] = p.bits[i][j]; 
     305                } 
     306        } 
     307        else { 
     308                bits = 0; 
     309                bitlengths = 0; 
     310        } 
    275311} 
    276312 
    277313Pattern& Pattern::copy(const Pattern& p) { 
     314        cout << "Enter method Pattern::copy" << endl;  
    278315  if (&p != this) { 
    279316    left = p.left; 
     
    292329    if (contList) delete [] contList; 
    293330    if (bits) delete [] bits; 
     331    if (bitlengths) delete [] bitlengths; 
    294332     
    295333    initialPos = new char[sizeX*sizeY]; 
     
    300338    } 
    301339    lenContList = p.lenContList; 
    302     if (lenContList) { 
    303       contList = new char[lenContList*4]; 
    304       for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 
    305     } 
    306     else contList = 0; 
    307  
    308     printf("OUCH problem with copying bits ...\n"); // FIXME 
    309     for(int i=0; i<4; i++) { 
    310       bits[i] = 0; // FIXME 
    311     } 
     340    contList = new char[lenContList*4+1]; 
     341    for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 
     342    contList[lenContList*4] = 0; 
     343 
     344                if (p.bitlengths) { 
     345                        bits = new charp[4]; 
     346                        bitlengths = new int[4]; 
     347 
     348                        for(int i=0; i<4; i++) { 
     349                                bitlengths[i] = p.bitlengths[i]; 
     350                                if (bitlengths[i]>0) bits[i] = new char[bitlengths[i]]; 
     351                                else { 
     352                                        bits[i] = 0; 
     353                                        continue; 
     354                                } 
     355                                for(int j=0; j<bitlengths[i]; j++) 
     356                                        bits[i][j] = p.bits[i][j]; 
     357                        } 
     358                } 
     359                else { 
     360                        bits = 0; 
     361                        bitlengths = 0; 
     362                } 
    312363  } 
    313364  return *this; 
     365        cout << "Leave method Pattern::copy " << endl;  
     366} 
     367 
     368void Pattern::printPattern() { 
     369        printf("print pattern\n"); 
    314370} 
    315371 
     
    347403 
    348404PatternList::PatternList(Pattern& p, int fColor, int nMove, int bsize) { 
     405        // cout << "Enter method PatternList::PatternList(...)" << endl;  
    349406  pattern.copy(p); 
    350407  fixedColor = fColor; 
    351408  nextMove = nMove; 
    352409  boardsize = bsize; 
     410        // cout << "BP1" << endl;  
    353411 
    354412  data = patternList(); 
     413        // cout << "Leave method PatternList::PatternList(...)" << endl;  
    355414} 
    356415 
     
    377436         
    378437vector<Pattern> PatternList::patternList() { 
     438        cout << "Enter method PatternList::patternList" << endl;  
    379439         
    380440  vector<Pattern> l; 
    381441  vector<Pattern> lCS; 
    382442  vector<pair<int,int> > sy; 
    383          
    384443  int special = -1; 
    385    
    386   for(int f=0; f < 8; f++) { 
    387     int newSizeX = max(Pattern::flipsX(f,0,0,pattern.sizeX,pattern.sizeY), 
    388                        Pattern::flipsX(f,pattern.sizeX,pattern.sizeY,pattern.sizeX,pattern.sizeY)); 
    389     int newSizeY = max(Pattern::flipsY(f,0,0,pattern.sizeX,pattern.sizeY), 
    390                        Pattern::flipsY(f,pattern.sizeX,pattern.sizeY,pattern.sizeX,pattern.sizeY)); 
    391      
    392     int newLeft = min(Pattern::flipsX(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
    393                       Pattern::flipsX(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
    394                                       boardsize-1,boardsize-1)); 
    395     int newRight = max(Pattern::flipsX(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
    396                        Pattern::flipsX(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
    397                                        boardsize-1,boardsize-1)) - (newSizeX-1); 
    398     int newTop = min(Pattern::flipsY(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
    399                      Pattern::flipsY(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
    400                                      boardsize-1,boardsize-1)); 
    401     int newBottom = max(Pattern::flipsY(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
    402                         Pattern::flipsY(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
    403                                         boardsize-1,boardsize-1)) - (newSizeY - 1); 
    404  
     444 
     445        for(int f = 0; f < 8; f++) { 
     446                int newSizeX = max(Pattern::flipsX(f,0,0,pattern.sizeX,pattern.sizeY), 
     447                       Pattern::flipsX(f,pattern.sizeX,pattern.sizeY,pattern.sizeX,pattern.sizeY)); 
     448                int newSizeY = max(Pattern::flipsY(f,0,0,pattern.sizeX,pattern.sizeY), 
     449                       Pattern::flipsY(f,pattern.sizeX,pattern.sizeY,pattern.sizeX,pattern.sizeY)); 
     450 
     451                int newLeft = min(Pattern::flipsX(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
     452                      Pattern::flipsX(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
     453                                      boardsize-1,boardsize-1)); 
     454                int newRight = max(Pattern::flipsX(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
     455                       Pattern::flipsX(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
     456                                       boardsize-1,boardsize-1)) - (newSizeX-1); 
     457                int newTop = min(Pattern::flipsY(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
     458                     Pattern::flipsY(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
     459                                     boardsize-1,boardsize-1)); 
     460                int newBottom = max(Pattern::flipsY(f,pattern.left,pattern.top,boardsize-1,boardsize-1), 
     461                        Pattern::flipsY(f,pattern.right+pattern.sizeX-1,pattern.bottom+pattern.sizeY-1, 
     462                        boardsize-1,boardsize-1)) - (newSizeY - 1); 
     463 
     464                // printf("%d, %d, %d, %d, %d, %d, %d\n", f, newSizeX, newSizeY, newLeft, newRight, newTop, newBottom); 
    405465    char* newInitialPos = new char[pattern.sizeX*pattern.sizeY]; 
    406     for(int i=0; i<pattern.sizeX; i++) { 
    407       for(int j=0; j<pattern.sizeY; j++) { 
    408         newInitialPos[Pattern::flipsX(f,i,j,pattern.sizeX-1,pattern.sizeY-1) + \ 
    409                       pattern.sizeX*Pattern::flipsY(f,i,j,pattern.sizeX-1,pattern.sizeY-1)] = pattern.getInitial(i, j); 
    410       } 
    411     } 
    412  
    413     char* newContList = new char[pattern.lenContList*4]; 
    414     for(int i=0; i<pattern.lenContList; i++) { 
    415       newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], 
    416                                          pattern.sizeX-1,pattern.sizeY-1); 
    417       newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], 
    418                                            pattern.sizeX-1,pattern.sizeY-1); 
    419       newContList[4*i+2] = pattern.contList[4*i+2]; 
    420       newContList[4*i+3] = '/'; 
    421     } 
    422     newContList[pattern.lenContList*4-1] = 0; 
    423  
    424     Pattern pNew(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 
    425                  newInitialPos, newContList, pattern.lenContList, pattern.moveOne); 
    426  
    427     pNew.flip = f; 
    428  
    429     delete newInitialPos; 
    430     delete newContList; 
    431  
    432     vector<Pattern>::iterator it; 
    433     bool foundNewPattern = true; 
    434     for(it = l.begin(); it != l.end(); it++) { 
    435       if (pNew == *it) { 
    436         foundNewPattern = false; 
    437         break; 
    438       } 
    439     } 
    440     if (foundNewPattern) l.push_back(pNew); 
    441  
    442     if (pNew == pattern) sy.push_back(pair<int,int>(f,0)); 
    443    
    444     if (nextMove || !fixedColor) { 
    445       // FIXME: nach flip "entspricht" links oben nicht mehr 0,0, also newInitialPos, newContList anpassen 
    446         
    447       char* newInitialPos = new char[pattern.sizeX*pattern.sizeY]; 
    448       for(int i=0; i<pattern.sizeX; i++) { 
    449         for(int j=0; j<pattern.sizeY; j++) { 
    450           newInitialPos[Pattern::flipsX(f,i,j,pattern.sizeX-1,pattern.sizeY-1) + pattern.sizeX*Pattern::flipsY(f,i,j,pattern.sizeX-1,pattern.sizeY-1)] = 
    451             invertColor(pattern.getInitial(i, j)); 
    452         } 
    453       } 
    454  
    455       char* newContList = new char[pattern.lenContList*4]; 
    456       for(int i=0; i<pattern.lenContList; i++) { 
    457         newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); 
    458         newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); 
    459         newContList[4*i+2] = invertColor(pattern.contList[4*i+2]); 
    460         newContList[4*i+3] = '/'; 
    461       } 
    462       newContList[pattern.lenContList*4-1] = 0; 
    463  
    464       Pattern pNew1(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 
    465                     newInitialPos, newContList, pattern.lenContList, pattern.moveTwo); 
    466       pNew.flip = f; 
    467       pNew1.colorSwitch = 1; 
    468  
    469       delete newInitialPos; 
    470       delete newContList; 
    471  
    472       if (!fixedColor) { 
     466                for(int i=0; i<pattern.sizeX; i++) { 
     467                        for(int j=0; j<pattern.sizeY; j++) { 
     468                                newInitialPos[Pattern::flipsX(f,i,j,pattern.sizeX-1,pattern.sizeY-1) + \ 
     469                      newSizeX*Pattern::flipsY(f,i,j,pattern.sizeX-1,pattern.sizeY-1)] = pattern.getInitial(i, j); 
     470                        } 
     471                } 
     472 
     473                char* newContList = new char[pattern.lenContList*4+1]; 
     474                for(int i=0; i<pattern.lenContList; i++) { 
     475                        newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], 
     476                                         pattern.sizeX-1,pattern.sizeY-1); 
     477                        newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], 
     478                                              pattern.sizeX-1,pattern.sizeY-1); 
     479                        newContList[4*i+2] = pattern.contList[4*i+2]; 
     480                        newContList[4*i+3] = '/'; // FIXME: ist doch so Verschwendung 
     481                } 
     482                newContList[pattern.lenContList*4] = 0; 
     483 
     484                // cout << "BP0" << endl; 
     485                Pattern pNew(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 
     486                 newInitialPos, newContList, pattern.lenContList, pattern.moveOne); 
     487 
     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 
    473556        vector<Pattern>::iterator it; 
    474         bool foundNewPattern = true; 
    475557        for(it = lCS.begin(); it != lCS.end(); it++) { 
    476           if (pNew == *it) { 
    477             foundNewPattern = false; 
    478             break; 
    479           } 
    480         } 
    481         if (foundNewPattern) l.push_back(pNew); 
    482       } 
    483  
    484       if (pNew1 == pattern) { 
    485         if (!fixedColor) sy.push_back(pair<int,int>(f,1)); 
    486         if (nextMove) special = f; 
    487       } 
    488     } 
    489   } 
    490  
    491   vector<Pattern>::iterator it; 
    492   for(it = lCS.begin(); it != lCS.end(); it++) { 
    493     vector<Pattern>::iterator it_l; 
    494     bool contained_in_l = false; 
    495     for(it_l = l.begin(); it_l != l.begin(); it_l++) 
    496       if (*it == *it_l) { 
    497         contained_in_l = true; 
    498         break; 
    499       } 
    500     if (!contained_in_l) l.push_back(*it); 
    501   } 
    502  
    503   Symmetries symm(pattern.sizeX, pattern.sizeY); 
    504   for(int i=0; i<symm.sizeX; i++) 
    505     for(int j=0; j<symm.sizeY; j++) 
    506       symm.set(i,j,i,j,0); 
    507  
    508   vector<pair<int,int> >::iterator it_s; 
    509   for(it_s=sy.begin(); it_s!=sy.end(); it_s++) { 
    510     int s = it_s->first; 
    511     int c = it_s->second; 
    512     Symmetries symm1; 
    513  
    514     for(int i=0; i < pattern.sizeX; i++) { 
    515       for(int j=0; j < pattern.sizeY; j++) { 
    516         int fX = Pattern::flipsX(s, i, j, pattern.sizeX-1, pattern.sizeY-1); 
    517         int fY = Pattern::flipsY(s, i, j, pattern.sizeX-1, pattern.sizeY-1); 
    518         if ((i != fX || j != fY) && !symm1.has_key(fX, fY)) 
    519           symm1.set(i,j, fX, fY, c); 
    520       } 
    521     } 
    522  
    523     int cs; 
    524     for(int i=0; i<symm.sizeX; i++) 
    525       for(int j=0; j<symm.sizeY; j++) 
    526         if (symm1.has_key(symm.getX(i,j), symm.getY(i,j))) { 
    527           if ((symm1.getCS(symm.getX(i,j),symm.getY(i,j)) || symm.getCS(i,j)) &&  
    528               !(symm1.getCS(symm.getX(i,j),symm.getY(i,j)) && symm.getCS(i,j))) 
    529             cs = 1; 
    530           else cs = 0; 
    531           symm.set(i,j,symm1.getX(symm.getX(i,j),symm.getY(i,j)),  
    532                    symm1.getY(symm.getX(i,j),symm.getY(i,j)), cs); 
    533         } 
    534   } 
    535  
    536   if (special == -1) 
    537     symm.special = -1; 
    538   else 
    539     symm.special = Pattern::PatternInvFlip(special); 
    540    
    541   symmetries = symm; 
    542   return l; 
     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), 
     577                       Pattern::flipsX(s,pattern.sizeX,pattern.sizeY,pattern.sizeX,pattern.sizeY)); 
     578                int newSizeY = max(Pattern::flipsY(s,0,0,pattern.sizeX,pattern.sizeY), 
     579                       Pattern::flipsY(s,pattern.sizeX,pattern.sizeY,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;  
    543613} 
    544614 
     
    715785    } 
    716786 
    717     if (winner == 'B') 
    718       if (!(data[index].colorSwitch || colorSwitch)) { 
    719         PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, wcc))+1); 
    720         PyDict_SetItemString(scxy, wcc, temp); 
    721         Py_DECREF(temp); 
    722      
    723       else { 
    724         PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, lcc))+1); 
    725         PyDict_SetItemString(scxy, lcc, temp); 
    726         Py_DECREF(temp); 
    727      
    728     else if (winner == 'W') 
    729       if (!(data[index].colorSwitch || colorSwitch)) { 
    730         PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, lcc))+1); 
    731         PyDict_SetItemString(scxy, lcc, temp); 
    732         Py_DECREF(temp); 
    733      
    734       else { 
    735         PyObject *temp = PyInt_FromLong(PyInt_AsLong(PyDict_GetItemString(scxy, wcc))+1); 
    736         PyDict_SetItemString(scxy, wcc, temp); 
    737         Py_DECREF(temp); 
    738      
    739  
     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       
    740810  return Py_BuildValue("icii", 1, text, contLabelsIndex,  
    741811                       (data[index].colorSwitch or colorSwitch));