Ticket #163: semeai.diff
| File semeai.diff, 6.9 kB (added by draqo, 19 months ago) |
|---|
-
engine/owl.c
diff -N -r -u -X .ignore gnugo-copy/engine/owl.c gnugo/engine/owl.c
old new 670 670 struct eyevalue probable_eyes_a; 671 671 struct eyevalue probable_eyes_b; 672 672 struct eyevalue dummy_eyes; 673 int I_have_more_eyes; 673 674 674 675 SETUP_TRACE_INFO2("do_owl_analyze_semeai", apos, bpos); 675 676 … … 804 805 if (!owl_phase) { 805 806 set_eyevalue(&probable_eyes_a, 0, 0, 0, 0); 806 807 set_eyevalue(&probable_eyes_b, 0, 0, 0, 0); 808 I_have_more_eyes = 0; 807 809 } 808 810 else { 809 811 /* First the vital moves. These include moves to attack or … … 893 895 shape_defensive_moves, 1, owla)) 894 896 break; 895 897 } 898 else 899 shape_defensive_moves[0].pos = 0; 900 896 901 owl_shapes(&shape_offensive_patterns, shape_offensive_moves, color, owlb, 897 902 &owl_attackpat_db); 898 903 for (k = 0; k < MAX_MOVES-1; k++) 899 904 if (!get_next_move_from_list(&shape_offensive_patterns, color, 900 905 shape_offensive_moves, 1, owla)) 901 906 break; 902 907 908 /* Filter out moves, which fills our eye (and not split it). */ 909 if (eyemax_a == 1) { 910 int n; 911 struct owl_move_data *checked_moves; 912 913 for (n = 1; n <= 5; n++) { 914 switch (n) { 915 case 1: 916 checked_moves = moves; 917 break; 918 case 2: 919 checked_moves = vital_defensive_moves; 920 break; 921 case 3: 922 checked_moves = vital_offensive_moves; 923 break; 924 case 4: 925 checked_moves = shape_defensive_moves; 926 break; 927 case 5: 928 checked_moves = shape_offensive_moves; 929 break; 930 } 931 932 for (k = 0; k < MAX_MOVES; k++) { 933 if (checked_moves[k].pos <= 0) 934 break; 935 else { 936 struct eye_data *eye = &owla->my_eye[checked_moves[k].pos]; 937 938 /* If esize==1 this eye must not be a real eye (at least one 939 * worm is capturable, otherwise this move would not be 940 * proposed). 941 */ 942 if (eye->color == color && eye->msize == 0 && eye->neighbors <= 1 943 && eye->esize != 1 944 && owla->half_eye[checked_moves[k].pos].type != HALF_EYE 945 && !has_neighbor(checked_moves[k].pos, OTHER_COLOR(color))) 946 checked_moves[k].value = 0; 947 } 948 } 949 } 950 } 951 903 952 /* Now we review the moves already considered, while collecting 904 953 * them into a single list. 905 954 */ … … 954 1003 include_semeai_worms_in_eyespace = 0; 955 1004 } 956 1005 1006 if (eyemin_a == eyemax_a) 1007 /* We have stable number of eyes, so we can try to reduce 1008 * opponent eyes. */ 1009 I_have_more_eyes = (eyemin_a > min_eyes(&probable_eyes_b)); 1010 else { 1011 if (min_eyes(&probable_eyes_a) == max_eyes(&probable_eyes_a)) 1012 /* If we can't increase our number of eyes, we try to reduce 1013 * opponent eyes. */ 1014 I_have_more_eyes = (max_eyes(&probable_eyes_a) > min_eyes(&probable_eyes_b)); 1015 else 1016 /* If we can increase our number of eyes, we do it and let 1017 * opponent to increase his. */ 1018 I_have_more_eyes = (max_eyes(&probable_eyes_a) > max_eyes(&probable_eyes_b)); 1019 } 1020 957 1021 if (get_level() < 8) { 958 1022 /* If no owl moves were found on two consecutive moves, 959 1023 * turn off the owl phase. … … 977 1041 978 1042 /* Now we look for a move to fill a liberty. This is only 979 1043 * interesting if the opponent doesn't already have two eyes. 1044 * If we have more eyes, always check for a backfilling move. 980 1045 */ 981 1046 if (!you_look_alive 982 && !safe_outside_liberty_found && moves[0].value < 110) { 1047 && !safe_outside_liberty_found 1048 && (moves[0].value < 110 || I_have_more_eyes)) { 983 1049 int pos; 984 1050 for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 985 1051 if (!ON_BOARD(pos)) 986 continue;1052 continue; 987 1053 988 1054 if (board[pos] == EMPTY && !mw[pos]) { 989 1055 if (liberty_of_goal(pos, owlb)) { … … 995 1061 break; 996 1062 } 997 1063 else if (backfill_outside_liberty.pos == NO_MOVE) 998 backfill_outside_liberty.pos = find_semeai_backfilling_move(bpos,999 pos);1064 backfill_outside_liberty.pos = 1065 find_semeai_backfilling_move(bpos, pos); 1000 1066 } 1001 1067 else { 1002 1068 /* common liberty */ … … 1005 1071 common_liberty.pos = pos; 1006 1072 } 1007 1073 else if (backfill_common_liberty.pos == NO_MOVE) 1008 backfill_common_liberty.pos = find_semeai_backfilling_move(bpos,1009 pos);1074 backfill_common_liberty.pos = 1075 find_semeai_backfilling_move(bpos, pos); 1010 1076 } 1011 1077 } 1012 1078 } … … 1093 1159 if (mpos == NO_MOVE) 1094 1160 break; 1095 1161 1162 if (moves[k].value == 0) 1163 continue; 1164 1096 1165 /* Do not try too many moves. */ 1097 1166 if (tested_moves > 2 1098 1167 || (stackp > semeai_branch_depth2 && tested_moves > 1) … … 1281 1350 gg_assert(this_resulta != NULL && this_resultb != NULL); 1282 1351 *this_resulta = 0; 1283 1352 *this_resultb = 0; 1284 if (!komaster_trymove(move, color, move_name, apos, &ko_move, ko_allowed)) 1353 1354 if (!komaster_trymove(move, color, move_name, apos, &ko_move, ko_allowed)) { 1355 /* Move was not allowed because of komaster. We want to check, if this 1356 * situation is double ko and when it is, we won semeai. 1357 */ 1358 int libs[MAX_LIBERTIES]; 1359 int n; 1360 int nlib; 1361 int sworm; 1362 int worm_color; 1363 1364 for (sworm = 0; sworm < s_worms; sworm++) { 1365 worm_color = board[semeai_worms[sworm]]; 1366 if (worm_color == color && *this_resulta == 0) { 1367 /* We only check up to MAX_LIBERTIES, due to performance reasons. When we 1368 * have more liberties we have some outside liberties to fill and these 1369 * moves will be tried later (and double ko situation will be found). 1370 */ 1371 nlib = findlib(semeai_worms[sworm], MAX_LIBERTIES, libs); 1372 if (nlib > MAX_LIBERTIES) 1373 return 0; 1374 1375 for (n = 0; n < nlib; n++) 1376 if (is_ko(libs[n], OTHER_COLOR(color), NULL)) { 1377 /* Our dragon has double ko, but we have to check if opponent dragon 1378 * doesn't have outside liberties or double ko. 1379 */ 1380 *this_resulta = WIN; 1381 *this_resultb = WIN; 1382 } 1383 } 1384 else if (worm_color == OTHER_COLOR(color)) { 1385 nlib = findlib(semeai_worms[sworm], 2, libs); 1386 if (nlib > 2) 1387 /* In double ko situation the opponent can have only 1388 * a single eye and a ko outside liberty to be sure that we 1389 * will always win double ko. */ 1390 return 0; 1391 } 1392 } 1393 1394 if (*this_resulta == WIN) 1395 return 1; 1396 1285 1397 return 0; 1398 } 1286 1399 1287 1400 semeai_add_sgf_comment(move_value, owl_phase); 1288 1401 TRACE("Trying %C %1m. Current stack: ", color, move); … … 1451 1564 if (move == NO_MOVE) 1452 1565 break; 1453 1566 1567 if (owl_moves[k].value == 0) 1568 continue; 1569 1454 1570 /* Does the move fill a liberty in the semeai? */ 1455 1571 if (liberty_of_goal(move, owlb) 1456 1572 && safe_move(move, color)) { -
patterns/conn.db
diff -N -r -u -X .ignore gnugo-copy/patterns/conn.db gnugo/patterns/conn.db
old new 611 611 Bc 612 612 dA 613 613 614 ; (attack(A) || attack(B)) && !oplay_disconnect(c,d)614 ;lib(c)<=1 || lib(d)<=1 || xplay_defend_both(A,B) ? 0 : (amalgamate(c,d), 0) 615 615 616 616 617 617 Pattern CC506
