| 399 | | PatternList::updateContinuations(index, x, y, co, Xint, Yint, |
|---|
| 400 | | foundWhere, counter, |
|---|
| 401 | | continuations, contLabels, contLabelsIndex, |
|---|
| 402 | | winner) { |
|---|
| 403 | | |
|---|
| 404 | | xx, yy = Pattern.flips[PatternInvFlip(self.data[index].flip)](x, y) |
|---|
| | 399 | PatternList::updateContinuations(int index, int x, int y, char co, int Xint0, int Xint1, |
|---|
| | 400 | int Yint0, int Yint1, |
|---|
| | 401 | int foundWhere, int counter, |
|---|
| | 402 | PyObject* continuations, char* contLabels, int contLabelsIndex, |
|---|
| | 403 | char winner) { |
|---|
| | 404 | int xx = Pattern::flipsX(Pattern::PatternInvFlip(data[index].flip), x, y, boardsize-1, boardsize-1); |
|---|
| | 405 | int yy = Pattern::flipsY(Pattern::PatternInvFlip(data[index].flip), x, y, boardsize-1, boardsize-1); |
|---|
| | 406 | |
|---|
| | 407 | int XX1 = Pattern::flipsX(Pattern::patternInvFlip(data[index].flip, Xint0, Yint0, boardsize-1, boardsize-1)); |
|---|
| | 408 | int YY1 = Pattern::flipsY(Pattern::patternInvFlip(data[index].flip, Xint0, Yint0, boardsize-1, boardsize-1)); |
|---|
| | 409 | int XX2 = Pattern::flipsX(Pattern::patternInvFlip(data[index].flip, Xint1-1, Yint1-1, boardsize-1, boardsize-1)); |
|---|
| | 410 | int YY2 = Pattern::flipsY(Pattern::patternInvFlip(data[index].flip, Xint1-1, Yint1-1, boardsize-1, boardsize-1)); |
|---|
| | 411 | |
|---|
| | 412 | int XX = XX1 < XX2 ? XX1 : XX2; |
|---|
| | 413 | int YY = YY1 < YY2 ? YY1 : YY2; |
|---|
| 406 | | XX1, YY1 = Pattern.flips[PatternInvFlip(self.data[index].flip)](Xint[0], Yint[0]) |
|---|
| 407 | | XX2, YY2 = Pattern.flips[PatternInvFlip(self.data[index].flip)](Xint[1]-1, Yint[1]-1) |
|---|
| 408 | | XX = min(XX1, XX2) |
|---|
| 409 | | YY = min(YY1, YY2) |
|---|
| 410 | | |
|---|
| 411 | | xx -= XX |
|---|
| 412 | | yy -= YY |
|---|
| 413 | | |
|---|
| 414 | | if (self.data[index].colorSwitch and co == 'X') or \ |
|---|
| 415 | | (not self.data[index].colorSwitch and co == 'O'): |
|---|
| 416 | | cc = 'B' |
|---|
| 417 | | else: cc = 'W' |
|---|
| 418 | | |
|---|
| 419 | | (xx, yy), cSymm = self.symmetries[(xx,yy)] |
|---|
| 420 | | |
|---|
| 421 | | if (cc == 'B' and not cSymm) or (cc=='W' and cSymm): cc = 'B' |
|---|
| 422 | | else: cc = 'W' |
|---|
| 423 | | |
|---|
| 424 | | if self.nextMove: |
|---|
| 425 | | if ((self.nextMove == 2 and cc == 'B') \ |
|---|
| 426 | | or (self.nextMove == 1 and cc == 'W')): |
|---|
| 427 | | if self.symmetries[-1] != -1 and not self.fixedColor: |
|---|
| 428 | | |
|---|
| 429 | | if cc == 'B': cc='W' |
|---|
| 430 | | else: cc = 'B' |
|---|
| | 415 | xx -= XX; |
|---|
| | 416 | yy -= YY; |
|---|
| | 417 | |
|---|
| | 418 | char cc; |
|---|
| | 419 | if ((data[index].colorSwitch && co == 'X') || |
|---|
| | 420 | (!data[index].colorSwitch && co == 'O')) |
|---|
| | 421 | cc = 'B'; |
|---|
| | 422 | else cc = 'W'; |
|---|
| | 423 | |
|---|
| | 424 | int xxN = self_symmetries.getX(xx,yy); |
|---|
| | 425 | int yyN = self_symmetries.getY(xx,yy); |
|---|
| | 426 | int cSymm = self_symmetries.getCS(xx,yy); |
|---|
| | 427 | |
|---|
| | 428 | xx = xxN; |
|---|
| | 429 | yy = yyN; |
|---|
| | 430 | |
|---|
| | 431 | if ((cc == 'B' && !cSymm) || (cc=='W' && cSymm)) cc = 'B'; |
|---|
| | 432 | else cc = 'W'; |
|---|
| | 433 | |
|---|
| | 434 | int colorSwitch; |
|---|
| | 435 | |
|---|
| | 436 | if (nextMove) { |
|---|
| | 437 | if ((nextMove == 2 && cc == 'B') |
|---|
| | 438 | || (nextMove == 1 && cc == 'W')) { |
|---|
| | 439 | if (self_symmetries.special != -1 && !fixedColor) { |
|---|
| | 440 | |
|---|
| | 441 | if (cc == 'B') cc='W'; |
|---|
| | 442 | else cc = 'B'; |
|---|
| 432 | | xx += XX |
|---|
| 433 | | yy += YY |
|---|
| 434 | | |
|---|
| 435 | | xx, yy = Pattern.flips[self.symmetries[-1]](xx, yy) |
|---|
| 436 | | |
|---|
| 437 | | XX1, YY1 = Pattern.flips[self.symmetries[-1]](XX1, YY1) |
|---|
| 438 | | XX2, YY2 = Pattern.flips[self.symmetries[-1]](XX2, YY2) |
|---|
| 439 | | |
|---|
| 440 | | XX = min(XX1, XX2) |
|---|
| 441 | | YY = min(YY1, YY2) |
|---|
| 442 | | |
|---|
| 443 | | xx -= XX |
|---|
| 444 | | yy -= YY |
|---|
| 445 | | |
|---|
| 446 | | (xx1, yy1), cSymm1 = self.symmetries[(xx,yy)] |
|---|
| 447 | | if not cSymm1: |
|---|
| 448 | | xx, yy = xx1, yy1 |
|---|
| 449 | | |
|---|
| 450 | | colorSwitch = 1-cSymm |
|---|
| 451 | | if colorSwitch: numOfSwitched += 1 |
|---|
| 452 | | else: |
|---|
| 453 | | return 0,0,0,0 |
|---|
| 454 | | else: |
|---|
| 455 | | colorSwitch = cSymm |
|---|
| 456 | | if colorSwitch: numOfSwitched += 1 |
|---|
| 457 | | else: |
|---|
| 458 | | colorSwitch = cSymm |
|---|
| 459 | | |
|---|
| 460 | | if continuations.has_key((xx, yy)): |
|---|
| 461 | | continuations[(xx,yy)][cc] = continuations[(xx,yy)][cc]+1 |
|---|
| 462 | | else: |
|---|
| 463 | | if contLabelsIndex >= len(contLabels): text = '?' |
|---|
| 464 | | else: |
|---|
| 465 | | text = contLabels[contLabelsIndex] |
|---|
| 466 | | contLabelsIndex += 1 |
|---|
| 467 | | if cc == 'B': |
|---|
| 468 | | continuations[(xx,yy)] = {'B':1, 'W':0, |
|---|
| 469 | | 'tB':0, 'tW':0, |
|---|
| 470 | | 'wB':0,'lB':0,'wW':0,'lW':0, |
|---|
| 471 | | 'N': text} |
|---|
| 472 | | else: |
|---|
| 473 | | continuations[(xx,yy)] = {'B':0, 'W':1, 'tB':0, 'tW':0, 'wB':0, 'lB':0, |
|---|
| 474 | | 'wW':0, 'lW':0, 'N': text} |
|---|
| | 444 | xx += XX; |
|---|
| | 445 | yy += YY; |
|---|
| | 446 | |
|---|
| | 447 | xxN = Pattern::flipsX(self_symmetries.special, xx, yy); |
|---|
| | 448 | yyN = Pattern::flipsY(self_symmetries.special, xx, yy); |
|---|
| | 449 | xx = xxN; |
|---|
| | 450 | yy = yyN; |
|---|
| | 451 | |
|---|
| | 452 | int XX1N = Pattern::flipsX(self_symmetries.special, XX1, YY1); |
|---|
| | 453 | int YY1N = Pattern::flipsY(self_symmetries.special, XX1, YY1); |
|---|
| | 454 | XX1 = XX1N; |
|---|
| | 455 | YY1 = YY1N; |
|---|
| | 456 | |
|---|
| | 457 | int XX2N = Pattern::flipsX(self_symmetries.special, XX2, YY2); |
|---|
| | 458 | int YY2N = Pattern::flipsY(self_symmetries.special, XX2, YY2); |
|---|
| | 459 | XX2 = XX2N; |
|---|
| | 460 | YY2 = YY2N; |
|---|
| | 461 | |
|---|
| | 462 | XX = XX1 < XX2 ? XX1 : XX2; |
|---|
| | 463 | YY = YY1 < YY2 ? YY1 : YY2; |
|---|
| | 464 | |
|---|
| | 465 | xx -= XX; |
|---|
| | 466 | yy -= YY; |
|---|
| | 467 | |
|---|
| | 468 | int xx1 = self_symmetries.getX(xx,yy); |
|---|
| | 469 | int yy1 = self_symmetries.getY(xx,yy); |
|---|
| | 470 | int cSymm1 = self_symmetries.getCS(xx,yy); |
|---|
| | 471 | |
|---|
| | 472 | if (!cSymm1) { |
|---|
| | 473 | xx = xx1; |
|---|
| | 474 | yy = yy1; |
|---|
| | 475 | } |
|---|
| | 476 | |
|---|
| | 477 | colorSwitch = 1-cSymm; |
|---|
| | 478 | if (colorSwitch) numOfSwitched++; |
|---|
| | 479 | } |
|---|
| | 480 | else |
|---|
| | 481 | return 0,0,0,0; |
|---|
| | 482 | } |
|---|
| | 483 | else { |
|---|
| | 484 | colorSwitch = cSymm; |
|---|
| | 485 | if (colorSwitch) numOfSwitched++; |
|---|
| | 486 | } |
|---|
| | 487 | } |
|---|
| | 488 | else colorSwitch = cSymm; |
|---|
| | 489 | |
|---|
| | 490 | if (continuations.has_key((xx, yy))) |
|---|
| | 491 | continuations[(xx,yy)][cc] = continuations[(xx,yy)][cc]+1; // FIXME ... |
|---|
| | 492 | else { |
|---|
| | 493 | if (contLabelsIndex >= len(contLabels)) text = '?'; |
|---|
| | 494 | else { |
|---|
| | 495 | text = contLabels[contLabelsIndex]; |
|---|
| | 496 | contLabelsIndex++; |
|---|
| | 497 | } |
|---|
| | 498 | if (cc == 'B') |
|---|
| | 499 | continuations[(xx,yy)] = {'B':1, 'W':0, |
|---|
| | 500 | 'tB':0, 'tW':0, |
|---|
| | 501 | 'wB':0,'lB':0,'wW':0,'lW':0, |
|---|
| | 502 | 'N': text}; |
|---|
| | 503 | else |
|---|
| | 504 | continuations[(xx,yy)] = {'B':0, 'W':1, 'tB':0, 'tW':0, 'wB':0, 'lB':0, |
|---|
| | 505 | 'wW':0, 'lW':0, 'N': text}; |
|---|
| 476 | | if not foundWhere in [counter, counter+1]: |
|---|
| 477 | | continuations[(xx,yy)]['t'+cc] += 1 |
|---|
| 478 | | |
|---|
| 479 | | if winner == 'B': |
|---|
| 480 | | if not (self.data[index].colorSwitch or colorSwitch): |
|---|
| 481 | | continuations[(xx,yy)]['w'+cc] += 1 |
|---|
| 482 | | else: |
|---|
| 483 | | continuations[(xx,yy)]['l'+cc] += 1 |
|---|
| 484 | | elif winner == 'W': |
|---|
| 485 | | if not (self.data[index].colorSwitch or colorSwitch): |
|---|
| 486 | | continuations[(xx,yy)]['l'+cc] += 1 |
|---|
| 487 | | else: |
|---|
| 488 | | continuations[(xx,yy)]['w'+cc] += 1 |
|---|
| 489 | | |
|---|
| 490 | | return 1, continuations[(xx,yy)]['N'], contLabelsIndex, (self.data[index].colorSwitch or colorSwitch) |
|---|
| 491 | | |
|---|
| 492 | | } |
|---|
| 493 | | |
|---|
| | 507 | if (foundWhere != counter && foundWhere != counter+1) |
|---|
| | 508 | continuations[(xx,yy)]['t'+cc] += 1; |
|---|
| | 509 | |
|---|
| | 510 | if (winner == 'B') |
|---|
| | 511 | if (!(data[index].colorSwitch || colorSwitch)) |
|---|
| | 512 | continuations[(xx,yy)]['w'+cc] += 1; |
|---|
| | 513 | else continuations[(xx,yy)]['l'+cc] += 1; |
|---|
| | 514 | else if (winner == 'W') |
|---|
| | 515 | if (!(self.data[index].colorSwitch or colorSwitch)) |
|---|
| | 516 | continuations[(xx,yy)]['l'+cc] += 1; |
|---|
| | 517 | else continuations[(xx,yy)]['w'+cc] += 1; |
|---|
| | 518 | } |
|---|
| | 519 | return 1, continuations[(xx,yy)]['N'], contLabelsIndex, (self.data[index].colorSwitch or colorSwitch) |
|---|
| | 520 | } |
|---|
| | 521 | |
|---|