Index: engine/cache.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v retrieving revision 1.23 diff -u -r1.23 cache.h --- engine/cache.h 2 Jan 2003 00:23:28 -0000 1.23 +++ engine/cache.h 12 Jan 2003 11:26:05 -0000 @@ -248,8 +248,6 @@ sgf_trace2(read_function_name, q1, q2, move, result, message) -extern Hashtable *movehash; - int get_read_result(int routine, int komaster, int kom_pos, int *str, Read_result **read_result); int get_read_result2(int routine, int komaster, int kom_pos, Index: engine/reading.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v retrieving revision 1.96 diff -u -r1.96 reading.c --- engine/reading.c 2 Jan 2003 00:23:28 -0000 1.96 +++ engine/reading.c 12 Jan 2003 11:26:15 -0000 @@ -506,14 +506,14 @@ attack_and_defend(astr, &acode, NULL, &dcode, &a_savepos); if (acode != 0) { a_threatened = 1; - if (dcode == 0) + if (dcode != WIN) return 0; /* (astr) already lost */ } attack_and_defend(bstr, &acode, NULL, &dcode, &b_savepos); if (acode != 0) { b_threatened = 1; - if (dcode == 0) + if (dcode != WIN) return 0; /* (bstr) already lost */ } Index: engine/value_moves.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v retrieving revision 1.77 diff -u -r1.77 value_moves.c --- engine/value_moves.c 11 Jan 2003 00:01:51 -0000 1.77 +++ engine/value_moves.c 12 Jan 2003 11:26:22 -0000 @@ -1281,8 +1281,10 @@ /* True if pos is adjacent to a nondead stone of the given color. This - * function can be called when stackp>0 but the result is given for the - * position when stackp==0. + * function can be called when stackp>0 but the result is given for + * the position when stackp==0. It also checks for nondead stones two + * steps away from pos if a move by color at pos cannot be cut off + * from that stone. * * FIXME: Move this somewhere more generally accessible, probably * utils.c @@ -1291,13 +1293,41 @@ adjacent_to_nondead_stone(int pos, int color) { int k; - for (k = 0; k < 4; k++) - if (ON_BOARD(pos + delta[k]) - && worm[pos + delta[k]].color == color - && dragon[pos + delta[k]].status != DEAD) - return 1; + + int stack[MAXSTACK]; + int move_color[MAXSTACK]; + int saved_stackp = stackp; + int result = 0; + + while (stackp > 0) { + get_move_from_stack(stackp - 1, &stack[stackp - 1], + &move_color[stackp - 1]); + popgo(); + } + + if (trymove(pos, color, NULL, EMPTY, NO_MOVE, EMPTY)) { + for (k = 0; k < 12; k++) { + int pos2; + if (k < 8) + pos2 = pos + delta[k]; + else + pos2 = pos + 2 * delta[k - 8]; + + if (ON_BOARD(pos2) + && worm[pos2].color == color + && dragon[pos2].status != DEAD + && !disconnect(pos, pos2, NULL)) { + result = 1; + break; + } + } + popgo(); + } + + while (stackp < saved_stackp) + tryko(stack[stackp], move_color[stackp], NULL, NO_MOVE, EMPTY); - return 0; + return result; } @@ -1336,7 +1366,7 @@ case ATTACK_MOVE_BAD_KO: aa = move_reasons[r].what; - gg_assert(board[aa] != color); + ASSERT1(board[aa] != color, aa); /* Defenseless stone. */ if (worm[aa].defense_codes[0] == 0) { @@ -1389,7 +1419,7 @@ case DEFEND_MOVE_BAD_KO: aa = move_reasons[r].what; - gg_assert(board[aa] == color); + ASSERT1(board[aa] == color, aa); /* * Estimate value @@ -1517,16 +1547,39 @@ || adjacent_to_nondead_stone(pos, color)) && find_defense(aa, &defense_move) == WIN && defense_move != NO_MOVE) { + int bad_followup; if (trymove(defense_move, other, "estimate_territorial_value-b", NO_MOVE, EMPTY, NO_MOVE)) { - if (board[pos] == EMPTY || attack(pos, NULL) == WIN) { + if (board[pos] == EMPTY || attack(pos, NULL) != 0) { popgo(); popgo(); break; } popgo(); } + + bad_followup = 0; + for (s = 0; s < num_adj; s++) { + int lib; + if (countlib(adjs[s]) == 1) { + findlib(adjs[s], 1, &lib); + if (trymove(lib, other, "estimate_territorial_value-c", NO_MOVE, + EMPTY, NO_MOVE)) { + if (!attack(aa, NULL) + && (board[pos] == EMPTY || attack(pos, NULL) != 0)) { + popgo(); + bad_followup = 1; + break; + } + popgo(); + } + } + } + if (bad_followup) { + popgo(); + break; + } } for (s = 0; s < num_adj; s++) { @@ -1563,8 +1616,7 @@ adjusted_value -= adjustment_down; if (adjusted_value > 0.0) { add_followup_value(pos, adjusted_value); - /* Inside trymove, so don't re-indented.*/ - TRACE("%1m: %f (followup) - threatens to capture %1m\n", + TRACE(" %1m: %f (followup) - threatens to capture %1m\n", pos, adjusted_value, aa); } } @@ -1593,7 +1645,7 @@ if (trymove(attack_move, other, "estimate_territorial_value-b", NO_MOVE, EMPTY, NO_MOVE)) { - if (board[pos] == EMPTY || attack(pos, NULL) == WIN) { + if (board[pos] == EMPTY || attack(pos, NULL) != 0) { popgo(); popgo(); break; @@ -1604,9 +1656,15 @@ popgo(); } + /* We don't trust tactical defense threats as ko threats, unless + * the move is safe. + */ + if (move[pos].move_safety == 0) + break; + add_followup_value(pos, 2 * worm[aa].effective_size); - TRACE(" %1m: %f (followup) - threatens to defend %1m\n", + TRACE(" %1m: %f (followup) - threatens to defend %1m\n", pos, 2 * worm[aa].effective_size, aa); break; @@ -1886,7 +1944,7 @@ move[pos].influence_followup_value); } popgo(); - + if (this_value != 0.0) TRACE(" %1m: %f - change in territory\n", pos, this_value); else @@ -2365,7 +2423,9 @@ * in a semeai, we have likewise already counted the points as * territorial value. */ - if (owl_attack_move_reason_known(pos, aa) + if (attack_move_reason_known(pos, aa) + || defense_move_reason_known(pos, aa) + || owl_attack_move_reason_known(pos, aa) || owl_defense_move_reason_known(pos, aa) || move_reason_known(pos, SEMEAI_MOVE, aa)) { /* But if the strategical value was larger than the territorial @@ -2563,6 +2623,19 @@ shape_factor2); } tot_value += base_value * shape_factor2; + } + + /* Dame points which have a cut or connect move reason get a small + * extra bonus because these have a tendency to actually be worth + * a point. + */ + if (tot_value < 0.3 + && (move_reason_known(pos, CONNECT_MOVE, -1) + || move_reason_known(pos, CUT_MOVE, -1))) { + float old_tot_value = tot_value; + tot_value = gg_min(0.3, tot_value + 0.1); + TRACE(" %1m: %f - cut/connect dame bonus\n", pos, + tot_value - old_tot_value); } } else { Index: patterns/barriers.db =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/barriers.db,v retrieving revision 1.45 diff -u -r1.45 barriers.db --- patterns/barriers.db 2 Jan 2003 00:23:29 -0000 1.45 +++ patterns/barriers.db 12 Jan 2003 11:26:30 -0000 @@ -2870,4 +2870,59 @@ >non_xterritory(c); +Pattern Nonterritory42 +# gf New pattern. (3.3.15) + +OX +.O + +:8,t + +bX +ac + +;!xplay_defend_both(a,b,c) && !adjacent_to_defendable_stone_in_atari(b) +;&& !adjacent_to_defendable_stone_in_atari(c) + +>non_oterritory(a); + + +Pattern Nonterritory43 +# gf New pattern. (3.3.15) + +oOXx +O..X +oO.X + +:8,t + +oODx +OabX +oOcX + +;!oplay_attack(b,D) && !oplay_attack(b,c,c) + +>non_oterritory(a); + + +Pattern Nonterritory44 +# gf New pattern. (3.3.15) + +OXXx? +.OOXx +..... +----- + +:8,t + +OXXx? +eccXx +..abd +----- + +;oplay_attack(a,b,c) && !oplay_attack(b,d,d) + +>non_oterritory(e); + + # END OF FILE Index: patterns/endgame.db =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/endgame.db,v retrieving revision 1.42 diff -u -r1.42 endgame.db --- patterns/endgame.db 2 Jan 2003 19:41:19 -0000 1.42 +++ patterns/endgame.db 12 Jan 2003 11:26:30 -0000 @@ -858,12 +858,13 @@ Pattern EE804 +# gf Revised value. (3.3.15) O*X endgame move -..X at least 0 points sente or one point gote +..X not guaranteed to be more than 0 points gote --- -:8,OXe,terri(0.5) +:8,OXe,terri(0.1) O*X a.X @@ -1131,6 +1132,7 @@ Pattern CE9 +# gf Revised constraint. (3.3.15) .X push in *O 1 points gote @@ -1140,7 +1142,8 @@ aX *O -;marginal_eye(*) && !safe_omove(a) && !obvious_false_xeye(a) +;marginal_eye(*) && max_eye_value(*)>0 +;&& !safe_omove(a) && !obvious_false_xeye(a) Pattern CE12 @@ -1226,6 +1229,7 @@ Pattern CE16b +# gf Revised constraint. (3.3.15) .O? sente endgame move .*X one point reverse sente @@ -1237,7 +1241,7 @@ a*X O?? -;marginal_eye(*) && proper_eye(a) && xlib(*)>2 +;marginal_eye(*) && proper_eye(a) && max_eye_value(a)>0 && xlib(*)>2 Pattern CE17 @@ -1258,6 +1262,7 @@ Pattern CE18 # tm removed reverse_followup value # see trevorb:700 +# gf Revised constraint. (3.3.15) OX endgame move .* one point gote. @@ -1269,10 +1274,11 @@ a* oO -;marginal_eye(*) && proper_eye(a) +;marginal_eye(*) && proper_eye(a) && max_eye_value(a)>0 Pattern CE19 +# gf Revised constraint. (3.3.15) ?.? endgame move X*X one point gote @@ -1284,11 +1290,12 @@ X*X OaO -;marginal_eye(*) && proper_eye(b) && oplay_attack(*,a,a) +;marginal_eye(*) && proper_eye(b) && max_eye_value(b)>0 && oplay_attack(*,a,a) Pattern CE20a # gf Split and revised pattern. (3.3.10) +# gf Revised constraint. (3.3.15) ?.? Smallish endgame O*O one point, possibly reverse sente @@ -1300,7 +1307,7 @@ O*O ?X? -;marginal_eye(*) && proper_eye(a) +;marginal_eye(*) && proper_eye(a) && max_eye_value(a)>0 Pattern CE20b @@ -1474,21 +1481,22 @@ ;oplay_attack_either(*,a,a,B) -Pattern CE30 -# tm New Pattern (3.1.20) (see trevorc:650, trevorc:470) - -??? threaten to capture -?*X -??. - -:8,nOXe,terri(1),followup(3) - -?c? -d*A -??b - -; o_alive_somewhere(c,d) && (!weak(c) || !weak(d)) -; && proper_eye(b) && oplay_attack(*,A) +# Pattern CE30 +# # tm New Pattern (3.1.20) (see trevorc:650, trevorc:470) +# # gf Too general, removed. (3.3.15) +# +# ??? threaten to capture +# ?*X +# ??. +# +# :8,nOXe,terri(1),followup(3) +# +# ?c? +# d*A +# ??b +# +# ; o_alive_somewhere(c,d) && (!weak(c) || !weak(d)) +# ; && proper_eye(b) && oplay_attack(*,A) Pattern CE31 Index: patterns/fuseki.db =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/fuseki.db,v retrieving revision 1.25 diff -u -r1.25 fuseki.db --- patterns/fuseki.db 2 Jan 2003 00:23:29 -0000 1.25 +++ patterns/fuseki.db 12 Jan 2003 11:26:32 -0000 @@ -1129,22 +1129,23 @@ Pattern F410d +# gf Revised pattern. (3.3.15) -......xxx extend while limiting opponent -O.....xxx -...*..xxx -......... -......... ---------- +o......xxx extend while limiting opponent +oO.....xxx +o...*..xxx +.......... +.......... +---------- :8,Fedt -......xxx -O.....abx -...*..cdx -......... -......... ---------- +o......xxx +oO.....abx +o...*..cdx +.......... +.......... +---------- ; x_alive_somewhere(a,b,c,d) Index: patterns/helpers.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/helpers.c,v retrieving revision 1.45 diff -u -r1.45 helpers.c --- patterns/helpers.c 1 Jan 2003 12:41:26 -0000 1.45 +++ patterns/helpers.c 12 Jan 2003 11:26:34 -0000 @@ -224,7 +224,8 @@ } /* The followup is to capture the "a" string. Estimate the value to - twice the size. */ + * twice the size. + */ add_followup_value(move, 2 * worm[apos].effective_size); TRACE("...followup value %f\n", 2 * worm[apos].effective_size); @@ -440,6 +441,25 @@ } popgo(); } + + /* In addition to the move found by find_defense(), also try all + * chain breaking moves in the same way. + */ + adj = chainlinks2(str, adjs, 1); + for (k = 0; k < adj; k++) { + int lib; + findlib(adjs[k], 1, &lib); + if (TRYMOVE(lib, board[str])) { + if (!attack(str, NULL) + && (board[move] == EMPTY || attack(move, NULL) != 0)) { + popgo(); + popgo(); + return; + } + popgo(); + } + } + popgo(); add_followup_value(move, 2.0 * worm[str].effective_size); @@ -768,6 +788,23 @@ } } +/* True if str is adjacent to a stone in atari, which is tactically + * defendable. + */ +int +adjacent_to_defendable_stone_in_atari(int str) +{ + int adj; + int adjs[MAXCHAIN]; + int k; + + adj = chainlinks2(str, adjs, 1); + for (k = 0; k < adj; k++) + if (attack_and_defend(adjs[k], NULL, NULL, NULL, NULL)) + return 1; + + return 0; +} /* * LOCAL Variables: Index: patterns/mkpat.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v retrieving revision 1.109 diff -u -r1.109 mkpat.c --- patterns/mkpat.c 4 Jan 2003 15:13:03 -0000 1.109 +++ patterns/mkpat.c 12 Jan 2003 11:26:39 -0000 @@ -354,7 +354,9 @@ {"does_surround", 2, 0, 1.00, "does_surround(%s, %s)"}, {"surround_map", 2, 0, 0.01, "surround_map(%s, %s)"}, {"oracle_threatens", 2, 0, 0.01, "oracle_threatens(%s, %s)"}, - {"value", 0, 2, 0.0, "(%s->value)"} + {"value", 0, 2, 0.0, "(%s->value)"}, + {"adjacent_to_defendable_stone_in_atari", 1, 0, 1.0, + "adjacent_to_defendable_stone_in_atari(%s)"} }; Index: patterns/patterns.db =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.db,v retrieving revision 1.97 diff -u -r1.97 patterns.db --- patterns/patterns.db 4 Jan 2003 15:31:58 -0000 1.97 +++ patterns/patterns.db 12 Jan 2003 11:26:49 -0000 @@ -1284,6 +1284,68 @@ ;!oplay_defend(*,a,b,a) && oplay_attack(*,b,a,c,c) +Pattern CC84 +# Formerly called EC37 + +XO?? prevent double nozoki +O.O? +?*.O +??OX + +:8,nC + + +Pattern CC85 +# Formerly called EC38 + +?XO? prevent ko +.O*O +O..X +?XXX + +:8,C + + +Pattern CC86 +# Formerly called EC39 + +??o? connect out +X..O +O.*X +?.?? + +:8,C + +??o? +X..O +O.*A +?.?? + +; lib(A)==2 + + +Pattern CC87 +# Formerly called EC40 + +??o? connect out +X*.O +O.OX +?.?? + +:8,C + + +Pattern CC88 +# Formerly called EC41 + +.O. cut! +.*X +X.. +..O + +:8,OB + + ########################## # # General Edge Connections @@ -1881,63 +1943,6 @@ ;ko(a) && alive(b) -Pattern EC37 - -XO?? prevent double nozoki -O.O? -?*.O -??OX - -:8,nC - - -Pattern EC38 - -?XO? prevent ko -.O*O -O..X -?XXX - -:8,C - - -Pattern EC39 - -??o? connect out -X..O -O.*X -?.?? - -:8,C - -??o? -X..O -O.*A -?.?? - -; lib(A)==2 - - -Pattern EC40 - -??o? connect out -X*.O -O.OX -?.?? - -:8,C - - -Pattern EC41 - -.O. cut! -.*X -X.. -..O - -:8,OB - - Pattern EC42 ..OO? cut @@ -2500,6 +2505,22 @@ --- :8,C + + +Pattern EC80 +# gf New Pattern (3.3.15) + +XOOX block edge connection +X.*. +---- + +:8,OB + +XOOX +Xa*. +---- + +;xplay_attack(*,a,a) ############################################## Index: patterns/patterns.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v retrieving revision 1.48 diff -u -r1.48 patterns.h --- patterns/patterns.h 3 Jan 2003 18:23:42 -0000 1.48 +++ patterns/patterns.h 12 Jan 2003 11:26:49 -0000 @@ -300,6 +300,7 @@ int edge_double_sente_helper(int move, int apos, int bpos, int cpos); int dragon_weak(int pos); void test_attack_either_move(int move, int color, int worma, int wormb); +int adjacent_to_defendable_stone_in_atari(int str); void init_tree_conn(void); Index: patterns/patterns2.db =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/patterns2.db,v retrieving revision 1.51 diff -u -r1.51 patterns2.db --- patterns/patterns2.db 2 Jan 2003 19:41:19 -0000 1.51 +++ patterns/patterns2.db 12 Jan 2003 11:26:53 -0000 @@ -2083,12 +2083,18 @@ Pattern Shape48 +# gf Added constraint. (3.3.15) .X. makes it harder for X to make eyes *.X :8,s,shape(1) +.A. +*.X + +;weak(A) + Pattern Shape49 @@ -2640,6 +2646,21 @@ ;(xlib(*)==2 || (lib(a)>2 && xlib(*) < xlib(c))) ;&& !oplay_defend(c,B) + + +Pattern Shape86 +# gf New pattern. (3.3.15) +# Prefer cut to peep as ko threat. + +XO ko threat +*X + +:/,sX,shape(1) + +AO +*B + +;oplay_attack_either(*,A,B) ###########################