| | 811 | /* This helper is intended to detect semeai kind of positions where |
| | 812 | * the tactical reading can't be trusted enough to allow amalgamation |
| | 813 | * over presumably tactically dead strings. |
| | 814 | * |
| | 815 | * It has turned out to be best not to trust tactical reading of three |
| | 816 | * and four liberty strings at all. Not trusting two liberty strings |
| | 817 | * leads to an underamalgamation and unnecessarily many dragons on the |
| | 818 | * board. Therefore we try to detect two liberty strings with an |
| | 819 | * enclosed nakade, which after capturing leads to an unreliable |
| | 820 | * reading at three or four liberties. |
| | 821 | * |
| | 822 | * More specifically we check whether the string has a neighbor with |
| | 823 | * the following properties: |
| | 824 | * 1. At least three stones in size. |
| | 825 | * 2. All its liberties are common liberties with the string. |
| | 826 | * 3. It has no second order liberties. |
| | 827 | * 4. Its liberties are adjacent to no other strings than itself and |
| | 828 | * the primary string. |
| | 829 | * |
| | 830 | * If we find such a neighbor 1 is returned, otherwise 0. |
| | 831 | */ |
| | 832 | int distrust_tactics_helper(int str) |
| | 833 | { |
| | 834 | int color = board[str]; |
| | 835 | int adj; |
| | 836 | int adjs[MAXCHAIN]; |
| | 837 | int k; |
| | 838 | int r; |
| | 839 | int s; |
| | 840 | int lib = countlib(str); |
| | 841 | |
| | 842 | ASSERT1(IS_STONE(board[str]), str); |
| | 843 | |
| | 844 | if (lib > 2) |
| | 845 | return 1; |
| | 846 | else if (lib == 1) |
| | 847 | return 0; |
| | 848 | |
| | 849 | adj = chainlinks3(str, adjs, lib); |
| | 850 | for (r = 0; r < adj; r++) { |
| | 851 | int nakade = 1; |
| | 852 | int adjlib; |
| | 853 | int adjlibs[3]; |
| | 854 | if (countstones(adjs[r]) < 3) |
| | 855 | continue; |
| | 856 | adjlib = findlib(adjs[r], 3, adjlibs); |
| | 857 | for (s = 0; s < adjlib; s++) { |
| | 858 | int str_found = 0; |
| | 859 | for (k = 0; k < 4; k++) { |
| | 860 | int pos = adjlibs[s] + delta[k]; |
| | 861 | if (board[pos] == EMPTY |
| | 862 | && !liberty_of_string(pos, adjs[r])) |
| | 863 | nakade = 0; |
| | 864 | else if (board[pos] == color) { |
| | 865 | if (same_string(pos, str)) |
| | 866 | str_found = 1; |
| | 867 | else |
| | 868 | nakade = 0; |
| | 869 | } |
| | 870 | else if (board[pos] == OTHER_COLOR(color) |
| | 871 | && !same_string(pos, adjs[r])) |
| | 872 | nakade = 0; |
| | 873 | } |
| | 874 | if (!str_found) |
| | 875 | nakade = 0; |
| | 876 | } |
| | 877 | if (nakade) |
| | 878 | return 1; |
| | 879 | } |
| | 880 | |
| | 881 | return 0; |
| | 882 | } |
| | 883 | |