Ticket #199: gunnar_9_1.17.diff

File gunnar_9_1.17.diff, 5.0 KB (added by gunnar, 22 months ago)

Do not play common liberties after having already passed.

  • engine/owl.c

    diff --git a/engine/owl.c b/engine/owl.c
    index 9b87cc0..9dc7574 100644
    a b static int semeai_trymove_and_recurse(int apos, int bpos, 
    267267                                      int move_value, const char *move_name, 
    268268                                      enum same_dragon_value same_dragon, 
    269269                                      struct matched_pattern_data *pattern_data, 
    270                                       int lunch, int *semeai_move, 
     270                                      int lunch, int pass, int *semeai_move, 
    271271                                      int *this_resulta, int *this_resultb); 
    272272static void semeai_add_sgf_comment(int value, int owl_phase); 
    273273static int semeai_trust_tactical_attack(int str); 
    owl_analyze_semeai_after_move(int move, int color, int apos, int bpos, 
    579579  else { 
    580580    semeai_trymove_and_recurse(bpos, apos, owlb, owla, owl, 
    581581                               move, color, 1, 0, "mandatory move", 
    582                                SAME_DRAGON_MAYBE_CONNECTED, NULL, NO_MOVE, 
     582                               SAME_DRAGON_MAYBE_CONNECTED, NULL, NO_MOVE, 0, 
    583583                               semeai_move, resultb, resulta); 
    584584    *resulta = REVERSE_RESULT(*resulta); 
    585585    *resultb = REVERSE_RESULT(*resultb); 
    do_owl_analyze_semeai(int apos, int bpos, 
    10941094                                     owla, owlb, 50, 
    10951095                                     critical_semeai_worms); 
    10961096      owl_add_move(moves, backfill_outside_liberty.pos, move_value, 
    1097                    "backfilling move", SAME_DRAGON_NOT_CONNECTED, NO_MOVE, 0, 
     1097                   "backfilling move for outer liberty", SAME_DRAGON_NOT_CONNECTED, NO_MOVE, 0, 
    10981098                   NO_MOVE, MAX_SEMEAI_MOVES, NULL); 
    10991099      riskless_move_found = 1; 
    11001100      TRACE("Added %1m %d (6)\n", backfill_outside_liberty.pos, move_value); 
    do_owl_analyze_semeai(int apos, int bpos, 
    11101110      riskless_move_found = 1; 
    11111111      TRACE("Added %1m %d (5)\n", eyefilling_liberty.pos, move_value); 
    11121112    } 
    1113     else if (safe_common_liberty_found 
     1113    else if (!(pass & color) && safe_common_liberty_found 
    11141114             && common_liberty.pos != NO_MOVE) { 
    11151115      move_value = semeai_move_value(common_liberty.pos, 
    11161116                                     owla, owlb, 10, 
    do_owl_analyze_semeai(int apos, int bpos, 
    11221122        riskless_move_found = 1; 
    11231123      TRACE("Added %1m %d (7)\n", common_liberty.pos, move_value); 
    11241124    } 
    1125     else if (backfill_common_liberty.pos != NO_MOVE) { 
     1125    else if (!(pass & color) && backfill_common_liberty.pos != NO_MOVE) { 
    11261126      move_value = semeai_move_value(backfill_common_liberty.pos, 
    11271127                                     owla, owlb, 10, 
    11281128                                     critical_semeai_worms); 
    11291129      owl_add_move(moves, backfill_common_liberty.pos, move_value, 
    1130                    "backfilling move", SAME_DRAGON_NOT_CONNECTED, NO_MOVE, 0, 
     1130                   "backfilling move for common liberty", SAME_DRAGON_NOT_CONNECTED, NO_MOVE, 0, 
    11311131                   NO_MOVE, MAX_SEMEAI_MOVES, NULL); 
    11321132      /* Playing a backfilling move for common liberties inside own 
    11331133       * eyespace is not risk free, regardless of the tactical 
    do_owl_analyze_semeai(int apos, int bpos, 
    11961196                                   best_resulta == 0 || best_resultb == 0, 
    11971197                                   moves[k].value, moves[k].name, 
    11981198                                   moves[k].same_dragon, moves[k].pattern_data, 
    1199                                    moves[k].lunch, NULL, 
     1199                                   moves[k].lunch, pass, NULL, 
    12001200                                   &this_resulta, &this_resultb)) { 
    12011201      tested_moves++; 
    12021202      if (this_resultb == WIN && this_resulta == WIN) { 
    do_owl_analyze_semeai(int apos, int bpos, 
    12851285   */ 
    12861286  if (best_resulta == 0 && best_resultb == 0 
    12871287      && !riskless_move_found) { 
    1288     if (pass) { 
     1288    if (pass & OTHER_COLOR(color)) { 
    12891289      if (max_eyes(&probable_eyes_a) < min_eyes(&probable_eyes_b)) { 
    12901290        *resulta = 0; 
    12911291        *resultb = 0; 
    do_owl_analyze_semeai(int apos, int bpos, 
    13171317    else { 
    13181318    /* No working move was found, but opponent hasn't passed. Then we pass. */ 
    13191319      do_owl_analyze_semeai(bpos, apos, owlb, owla, 
    1320                             resultb, resulta, NULL, 1, owl_phase); 
     1320                            resultb, resulta, NULL, pass | color, owl_phase); 
    13211321      *resulta = REVERSE_RESULT(*resulta); 
    13221322      *resultb = REVERSE_RESULT(*resultb); 
    13231323      TRACE("No move found\n"); 
    do_owl_analyze_semeai(int apos, int bpos, 
    13581358        || (best_resulta == KO_B && best_resultb == KO_B 
    13591359            && is_ko(best_move, owla->color, NULL))) { 
    13601360      do_owl_analyze_semeai(bpos, apos, owlb, owla, &this_resultb, 
    1361                             &this_resulta, NULL, 1, owl_phase); 
     1361                            &this_resulta, NULL, pass | color, owl_phase); 
    13621362      if (REVERSE_RESULT(this_resulta) >= best_resulta 
    13631363          && REVERSE_RESULT(this_resultb) >= best_resultb) { 
    13641364        best_move = PASS_MOVE; 
    semeai_trymove_and_recurse(int apos, int bpos, struct local_owl_data *owla, 
    13911391                           int move_value, const char *move_name, 
    13921392                           enum same_dragon_value same_dragon, 
    13931393                           struct matched_pattern_data *pattern_data, 
    1394                            int lunch, int *semeai_move, 
     1394                           int lunch, int pass, int *semeai_move, 
    13951395                           int *this_resulta, int *this_resultb) 
    13961396{ 
    13971397  int ko_move = 0; 
    semeai_trymove_and_recurse(int apos, int bpos, struct local_owl_data *owla, 
    14941494  else { 
    14951495    do_owl_analyze_semeai(bpos, apos, owlb, owla, 
    14961496                          this_resultb, this_resulta, semeai_move, 
    1497                           0, owl_phase); 
     1497                          pass, owl_phase); 
    14981498    *this_resulta = REVERSE_RESULT(*this_resulta); 
    14991499    *this_resultb = REVERSE_RESULT(*this_resultb); 
    15001500  }