diff -r -u -X .ignore gnugo-copy/engine/globals.c gnugo/engine/globals.c
|
old
|
new
|
|
| 133 | 133 | float black_score; |
| 134 | 134 | |
| 135 | 135 | /* Close worms data. See liberty.h */ |
| 136 | | int close_worms[BOARDMAX][MAX_CLOSE_WORMS]; |
| 137 | | int number_close_worms[BOARDMAX]; |
| 138 | 136 | int close_black_worms[BOARDMAX][MAX_CLOSE_WORMS]; |
| 139 | 137 | int number_close_black_worms[BOARDMAX]; |
| 140 | 138 | int close_white_worms[BOARDMAX][MAX_CLOSE_WORMS]; |
diff -r -u -X .ignore gnugo-copy/engine/liberty.h gnugo/engine/liberty.h
|
old
|
new
|
|
| 740 | 740 | extern const int transformation2[8][2][2]; |
| 741 | 741 | |
| 742 | 742 | |
| 743 | | /* Arrays pointing out the closest worms from each vertex. The first |
| 744 | | * one is the closest worms of either color, the last two ones ignore |
| 745 | | * worms of the other color. Beyond a certain distance from any worm |
| 746 | | * no close worm is listed at all. Only the closest worm is listed |
| 747 | | * and if more than one are equally close they are all listed. The |
| 748 | | * number of equally close worms is given in the number_*_worms |
| 749 | | * arrays. If more than MAX_CLOSE_WORMS are equally close, none is |
| 750 | | * listed. |
| | 743 | /* Arrays pointing out the closest worms (of given color) from each |
| | 744 | * vertex. Beyond a certain distance from any worm no close worm is |
| | 745 | * listed at all. Only the closest worm is listed and if more than |
| | 746 | * one are equally close they are all listed. The number of equally |
| | 747 | * close worms is given in the number_*_worms arrays. If more than |
| | 748 | * MAX_CLOSE_WORMS are equally close, none is listed. |
| 751 | 749 | * |
| 752 | 750 | * See compute_effective_worm_sizes() in worm.c for details. |
| 753 | 751 | */ |
| 754 | 752 | #define MAX_CLOSE_WORMS 4 |
| 755 | | extern int close_worms[BOARDMAX][MAX_CLOSE_WORMS]; |
| 756 | | extern int number_close_worms[BOARDMAX]; |
| 757 | 753 | extern int close_black_worms[BOARDMAX][MAX_CLOSE_WORMS]; |
| 758 | 754 | extern int number_close_black_worms[BOARDMAX]; |
| 759 | 755 | extern int close_white_worms[BOARDMAX][MAX_CLOSE_WORMS]; |
diff -r -u -X .ignore gnugo-copy/engine/worm.c gnugo/engine/worm.c
|
old
|
new
|
|
| 553 | 553 | * territorial value of capturing a worm. Intersections that are |
| 554 | 554 | * shared are counted with equal fractional values for each worm. |
| 555 | 555 | * |
| 556 | | * We never count intersections further away than distance 3. |
| | 556 | * We never count intersections further away than distance 3 (distance |
| | 557 | * is number of intersections between a worm and checked intersection - |
| | 558 | * so when an intersection is adjacent to a worm, it distance is 0). |
| 557 | 559 | * |
| 558 | 560 | * This function is also used to compute arrays with information about |
| 559 | | * the distances to worms of both or either color. In the latter case |
| 560 | | * we count intersections up to a distance of 5. |
| | 561 | * the distances to worms of either color. In this case we count |
| | 562 | * intersections up to a distance of 5. |
| 561 | 563 | */ |
| 562 | 564 | |
| 563 | 565 | static void |
| 564 | 566 | compute_effective_worm_sizes() |
| 565 | 567 | { |
| 566 | | do_compute_effective_worm_sizes(BLACK | WHITE, close_worms, |
| 567 | | number_close_worms, 3); |
| | 568 | do_compute_effective_worm_sizes(BLACK | WHITE, NULL, NULL, 3); |
| 568 | 569 | do_compute_effective_worm_sizes(BLACK, close_black_worms, |
| 569 | 570 | number_close_black_worms, 5); |
| 570 | 571 | do_compute_effective_worm_sizes(WHITE, close_white_worms, |
| … |
… |
|
| 611 | 612 | |
| 612 | 613 | dist = 0; |
| 613 | 614 | found_one = 1; |
| | 615 | |
| | 616 | /* in each iteration dist is increased; found_one |
| | 617 | means, that at least one unchecked intersection |
| | 618 | was found in previous iteration */ |
| 614 | 619 | while (found_one && dist <= max_distance) { |
| 615 | 620 | found_one = 0; |
| 616 | 621 | dist++; |
| … |
… |
|
| 618 | 623 | if (distance[pos] != -1 || !ON_BOARD(pos)) |
| 619 | 624 | continue; /* already claimed */ |
| 620 | 625 | |
| | 626 | /* when unchecked intersection is found, all neighboring |
| | 627 | intersections are checked for equally close worms */ |
| 621 | 628 | for (r = 0; r < 4; r++) { |
| 622 | | int pos2 = pos + delta[r]; |
| | 629 | int neigbor_pos = pos + delta[r]; |
| 623 | 630 | |
| 624 | | if (ON_BOARD(pos2) && distance[pos2] == dist - 1) { |
| | 631 | if (ON_BOARD(neigbor_pos) && distance[neigbor_pos] == dist - 1) { |
| 625 | 632 | found_one = 1; |
| 626 | 633 | distance[pos] = dist; |
| 627 | | for (k = 0; k < nworms[pos2]; k++) { |
| | 634 | |
| | 635 | /* we check, if a worm is already written into list of equally |
| | 636 | close worms for checked position; if not we add new entry |
| | 637 | in worms[pos] */ |
| | 638 | for (k = 0; k < nworms[neigbor_pos]; k++) { |
| 628 | 639 | int already_counted = 0; |
| 629 | 640 | for (l = 0; l < nworms[pos]; l++) |
| 630 | | if (worms[pos][l] == worms[pos2][k]) { |
| | 641 | if (worms[pos][l] == worms[neigbor_pos][k]) { |
| 631 | 642 | already_counted = 1; |
| 632 | 643 | break; |
| 633 | 644 | } |
| 634 | 645 | if (!already_counted) { |
| 635 | 646 | ASSERT1(nworms[pos] < 2*(board_size-1), pos); |
| 636 | | worms[pos][nworms[pos]++] = worms[pos2][k]; |
| | 647 | worms[pos][nworms[pos]++] = worms[neigbor_pos][k]; |
| 637 | 648 | } |
| 638 | 649 | } |
| 639 | 650 | } |
| … |
… |
|
| 641 | 652 | } |
| 642 | 653 | } |
| 643 | 654 | |
| 644 | | /* Compute the effective sizes but only when all worms are considered. */ |
| | 655 | /* Compute the effective sizes but only when all worms are considered... */ |
| 645 | 656 | if (color == (BLACK | WHITE)) { |
| 646 | 657 | /* Distribute (fractional) contributions to the worms. */ |
| 647 | 658 | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| … |
… |
|
| 659 | 670 | |
| 660 | 671 | /* Propagate the effective size values all over the worms. */ |
| 661 | 672 | for (pos = BOARDMIN; pos < BOARDMAX; pos++) |
| 662 | | if (IS_STONE(board[pos]) && is_worm_origin(pos, pos)) |
| 663 | | propagate_worm(pos); |
| | 673 | if (IS_STONE(board[pos])) |
| | 674 | worm[pos].effective_size = worm[worm[pos].origin].effective_size; |
| 664 | 675 | } |
| | 676 | else |
| | 677 | /* ... or fill in the appropriate close_*_worms (cw) and |
| | 678 | number_close_*_worms (ncw) arrays. */ |
| | 679 | { |
| | 680 | int worms_count; |
| 665 | 681 | |
| 666 | | /* Fill in the appropriate close_*_worms (cw) and |
| 667 | | * number_close_*_worms (ncw) arrays. |
| 668 | | */ |
| 669 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| 670 | | if (!ON_BOARD(pos)) |
| 671 | | continue; |
| | 682 | for (pos = BOARDMIN; pos < BOARDMAX; pos++) { |
| | 683 | if (!ON_BOARD(pos)) |
| | 684 | continue; |
| 672 | 685 | |
| 673 | | if (nworms[pos] > MAX_CLOSE_WORMS) |
| 674 | | ncw[pos] = 0; |
| 675 | | else |
| 676 | | ncw[pos] = nworms[pos]; |
| | 686 | worms_count = nworms[pos]; |
| 677 | 687 | |
| 678 | | for (k = 0; k < ncw[pos]; k++) |
| 679 | | cw[pos][k] = worms[pos][k]; |
| | 688 | if (worms_count > MAX_CLOSE_WORMS) { |
| | 689 | ncw[pos] = 0; |
| | 690 | continue; |
| | 691 | } |
| | 692 | else |
| | 693 | ncw[pos] = worms_count; |
| | 694 | |
| | 695 | memcpy(cw[pos], worms[pos], worms_count * sizeof(int)); |
| | 696 | } |
| 680 | 697 | } |
| 681 | 698 | } |
| 682 | 699 | |