gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] a patch from a newbie :)


From: Portela Fernand
Subject: [gnugo-devel] a patch from a newbie :)
Date: Tue, 10 Sep 2002 04:43:30 +0200

Hello,

I would like to submit a patch for revision/discussion. I tried to solve the
problem in blunder.tst:12 and after a long thought (+ reading and tracing
the
source code), I came up with the attached patch. I have been very
conservative, 
since I didn't allow for any breakage in the regressions, but I think that
this patch has a good margin for improvements. But before working any
further 
on it and since it involves some important changes (see gnugo.h), I would
like
it to be first reviewed and discussed here.

Summary: 3 PASSes and no FAILs.

---- File [blunder.tst]
12 PASSED
20 PASSED
---- File [trevor.tst]
290 PASSED


/nando


diff -u -r gnugo-3.3.8/engine/filllib.c gnugo-3.3.8-patch/engine/filllib.c
--- gnugo-3.3.8/engine/filllib.c        2002-09-05 01:19:18.000000000 +0200
+++ gnugo-3.3.8-patch/engine/filllib.c  2002-09-10 03:35:20.000000000 +0200
@@ -58,12 +58,12 @@
     case EMPTY:
       if (!(*found_black)
          && living_neighbor(pos, BLACK)
-         && safe_move(pos, WHITE) != 3)
+         && safe_move(pos, WHITE) != WIN)
        *found_black = 1;
       
       if (!(*found_white)
          && living_neighbor(pos, WHITE)
-         && safe_move(pos, BLACK) != 3)
+         && safe_move(pos, BLACK) != WIN)
        *found_white = 1;
       
       break;
diff -u -r gnugo-3.3.8/engine/gnugo.h gnugo-3.3.8-patch/engine/gnugo.h
--- gnugo-3.3.8/engine/gnugo.h  2002-09-03 16:13:38.000000000 +0200
+++ gnugo-3.3.8-patch/engine/gnugo.h    2002-09-10 03:37:42.000000000 +0200
@@ -66,11 +66,16 @@
 
 /* Return codes for reading functions */
 
-#define WIN  3
-#define KO_A 2
+/* FIXME: HALFWIN and HALFLOSS are misnamed, but I couldn't figure anything
better */
+#define WIN  5
+#define KO_A 4
+#define HALFWIN 3
+#define HALFLOSS 2
 #define KO_B 1
 #define LOSE 0
-#define CUT  2
+
+/* FIXME: should this be changed too or not ? */
+#define CUT  4
 
 /* Group statuses */
 #define DEAD        0
diff -u -r gnugo-3.3.8/engine/move_reasons.c
gnugo-3.3.8-patch/engine/move_reasons.c
--- gnugo-3.3.8/engine/move_reasons.c   2002-09-05 01:19:18.000000000 +0200
+++ gnugo-3.3.8-patch/engine/move_reasons.c     2002-09-10
03:40:38.000000000 +0200
@@ -1147,6 +1147,8 @@
   ASSERT_ON_BOARD1(dr);
   if (code == WIN)
     add_move_reason(pos, OWL_ATTACK_MOVE, dragon1);
+  else if (code == HALFWIN && dragon[dr].crude_status == ALIVE)
+    add_move_reason(pos, OWL_ATTACK_MOVE, dragon1);
   else if (code == KO_A)
     add_move_reason(pos, OWL_ATTACK_MOVE_GOOD_KO, dragon1);
   else if (code == KO_B)
@@ -1169,6 +1171,8 @@
     add_move_reason(pos, OWL_DEFEND_MOVE_GOOD_KO, dragon1);
   else if (code == KO_B)
     add_move_reason(pos, OWL_DEFEND_MOVE_BAD_KO, dragon1);
+  else if (code == HALFLOSS)
+    add_move_reason(pos, OWL_DEFEND_MOVE, dragon1);
 }
 
 /*
diff -u -r gnugo-3.3.8/engine/owl.c gnugo-3.3.8-patch/engine/owl.c
--- gnugo-3.3.8/engine/owl.c    2002-09-05 01:19:18.000000000 +0200
+++ gnugo-3.3.8-patch/engine/owl.c      2002-09-10 03:41:57.000000000 +0200
@@ -1438,6 +1438,7 @@
       int new_komaster;
       int new_kom_pos;
       int origin = NO_MOVE;
+      int captured;
 
       /* Consider only the highest scoring move if we're deeper than
        * owl_branch_depth.
@@ -1480,12 +1481,16 @@
       if (mw[mpos])
        continue;
 
+      captured = (color==WHITE? white_captured : black_captured);
+
       /* Try to make the move. */
       if (!komaster_trymove(mpos, other, moves[k].name, str,
                            komaster, kom_pos, &new_komaster, &new_kom_pos,
                            &ko_move, savecode == 0))
        continue;
 
+      captured = (color==WHITE? white_captured : black_captured)-captured;
+
       TRACE("Trying %C %1m. Escape = %d. Current stack: ",
            other, mpos, escape);
       if (verbose)
@@ -1540,7 +1545,14 @@
           close_pattern_list(other, &shape_patterns);
          READ_RETURN(read_result, move, mpos, WIN);
        }
-       UPDATE_SAVED_KO_RESULT(savecode, savemove, dcode, mpos);
+       /* FIXME: Of course, a constant is no good here. But I haven't yet 
+                 solved the problem of how to decide what is "big enough"
*/
+       else if(captured>3) {
+         UPDATE_SAVED_KO_RESULT(savecode, savemove, HALFLOSS, mpos);
+       }
+       else {
+         UPDATE_SAVED_KO_RESULT(savecode, savemove, dcode, mpos);
+       }
       }
       else { /* ko_move */
        if (dcode != WIN) {
@@ -3631,12 +3643,12 @@
     if (search_persistent_owl_cache(OWL_ATTACK, origin, 0, 0,
                                    &result, NULL, NULL, NULL)) {
       popgo();
-      return 3 - result;
+      return WIN - result;
     }
     
     init_owl(&owl, target, NO_MOVE, move, 1);
     acode = do_owl_attack(target, NULL, owl, EMPTY, 0, 0);
-    result = 3 - acode;
+    result = WIN - acode;
     popgo();
   }
   else
@@ -3773,7 +3785,7 @@
     if (search_persistent_owl_cache(OWL_DEFEND, origin, 0, 0,
                                    &result, NULL, NULL, NULL)) {
       popgo();
-      return 3 - result;
+      return WIN - result;
     }
 
 #if 0
@@ -3792,7 +3804,7 @@
       dcode = 0;
     else
       dcode = do_owl_defend(target, NULL, owl, EMPTY, 0, 0);
-    result = 3 - dcode;
+    result = WIN - dcode;
     owl->lunches_are_current = 0;
     popgo();
   }
diff -u -r gnugo-3.3.8/engine/worm.c gnugo-3.3.8-patch/engine/worm.c
--- gnugo-3.3.8/engine/worm.c   2002-09-05 01:19:18.000000000 +0200
+++ gnugo-3.3.8-patch/engine/worm.c     2002-09-10 03:44:22.000000000 +0200
@@ -1565,11 +1565,11 @@
          * possible that it only has a ko defense and then we would
          * risk to find an irrelevant move to attack with ko.
         */
-       if (dcode != WIN && 3 - dcode >= worm[str].attack_codes[0]) {
-         change_attack(str, move, 3 - dcode);
+       if (dcode != WIN && WIN - dcode >= worm[str].attack_codes[0]) {
+         change_attack(str, move, WIN - dcode);
          DEBUG(DEBUG_WORMS,
                "Attack pattern %s+%d found attack on %1m at %1m with code
%d\n",
-               pattern->name, ll, str, move, 3 - dcode);
+               pattern->name, ll, str, move, WIN - dcode);
        }
       }
     }
@@ -1635,10 +1635,10 @@
        popgo();
        
        if (acode < worm[str].attack_codes[0]) {
-         change_defense(str, move, 3 - acode);
+         change_defense(str, move, WIN - acode);
          DEBUG(DEBUG_WORMS,
                "Defense pattern %s+%d found defense of %1m at %1m with code
%d\n",
-               pattern->name, ll, str, move, 3 - acode);
+               pattern->name, ll, str, move, WIN - acode);
        }
       }
     }
diff -u -r gnugo-3.3.8/interface/play_gtp.c
gnugo-3.3.8-patch/interface/play_gtp.c
--- gnugo-3.3.8/interface/play_gtp.c    2002-09-03 16:13:38.000000000 +0200
+++ gnugo-3.3.8-patch/interface/play_gtp.c      2002-09-10
03:46:17.000000000 +0200
@@ -2923,7 +2923,7 @@
 static void
 gtp_print_code(int c)
 {
-  gtp_printf("%d", c ? 4-c : c);
+  gtp_printf("%d", c ? (WIN+1)-c : c);
 }
 
 static void
diff -u -r gnugo-3.3.8/regression/connection.tst
gnugo-3.3.8-patch/regression/connection.tst
--- gnugo-3.3.8/regression/connection.tst       2002-08-13
19:59:14.000000000 +0200
+++ gnugo-3.3.8-patch/regression/connection.tst 2002-09-10
04:00:47.000000000 +0200
@@ -302,7 +302,7 @@
 # See also nngs2:130
 loadsgf games/nngs/joshj-gnugo-3.3.2-200205310709.sgf 124
 93 disconnect K2 L3
-#? [3 L2]*
+#? [5 L2]*
 
 
 # Report number of nodes visited by the tactical reading
diff -u -r gnugo-3.3.8/regression/ld_owl.tst
gnugo-3.3.8-patch/regression/ld_owl.tst
--- gnugo-3.3.8/regression/ld_owl.tst   2002-08-13 19:58:50.000000000 +0200
+++ gnugo-3.3.8-patch/regression/ld_owl.tst     2002-09-10
01:35:58.000000000 +0200
@@ -224,7 +224,7 @@
 162 dragon_status R3
 #? [critical P1 R1]
 163 owl_attack C3
-#? [3 B1]
+#? [5 B1]
 164 owl_defend C3
 #? [1 (B2|B1|A2)]
 
@@ -234,7 +234,7 @@
 166 owl_defend C17
 #? [2 B18]
 167 owl_attack R17
-#? [3 T15]
+#? [5 T15]
 168 owl_defend R17
 #? [1 (R19|T16|T18|T19)]
 169 owl_attack R3
@@ -242,7 +242,7 @@
 170 owl_defend R3
 #? [2 Q1]
 171 owl_attack C3
-#? [3 A2]
+#? [5 A2]
 172 owl_defend C3
 #? [1 (C1|A2)]
 
@@ -264,7 +264,7 @@
 178 owl_defend C17
 #? [1 (A19|A17)]
 179 owl_attack R17
-#? [3 T17]
+#? [5 T17]
 180 owl_defend R17
 #? [1 (Q18|T17|S18|T18|S17|S19)]
 181 owl_attack R3
@@ -272,7 +272,7 @@
 182 owl_defend R3
 #? [2 S1]
 183 owl_attack C3
-#? [3 B2]
+#? [5 B2]
 184 owl_defend C3
 #? [1 (B1|B2|B3|A4|D2)]
 
@@ -298,7 +298,7 @@
 193 dragon_status R3
 #? [critical (S4|T4|T5) S4]
 194 owl_attack C3
-#? [3 B1]
+#? [5 B1]
 195 owl_defend C3
 #? [1 (C1|A5|A3|A2|B1)]
 
@@ -319,7 +319,7 @@
 300 owl_attack  C17
 #? [1 (E19|D19|C19|B18|B19|A18|A19)]
 301 owl_defend  C17
-#? [3 B18]
+#? [5 B18]
 302 dragon_status R17
 #? [critical T19 (Q19|R18)]
 303 dragon_status R3
diff -u -r gnugo-3.3.8/regression/ld_owl_rot.tst
gnugo-3.3.8-patch/regression/ld_owl_rot.tst
--- gnugo-3.3.8/regression/ld_owl_rot.tst       2002-01-18
08:19:56.000000000 +0100
+++ gnugo-3.3.8-patch/regression/ld_owl_rot.tst 2002-09-10
04:02:09.000000000 +0200
@@ -1,7 +1,7 @@
 orientation 2
 loadsgf games/life_and_death/tripod6.sgf
 179 owl_attack R17
-#? [3 T17]*
+#? [5 T17]*
 
 orientation 2
 loadsgf games/life_and_death/tripod9.sgf
diff -u -r gnugo-3.3.8/regression/owl.tst
gnugo-3.3.8-patch/regression/owl.tst
--- gnugo-3.3.8/regression/owl.tst      2002-09-03 16:13:38.000000000 +0200
+++ gnugo-3.3.8-patch/regression/owl.tst        2002-09-10
03:08:48.000000000 +0200
@@ -522,7 +522,7 @@
 
 loadsgf games/nicklas/nicklas19.sgf 61
 141 owl_attack H8
-#? [3 J8]
+#? [5 J8]
 142 owl_defend H8
 #? [1 (H9|J8|J9|H7|J7)]
 
@@ -534,7 +534,7 @@
 
 loadsgf games/nicklas/nicklas19.sgf 63
 145 owl_attack H8
-#? [3 H9]
+#? [5 H9]
 146 owl_defend H8
 #? [1 (H9|J7)]
 
@@ -576,7 +576,7 @@
 156 owl_attack M19
 #? [1 O13]*
 157 owl_defend M19
-#? [3 (P16|Q15)]*
+#? [5 (P16|Q15)]*
 
 # There might be some attack here, but at least both S16 and S15 fail.
 loadsgf games/strategy26.sgf 51
@@ -628,7 +628,7 @@
 # incident 284
 loadsgf games/incident278.sgf 318
 171 owl_attack A6
-#? [3 (B3|C1|A1)]*
+#? [5 (B3|C1|A1)]*
 172 owl_defend A6
 #? [1 (B3|C1)]
 
@@ -647,7 +647,7 @@
 
 loadsgf games/incident240.sgf 103
 176 owl_defend C4
-#? [3 G1]
+#? [5 G1]
 
 # incident 105
 loadsgf games/incident104.sgf 169
@@ -659,7 +659,7 @@
 178 owl_attack R13
 #? [1 (R19|T18)]*
 179 owl_defend R13
-#? [3 R19]
+#? [5 R19]
 
 loadsgf games/incident269.sgf 200
 180 owl_attack R19
@@ -674,7 +674,7 @@
 182 owl_attack C18
 #? [2 (A15|A17)]
 183 owl_defend C18
-#? [3 (A17|B18)]
+#? [5 (A17|B18)]
 
 # incident 212
 # There may be a few more defenses.
@@ -753,7 +753,7 @@
 204 owl_attack H6
 #? [1 (H9|E9)]
 205 owl_defend H6
-#? [3 H9]
+#? [5 H9]
 
 loadsgf games/owl26.sgf 10
 206 owl_attack C12
@@ -765,7 +765,7 @@
 
 loadsgf games/incident248.sgf 228
 208 owl_attack J2
-#? [3 A2]*
+#? [5 A2]*
 209 owl_defend J2
 #? [1 (A2|F1|J1|A1|B1)]
 
@@ -778,7 +778,7 @@
 # Incident 190.
 loadsgf games/incident189.sgf 186
 212 owl_attack K13
-#? [3 E16]
+#? [5 E16]
 213 owl_defend K13
 #? [1 (D18|E16|M16|E18)]
 
@@ -819,7 +819,7 @@
 
 loadsgf games/incident169.sgf 224
 223 owl_defend R17
-#? [3 S16]
+#? [5 S16]
 
 loadsgf games/ego.sgf 198
 224 owl_attack T17
@@ -827,7 +827,7 @@
 
 loadsgf games/ego.sgf 198
 225 owl_defend T17
-#? [3 Q19|S16]*
+#? [5 Q19|S16]*
 
 loadsgf games/owl29.sgf 132
 226 owl_attack J10
@@ -854,7 +854,7 @@
 231 owl_attack A8
 #? [1 (C6|A4)]
 232 owl_defend A8
-#? [3 C6]*
+#? [5 C6]*
 233 owl_attack F6
 #? [1 H7]*
 234 owl_defend F6
@@ -887,11 +887,11 @@
 243 owl_attack A11
 #? [0]
 244 owl_attack D11
-#? [(2|3) F11]
+#? [(2|5) F11]
 245 owl_defend D11
 #? [1 (F11|H8|F8|H5)]
 246 owl_attack O9
-#? [3 (M6|Q8)]
+#? [5 (M6|Q8)]
 247 owl_defend O9
 #? [1 (M6|Q8)]
 248 owl_attack A6
@@ -901,7 +901,7 @@
 250 owl_attack R3
 #? [1 (T3|R2)]
 251 owl_defend R3
-#? [3 T3]
+#? [5 T3]
 252 owl_attack C2
 #? [2 B2]
 253 owl_defend C2
diff -u -r gnugo-3.3.8/regression/owl_rot.tst
gnugo-3.3.8-patch/regression/owl_rot.tst
--- gnugo-3.3.8/regression/owl_rot.tst  2002-06-20 00:26:44.000000000 +0200
+++ gnugo-3.3.8-patch/regression/owl_rot.tst    2002-09-10
04:04:02.000000000 +0200
@@ -37,7 +37,7 @@
 orientation 3
 loadsgf games/marginal_ko.sgf
 244 owl_attack D11
-#? [(2|3) F11]*
+#? [(2|5) F11]*
 
 orientation 3
 loadsgf games/marginal_ko.sgf
diff -u -r gnugo-3.3.8/regression/reading.tst
gnugo-3.3.8-patch/regression/reading.tst
--- gnugo-3.3.8/regression/reading.tst  2002-09-03 16:13:38.000000000 +0200
+++ gnugo-3.3.8-patch/regression/reading.tst    2002-09-10
03:09:11.000000000 +0200
@@ -141,7 +141,7 @@
 # Technically N1 also works with ko, but it's inferior since we have
 # to win the ko twice.
 31 attack J10
-#? [3 (F1|F2)]
+#? [5 (F1|F2)]
 # This test passes if ko depth is increased to 9.
 32 defend J10
 #? [2 J1]
@@ -254,7 +254,7 @@
 loadsgf games/reading03.sgf
 # Should find ko attack. Also a life and death problem
 56 attack J7
-#? [3 J8]
+#? [5 J8]
 
 # incident 252
 loadsgf games/incident252.sgf 134
@@ -272,7 +272,7 @@
 # further analysis, we accept both return codes 2 and 3.
 loadsgf games/incident272.sgf 252
 59 defend N2
-#? [(2|3) P5]
+#? [(2|5) P5]
 
 # incident 280
 loadsgf games/incident278.sgf 160
@@ -296,7 +296,7 @@
 
 loadsgf games/nicklas/nicklas11.sgf 244
 64 defend P8
-#? [3 N1]
+#? [5 N1]
 
 loadsgf games/reading06.sgf
 65 defend S5
@@ -313,11 +313,11 @@
 
 loadsgf games/reading07.sgf 2
 69 defend G9
-#? [3 E8]
+#? [5 E8]
 70 attack F8
-#? [3 E8]
+#? [5 E8]
 71 attack E9
-#? [3 E8]
+#? [5 E8]
 
 # A simplification of incident 225. Ko tests.
 loadsgf games/reading08.sgf
@@ -326,7 +326,7 @@
 73 defend G9
 #? [1 E6]
 74 attack E8
-#? [3 E9]
+#? [5 E9]
 75 defend E8
 #? [1 (E6|E9|D9|D8)]
 76 attack C9
@@ -337,24 +337,24 @@
 # A simplification of incident 119. Ko tests.
 loadsgf games/reading09.sgf 1
 78 attack C5
-#? [3 (C1|C2)]
+#? [5 (C1|C2)]
 79 defend C5
 #? [2 F1]
 80 attack E5
 #? [2 F1]
 81 defend E5
-#? [3 (C1|C2)]
+#? [5 (C1|C2)]
 
 # More ko tests.
 loadsgf games/reading09.sgf 3
 82 attack C5
-#? [3 G1]
+#? [5 G1]
 83 defend C5
 #? [1 F3]
 84 attack E5
 #? [1 F3]
 85 defend E5
-#? [3 G1]
+#? [5 G1]
 
 # Failure to consider double atari on surrounding chain.
 loadsgf games/reading10.sgf
@@ -398,7 +398,7 @@
 # Ko mistake
 loadsgf games/reading13.sgf 2
 95 attack B5
-#? [3 E1]
+#? [5 E1]
 
 # Ko mistake
 loadsgf games/reading13.sgf 3
@@ -408,7 +408,7 @@
 # Simplification of tests 31 and 32, ko mistakes.
 loadsgf games/reading13.sgf 4
 97 attack B5
-#? [3 (A3|E6)]
+#? [5 (A3|E6)]
 98 defend B5
 #? [2 D1]
 
@@ -503,7 +503,7 @@
 127 attack D9
 #? [1 F7]
 128 defend D9
-#? [3 F7]
+#? [5 F7]
 
 # Backfilling insufficient, need to back-capture.
 loadsgf games/reading22.sgf
@@ -525,7 +525,7 @@
 132 attack J8
 #? [2 J9]
 133 defend J8
-#? [3 F9]
+#? [5 F9]
 
 # See also test case 137.
 loadsgf games/strategy27.sgf 62
diff -u -r gnugo-3.3.8/regression/trevor.tst
gnugo-3.3.8-patch/regression/trevor.tst
--- gnugo-3.3.8/regression/trevor.tst   2002-09-05 01:19:18.000000000 +0200
+++ gnugo-3.3.8-patch/regression/trevor.tst     2002-09-10
04:04:45.000000000 +0200
@@ -349,14 +349,14 @@
 #SEE_ALSO=owl.tst#226
 loadsgf games/trevor/trevor_35.sgf
 350 owl_defend J10
-#? [(2|3) L8]
+#? [(2|5) L8]
 
 #CATEGORY=
 #DESCRIPTION=
 #SEVERITY=
 loadsgf games/trevor/trevor_36.sgf
 360 owl_defend G8
-#? [(2|3) J9]*
+#? [(2|5) J9]*
 
 #CATEGORY=OWL_BUG
 #DESCRIPTION=Can safely connect out!
@@ -504,11 +504,11 @@
 #SEE_ALSO=owl:181
 loadsgf games/trevor/trevor_47.sgf
 470 owl_attack G9
-#? [(2|3) G6]
+#? [(2|5) G6]
 
 #SEE_ALSO=trevor:470
 471 owl_attack A7
-#? [(2|3) A3]
+#? [(2|5) A3]
 
 
 #CATEGORY=pattern_tuning
@@ -561,7 +561,7 @@
 #SEVERITY=6
 loadsgf games/trevor/trevor_65.sgf
 650 owl_attack G2
-#? [(2|3) E1]
+#? [(2|5) E1]
 
 #CATEGORY=OWL_TUNING
 #DESCRIPTION=short of liberties
@@ -572,7 +572,7 @@
 
 loadsgf games/trevor/trevor_67.sgf
 670 attack G1
-#? [(2|3) F1]
+#? [(2|5) F1]
 
 loadsgf games/trevor/trevor_67.sgf
 671 defend G1
@@ -604,7 +604,7 @@
 
 loadsgf games/trevor/trevor_73.sgf
 730 owl_attack M2
-#? [(2|3) H1]*
+#? [(2|5) H1]*
 
 
 loadsgf games/trevor/trevor_74.sgf
@@ -649,7 +649,7 @@
 
 loadsgf games/trevor/auto/c17.sgf 55
 1040 attack H13
-#? [(2|3) H12]*
+#? [(2|5) H12]*
 
 # gf B1 is also an effective attack.
 loadsgf games/trevor/auto/c30.sgf 62





reply via email to

[Prev in Thread] Current Thread [Next in Thread]