diff -N -r -u -X .ignore gnugo-copy/engine/board.c gnugo/engine/board.c
|
old
|
new
|
|
| 874 | 874 | return 0; |
| 875 | 875 | |
| 876 | 876 | /* 4. The location must not be the ko point, unless ignore_ko == 1. */ |
| 877 | | if (!ignore_ko && pos == board_ko_pos) { |
| | 877 | if (!ignore_ko && pos == board_ko_pos) { |
| 878 | 878 | /* The ko position is guaranteed to have all neighbors of the |
| 879 | 879 | * same color, or off board. If that color is the same as the |
| 880 | 880 | * move the ko is being filled, it is always allowed. This |
| … |
… |
|
| 884 | 884 | if (board[WEST(pos)] == OTHER_COLOR(color) |
| 885 | 885 | || board[EAST(pos)] == OTHER_COLOR(color)) |
| 886 | 886 | return 0; |
| 887 | | } |
| | 887 | } |
| 888 | 888 | |
| 889 | 889 | /* 5. Test for suicide. */ |
| 890 | 890 | if (is_suicide(pos, color)) |
diff -N -r -u -X .ignore gnugo-copy/engine/liberty.h gnugo/engine/liberty.h
|
old
|
new
|
|
| 336 | 336 | /* movelist.c */ |
| 337 | 337 | int movelist_move_known(int move, int max_points, int points[], int codes[]); |
| 338 | 338 | void movelist_change_point(int move, int code, int max_points, |
| 339 | | int points[], int codes[]); |
| | 339 | int points[], int codes[], int discarded_points[]); |
| | 340 | int discarded_move_known(int move, int max_points, int points[]); |
| | 341 | void movelist_change_discarded(int move, int max_points, int points[]); |
| 340 | 342 | |
| 341 | 343 | /* worm.c */ |
| 342 | 344 | void change_tactical_point(int str, int move, int code, |
| 343 | | int points[], int codes[]); |
| | 345 | int points[], int codes[], int discarded_points[]); |
| 344 | 346 | |
| 345 | 347 | /* surround.c */ |
| 346 | 348 | int compute_surroundings(int pos, int apos, int showboard, |
| … |
… |
|
| 837 | 839 | */ |
| 838 | 840 | int attack_points[MAX_TACTICAL_POINTS]; |
| 839 | 841 | int attack_codes[MAX_TACTICAL_POINTS]; |
| | 842 | int discarded_attacks[MAX_TACTICAL_POINTS]; |
| 840 | 843 | int defense_points[MAX_TACTICAL_POINTS]; |
| 841 | 844 | int defense_codes[MAX_TACTICAL_POINTS]; |
| | 845 | int discarded_defenses[MAX_TACTICAL_POINTS]; |
| 842 | 846 | int attack_threat_points[MAX_TACTICAL_POINTS]; |
| 843 | 847 | int attack_threat_codes[MAX_TACTICAL_POINTS]; |
| | 848 | int discarded_att_threats[MAX_TACTICAL_POINTS]; |
| 844 | 849 | int defense_threat_points[MAX_TACTICAL_POINTS]; |
| 845 | 850 | int defense_threat_codes[MAX_TACTICAL_POINTS]; |
| | 851 | int discarded_def_threats[MAX_TACTICAL_POINTS]; |
| 846 | 852 | }; |
| 847 | 853 | |
| 848 | 854 | extern struct worm_data worm[BOARDMAX]; |
diff -N -r -u -X .ignore gnugo-copy/engine/movelist.c gnugo/engine/movelist.c
|
old
|
new
|
|
| 41 | 41 | int k; |
| 42 | 42 | |
| 43 | 43 | for (k = 0; k < max_points; k++) { |
| 44 | | if (codes[k] == 0) |
| | 44 | if (points[k] == 0) |
| 45 | 45 | return 0; |
| 46 | 46 | if (points[k] == move) |
| 47 | 47 | return codes[k]; |
| … |
… |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| | 53 | /* Return true if the move was previously discarded. |
| | 54 | */ |
| | 55 | int |
| | 56 | discarded_move_known(int move, int max_points, int points[]) |
| | 57 | { |
| | 58 | int k; |
| | 59 | |
| | 60 | for (k = 0; k < max_points; k++) { |
| | 61 | if (points[k] == 0) |
| | 62 | return 0; |
| | 63 | if (points[k] == move) |
| | 64 | return 1; |
| | 65 | } |
| | 66 | return 0; |
| | 67 | } |
| | 68 | |
| | 69 | |
| 53 | 70 | /* |
| 54 | 71 | * This function does the real work for change_attack(), |
| 55 | 72 | * change_defense(), change_attack_threat(), and |
| … |
… |
|
| 58 | 75 | |
| 59 | 76 | void |
| 60 | 77 | movelist_change_point(int move, int code, int max_points, |
| 61 | | int points[], int codes[]) |
| | 78 | int points[], int codes[], int discarded_points[]) |
| 62 | 79 | { |
| 63 | 80 | int k; |
| 64 | 81 | |
| 65 | 82 | /* First see if we already know about this point. */ |
| 66 | | for (k = 0; k < max_points; k++) |
| | 83 | for (k = 0; k < max_points; k++) { |
| 67 | 84 | if (points[k] == move) |
| 68 | 85 | break; |
| 69 | 86 | |
| | 87 | if (points[k] == 0) { |
| | 88 | /* We have empty space to store the move. */ |
| | 89 | points[k] = move; |
| | 90 | codes[k] = code; |
| | 91 | move_up_list(points, codes, k); |
| | 92 | return; |
| | 93 | } |
| | 94 | } |
| | 95 | |
| 70 | 96 | /* Yes, we do. */ |
| 71 | 97 | if (k < max_points) { |
| 72 | 98 | if (code >= codes[k]) |
| … |
… |
|
| 78 | 104 | /* This tactical point is new to us. */ |
| 79 | 105 | else { |
| 80 | 106 | k--; /* last index */ |
| 81 | | if (code <= codes[k]) |
| | 107 | if (code <= codes[k]) { |
| | 108 | movelist_change_discarded(move, max_points, discarded_points); |
| 82 | 109 | return; /* Too bad move to store. */ |
| | 110 | } |
| 83 | 111 | |
| 84 | 112 | points[k] = move; |
| 85 | 113 | codes[k] = code; |
| … |
… |
|
| 88 | 116 | } |
| 89 | 117 | |
| 90 | 118 | |
| | 119 | /* |
| | 120 | * This function changes discarded moves list. |
| | 121 | */ |
| | 122 | void |
| | 123 | movelist_change_discarded(int move, int max_points, int points[]) |
| | 124 | { |
| | 125 | int k; |
| | 126 | |
| | 127 | /* We store only max_points discarded moves. */ |
| | 128 | for (k = 0; k < max_points; k++) { |
| | 129 | if (points[k] == move) |
| | 130 | return; |
| | 131 | |
| | 132 | if (points[k] == 0) { |
| | 133 | points[k] = move; |
| | 134 | return; |
| | 135 | } |
| | 136 | } |
| | 137 | } |
| | 138 | |
| | 139 | |
| 91 | 140 | /* Sort the changed tactical point. We set it to the higher value, so |
| 92 | 141 | * we just have to move it up the table. |
| 93 | 142 | */ |
diff -N -r -u -X .ignore gnugo-copy/engine/owl.c gnugo/engine/owl.c
|
old
|
new
|
|
| 927 | 927 | case 5: |
| 928 | 928 | checked_moves = shape_offensive_moves; |
| 929 | 929 | break; |
| | 930 | default: |
| | 931 | checked_moves = NULL; |
| | 932 | gg_assert(0); |
| 930 | 933 | } |
| 931 | 934 | |
| 932 | 935 | for (k = 0; k < MAX_MOVES; k++) { |
diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
|
old
|
new
|
|
| 1035 | 1035 | int k; |
| 1036 | 1036 | int l; |
| 1037 | 1037 | int r; |
| | 1038 | int discard; |
| 1038 | 1039 | |
| 1039 | 1040 | ASSERT1(IS_STONE(board[str]), str); |
| 1040 | 1041 | |
| … |
… |
|
| 1060 | 1061 | if (trymove(aa, other, "attack_threats-A", str)) { |
| 1061 | 1062 | int acode = attack(str, NULL); |
| 1062 | 1063 | if (acode != 0) |
| 1063 | | change_tactical_point(str, aa, acode, moves, codes); |
| | 1064 | change_tactical_point(str, aa, acode, moves, codes, |
| | 1065 | worm[str].discarded_att_threats); |
| 1064 | 1066 | popgo(); |
| 1065 | 1067 | } |
| 1066 | 1068 | |
| … |
… |
|
| 1070 | 1072 | |
| 1071 | 1073 | if (!ON_BOARD(bb) |
| 1072 | 1074 | || IS_STONE(board[bb]) |
| | 1075 | || attack_threat_move_known(bb, str) |
| | 1076 | || discarded_move_known(bb, MAX_TACTICAL_POINTS, |
| | 1077 | worm[str].discarded_att_threats) |
| 1073 | 1078 | || liberty_of_string2(bb, str)) |
| 1074 | 1079 | continue; |
| 1075 | 1080 | |
| | 1081 | discard = 1; |
| | 1082 | |
| 1076 | 1083 | if (trymove(bb, other, "attack_threats-B", str)) { |
| 1077 | 1084 | int acode = attack(str, NULL); |
| 1078 | | if (acode != 0) |
| 1079 | | change_tactical_point(str, bb, acode, moves, codes); |
| | 1085 | if (acode != 0) { |
| | 1086 | change_tactical_point(str, bb, acode, moves, codes, |
| | 1087 | worm[str].discarded_att_threats); |
| | 1088 | discard = 0; |
| | 1089 | } |
| 1080 | 1090 | popgo(); |
| 1081 | 1091 | } |
| | 1092 | |
| | 1093 | if (discard) |
| | 1094 | movelist_change_discarded(bb, MAX_TACTICAL_POINTS, |
| | 1095 | worm[str].discarded_att_threats); |
| 1082 | 1096 | } |
| 1083 | 1097 | } |
| 1084 | 1098 | } |
| … |
… |
|
| 1087 | 1101 | num_adj = chainlinks(str, adjs); |
| 1088 | 1102 | for (k = 0; k < num_adj; k++) { |
| 1089 | 1103 | int bb; |
| 1090 | | int dd; /* Defense point of weak neighbor. */ |
| 1091 | 1104 | int acode; |
| 1092 | 1105 | int dcode; |
| 1093 | 1106 | |
| 1094 | | attack_and_defend(adjs[k], &acode, NULL, &dcode, &dd); |
| | 1107 | attack_and_defend(adjs[k], &acode, NULL, &dcode, NULL); |
| 1095 | 1108 | if (acode == 0 || dcode == 0) |
| 1096 | 1109 | continue; |
| 1097 | 1110 | |
| 1098 | | /* The strange code using r == -1 below is only avoid duplication |
| 1099 | | * of the code starting with "if (trymove..)" below. |
| 1100 | | * If r == -1 and stackp == 0 then use the defense point what we got from |
| 1101 | | * attack_and_defend above. Otherwise step through all defense points. |
| 1102 | | */ |
| 1103 | | for (r = -1; r < max_points; r++) { |
| 1104 | | if (stackp == 0) { |
| 1105 | | if (r == -1) |
| 1106 | | continue; |
| 1107 | | if (worm[adjs[k]].defense_codes[r] == 0) |
| 1108 | | break; |
| 1109 | | bb = worm[adjs[k]].defense_points[r]; |
| 1110 | | } |
| 1111 | | else { |
| 1112 | | if (r == -1) |
| 1113 | | bb = dd; |
| 1114 | | else |
| 1115 | | break; |
| 1116 | | } |
| | 1111 | /* Step through all defense points. */ |
| | 1112 | for (r = 0; r < max_points; r++) { |
| | 1113 | if (worm[adjs[k]].defense_codes[r] == 0) |
| | 1114 | break; |
| | 1115 | bb = worm[adjs[k]].defense_points[r]; |
| 1117 | 1116 | |
| 1118 | 1117 | /* Test the move and see if it is a threat. */ |
| 1119 | 1118 | if (trymove(bb, other, "attack_threats-C", str)) { |
| … |
… |
|
| 1122 | 1121 | else |
| 1123 | 1122 | acode = attack(str, NULL); |
| 1124 | 1123 | if (acode != 0) |
| 1125 | | change_tactical_point(str, bb, acode, moves, codes); |
| | 1124 | change_tactical_point(str, bb, acode, moves, codes, |
| | 1125 | worm[str].discarded_att_threats); |
| 1126 | 1126 | popgo(); |
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | /* Return actual number of threats found regardless of attack code. */ |
| 1132 | | if (codes[max_points - 1] > 0) |
| 1133 | | return max_points; |
| 1134 | 1132 | for (num_threats = 0; num_threats < max_points; num_threats++) |
| 1135 | 1133 | if (codes[num_threats] == 0) |
| 1136 | 1134 | break; |
diff -N -r -u -X .ignore gnugo-copy/engine/unconditional.c gnugo/engine/unconditional.c
|
old
|
new
|
|
| 676 | 676 | void |
| 677 | 677 | clear_unconditionally_meaningless_moves() |
| 678 | 678 | { |
| 679 | | int pos; |
| 680 | | |
| 681 | | for (pos = BOARDMIN; pos < BOARDMAX; pos++) |
| 682 | | if (ON_BOARD(pos)) { |
| 683 | | meaningless_black_moves[pos] = -1; |
| 684 | | meaningless_white_moves[pos] = -1; |
| 685 | | } |
| | 679 | memset(meaningless_black_moves, -1, sizeof(meaningless_black_moves)); |
| | 680 | memset(meaningless_white_moves, -1, sizeof(meaningless_black_moves)); |
| 686 | 681 | } |
| 687 | 682 | |
| 688 | 683 | /* Pick up antisuji and replacement move reasons found by analysis |
diff -N -r -u -X .ignore gnugo-copy/engine/worm.c gnugo/engine/worm.c
|
old
|
new
|
|
| 884 | 884 | int k; |
| 885 | 885 | int l; |
| 886 | 886 | int color; |
| | 887 | int discard; |
| 887 | 888 | |
| 888 | 889 | for (str = BOARDMIN; str < BOARDMAX; str++) { |
| 889 | 890 | color = board[str]; |
| … |
… |
|
| 951 | 952 | |
| 952 | 953 | if (!ON_BOARD(bb) |
| 953 | 954 | || IS_STONE(board[bb]) |
| | 955 | || defense_threat_move_known(bb, str) |
| | 956 | || discarded_move_known(bb, MAX_TACTICAL_POINTS, |
| | 957 | worm[str].discarded_def_threats) |
| 954 | 958 | || liberty_of_string2(bb, str)) |
| 955 | 959 | continue; |
| | 960 | |
| | 961 | discard = 1; |
| 956 | 962 | |
| 957 | 963 | if (trymove(bb, color, "threaten defense", str)) { |
| 958 | 964 | if (attack(str, NULL) == WIN) { |
| 959 | 965 | int dcode = find_defense(str, NULL); |
| 960 | | if (dcode != 0) |
| | 966 | if (dcode != 0) { |
| 961 | 967 | change_defense_threat(str, bb, dcode); |
| | 968 | discard = 0; |
| | 969 | } |
| 962 | 970 | } |
| 963 | 971 | popgo(); |
| 964 | 972 | } |
| | 973 | |
| | 974 | if (discard) |
| | 975 | movelist_change_discarded(bb, MAX_TACTICAL_POINTS, |
| | 976 | worm[str].discarded_def_threats); |
| 965 | 977 | } |
| 966 | 978 | } |
| 967 | 979 | |
| … |
… |
|
| 1063 | 1075 | void |
| 1064 | 1076 | change_defense(int str, int move, int dcode) |
| 1065 | 1077 | { |
| 1066 | | str = worm[str].origin; |
| 1067 | 1078 | change_tactical_point(str, move, dcode, |
| 1068 | | worm[str].defense_points, worm[str].defense_codes); |
| | 1079 | worm[str].defense_points, worm[str].defense_codes, |
| | 1080 | worm[str].discarded_defenses); |
| 1069 | 1081 | } |
| 1070 | 1082 | |
| 1071 | 1083 | |
| … |
… |
|
| 1080 | 1092 | void |
| 1081 | 1093 | change_attack(int str, int move, int acode) |
| 1082 | 1094 | { |
| 1083 | | str = worm[str].origin; |
| 1084 | 1095 | DEBUG(DEBUG_WORMS, "change_attack: %1m %1m %d\n", str, move, acode); |
| 1085 | 1096 | change_tactical_point(str, move, acode, |
| 1086 | | worm[str].attack_points, worm[str].attack_codes); |
| | 1097 | worm[str].attack_points, worm[str].attack_codes, |
| | 1098 | worm[str].discarded_attacks); |
| 1087 | 1099 | } |
| 1088 | 1100 | |
| 1089 | 1101 | |
| … |
… |
|
| 1099 | 1111 | void |
| 1100 | 1112 | change_defense_threat(int str, int move, int dcode) |
| 1101 | 1113 | { |
| 1102 | | str = worm[str].origin; |
| 1103 | 1114 | change_tactical_point(str, move, dcode, |
| 1104 | 1115 | worm[str].defense_threat_points, |
| 1105 | | worm[str].defense_threat_codes); |
| | 1116 | worm[str].defense_threat_codes, |
| | 1117 | worm[str].discarded_def_threats); |
| 1106 | 1118 | } |
| 1107 | 1119 | |
| 1108 | 1120 | |
| … |
… |
|
| 1118 | 1130 | void |
| 1119 | 1131 | change_attack_threat(int str, int move, int acode) |
| 1120 | 1132 | { |
| 1121 | | str = worm[str].origin; |
| 1122 | 1133 | change_tactical_point(str, move, acode, |
| 1123 | 1134 | worm[str].attack_threat_points, |
| 1124 | | worm[str].attack_threat_codes); |
| | 1135 | worm[str].attack_threat_codes, |
| | 1136 | worm[str].discarded_att_threats); |
| 1125 | 1137 | } |
| 1126 | 1138 | |
| 1127 | 1139 | |
| … |
… |
|
| 1181 | 1193 | void |
| 1182 | 1194 | change_tactical_point(int str, int move, int code, |
| 1183 | 1195 | int points[MAX_TACTICAL_POINTS], |
| 1184 | | int codes[MAX_TACTICAL_POINTS]) |
| | 1196 | int codes[MAX_TACTICAL_POINTS], |
| | 1197 | int discarded_points[MAX_TACTICAL_POINTS]) |
| 1185 | 1198 | { |
| 1186 | 1199 | ASSERT_ON_BOARD1(str); |
| 1187 | | ASSERT1(str == worm[str].origin, str); |
| 1188 | 1200 | |
| 1189 | | movelist_change_point(move, code, MAX_TACTICAL_POINTS, points, codes); |
| | 1201 | movelist_change_point(move, code, MAX_TACTICAL_POINTS, points, codes, |
| | 1202 | discarded_points); |
| 1190 | 1203 | propagate_worm2(str); |
| 1191 | 1204 | } |
| 1192 | 1205 | |
| … |
… |
|
| 1602 | 1615 | if (countlib(str) > 4) |
| 1603 | 1616 | continue; |
| 1604 | 1617 | |
| 1605 | | if (attack_move_known(move, str)) |
| | 1618 | if (attack_move_known(move, str) |
| | 1619 | || discarded_move_known(move, MAX_TACTICAL_POINTS, |
| | 1620 | worm[str].discarded_attacks)) |
| 1606 | 1621 | continue; |
| 1607 | 1622 | |
| 1608 | 1623 | /* No defenses are known at this time, so defend_code is always 0. */ |
| … |
… |
|
| 1612 | 1627 | continue; |
| 1613 | 1628 | #endif |
| 1614 | 1629 | |
| 1615 | | /* FIXME: Don't attack the same string more than once. |
| 1616 | | * Play (move) and see if there is a defense. |
| 1617 | | */ |
| | 1630 | /* Play (move) and see if there is a defense. */ |
| 1618 | 1631 | if (trymove(move, color, "attack_callback", str)) { |
| 1619 | 1632 | int dcode; |
| 1620 | 1633 | if (!board[str]) |
| … |
… |
|
| 1637 | 1650 | "Attack pattern %s+%d found attack on %1m at %1m with code %d\n", |
| 1638 | 1651 | pattern->name, ll, str, move, REVERSE_RESULT(dcode)); |
| 1639 | 1652 | } |
| | 1653 | else |
| | 1654 | movelist_change_discarded(move, MAX_TACTICAL_POINTS, |
| | 1655 | worm[str].discarded_attacks); |
| 1640 | 1656 | } |
| | 1657 | else |
| | 1658 | movelist_change_discarded(move, MAX_TACTICAL_POINTS, |
| | 1659 | worm[str].discarded_attacks); |
| 1641 | 1660 | } |
| 1642 | 1661 | } |
| 1643 | 1662 | } |
| … |
… |
|
| 1688 | 1707 | int str = worm[pos].origin; |
| 1689 | 1708 | |
| 1690 | 1709 | if (worm[str].attack_codes[0] == 0 |
| 1691 | | || defense_move_known(move, str)) |
| | 1710 | || defense_move_known(move, str) |
| | 1711 | || discarded_move_known(move, MAX_TACTICAL_POINTS, |
| | 1712 | worm[str].discarded_defenses)) |
| 1692 | 1713 | continue; |
| 1693 | 1714 | |
| 1694 | | /* FIXME: Don't try to defend the same string more than once. |
| 1695 | | * FIXME: For all attacks on this string, we should test whether |
| | 1715 | /* FIXME: For all attacks on this string, we should test whether |
| 1696 | 1716 | * the proposed move happens to refute the attack. |
| 1697 | 1717 | * Play (move) and see if there is an attack. |
| 1698 | 1718 | */ |
| … |
… |
|
| 1707 | 1727 | "Defense pattern %s+%d found defense of %1m at %1m with code %d\n", |
| 1708 | 1728 | pattern->name, ll, str, move, REVERSE_RESULT(acode)); |
| 1709 | 1729 | } |
| | 1730 | else |
| | 1731 | movelist_change_discarded(move, MAX_TACTICAL_POINTS, |
| | 1732 | worm[str].discarded_defenses); |
| 1710 | 1733 | } |
| | 1734 | else |
| | 1735 | movelist_change_discarded(move, MAX_TACTICAL_POINTS, |
| | 1736 | worm[str].discarded_defenses); |
| 1711 | 1737 | } |
| 1712 | 1738 | } |
| 1713 | 1739 | } |
diff -N -r -u -X .ignore gnugo-copy/interface/gnugo.vcproj gnugo/interface/gnugo.vcproj
|
old
|
new
|
|
| 400 | 400 | RelativePath=".\interface.h" |
| 401 | 401 | > |
| 402 | 402 | </File> |
| | 403 | <File |
| | 404 | RelativePath="..\engine\liberty.h" |
| | 405 | > |
| | 406 | </File> |
| 403 | 407 | </Filter> |
| 404 | 408 | <Filter |
| 405 | 409 | Name="Resource Files" |